<?php  if(!defined('DEDEINC')) exit('dedecms');
/**
 * 扩展小助手
 *
 * @version        $Id: extend.helper.php 1 13:58 2010年7月5日Z tianya $
 * @package        DedeCMS.Helpers
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html 
 * @link           http://www.dedecms.com
 */

/**
 *  返回指定的字符
 *
 * @param     string  $n  字符ID
 * @return    string
 */
if ( ! function_exists('ParCv'))
{
    function ParCv($n)
    {
        return chr($n);
    }
}


/**
 *  显示一个错误
 *
 * @return    void
 */
if ( ! function_exists('ParamError'))
{
    function ParamError()
    {
        ShowMsg('对不起，你输入的参数有误！','javascript:;');
        exit();
    }
}

/**
 *  默认属性
 *
 * @param     string  $oldvar  旧的值
 * @param     string  $nv      新值
 * @return    string
 */
if ( ! function_exists('AttDef'))
{
    function AttDef($oldvar, $nv)
    {
        return empty($oldvar) ? $nv : $oldvar;
    }
}


/**
 *  返回Ajax头信息
 *
 * @return     void
 */
if ( ! function_exists('AjaxHead'))
{
    function AjaxHead()
    {
        @header("Pragma:no-cache\r\n");
        @header("Cache-Control:no-cache\r\n");
        @header("Expires:0\r\n");
    }
}

/**
 *  去除html和php标记
 *
 * @return     string
 */
if ( ! function_exists('dede_strip_tags'))
{
	function dede_strip_tags($str) { 
	    $strs=explode('<',$str); 
	    $res=$strs[0]; 
	    for($i=1;$i<count($strs);$i++) 
	    { 
	        if(!strpos($strs[$i],'>')) 
	            $res = $res.'&lt;'.$strs[$i]; 
	        else 
	            $res = $res.'<'.$strs[$i]; 
	    } 
	    return strip_tags($res);    
	} 
}
if( ! function_exists('sitetags'))
{
    function sitetags($aid){
    global $dsql;
    $sql = "SELECT tag FROM #@__webtaglist WHERE aid='$aid' ";
    $dsql->SetQuery($sql);
    $dsql->Execute();
    $menu_i=1;
    while ($row = $dsql->GetArray()) {
        $tags .= "<a href='/sitetags/".urlencode($row['tag']).".html' target='_blank'>".$row['tag']."</a> &nbsp;";
    }
    return $tags;
}
}
if( ! function_exists('listtag'))
{
    function listtag($aid){
    global $dsql;
    $sql = "SELECT tag FROM #@__taglist WHERE aid='$aid' ";
    $dsql->SetQuery($sql);
    $dsql->Execute();
    $menu_i=1;
    while ($row = $dsql->GetArray()) {
        $tags .= "<a href='/tags/".urlencode($row['tag']).".html' target='_blank'>".$row['tag']."</a> &nbsp;&nbsp;";
    }
    return $tags;
}
}

if (!function_exists('alltemp'))
{
function alltemp($path)
{
require_once(DEDEINC."/arc.partview.class.php");
global $cfg_basedir,$cfg_templets_dir,$cfg_df_style;
$tmpfile = $cfg_basedir.$cfg_templets_dir."/".$cfg_df_style."/".$path;
$dtp = new PartView();
$dtp->SetTemplet($tmpfile);
$dtp->Display();
}
}
/**
 *  调用评论数量
 */
if( ! function_exists('pinglunnum'))
{
function pinglunnum($aid){
	global $dsql;
	$sql = GetSonIds($aid);
	$row = $dsql->GetOne("Select count(id) as plnum from #@__feedback where aid='$aid' ");
	if($row['plnum'] == 0){
	return 'O';
	}
	else{
	return $row['plnum'];
	}
	}
}
/**
 *  获取投稿会员ID
 */
if( ! function_exists('getuid')){
	function getuid($mid){
	global $dsql;
	$sql = GetSonIds($mid);
	$row = $dsql->GetOne("select userid from #@__member where mid = $mid");
        return $row['userid'];   
}
}
/**
 *  获取投稿会员QQ
 */
if( ! function_exists('getqq')){
	function getqq($mid){
	global $dsql;
	$sql = GetSonIds($mid);
	$row = $dsql->GetOne("select qq from #@__member where mid = $mid");
        return $row['qq'];   
}
}