<?php
//统计字数
function utf8_strlen($string = null) {
    preg_match_all("/./us", $string, $match);
    return count($match[0]);
}
function huifunums($gro) {
	$wapid = WAPID;
    $result = mysql_query("SELECT count(*) FROM bbscomm WHERE siteid='{$wapid}' AND gro='{$gro}'");
    list($nums) = mysql_fetch_row($result);
    return $nums;
}
function viewStr($str, $wordNums, $id) {
    if (utf8_strlen($str) > $wordNums) {
        $text.= mb_substr($str, 0, $wordNums, "UTF-8") . '...<br>';
        $text.= '<a href="viewContent.php?f=y&id=' . $id . '">查看所有内容>></a>';
		return $text;
    }
    return $str;
}
function viewType($type, $value, $str) {
    if ($type == 'noLoginStop' && $GLOBALS['login'] == 0) {
        return '<font color="red">此帖只能<a href="http://' . $_SERVER['HTTP_HOST'] . '/login.php">登录</a>可见哦</font>';
    } elseif ($type == 'creMin' && crevalue < $value) {
        return '<font color="red">您的金币必须大于' . $value . '才可以查看内容！您当前的可用余额是' . crevalue . '</font>';
    } elseif ($type == 'buy') {
        if (!is_dir("buylog")) {
            mkdir("buylog");
        }
        if (!is_file("buylog/" . $_GET['id'] . "_" . MYID . "_" . XID . ".txt")) {
            return '<font color="red">您好，您必须支付' . $vlue . '积分(您的余额' . crevalue . ')才能继续查看！[<a href="buy.php?cid=' . $_GET['cid'] . '&id=' . $_GET['id'] . '&act=buy">确认支付</a>]</font>';
        }
        return $str;
    } elseif ($type == 'vip') {
        if (user('vip', 'id', MYID) == '1') {
            return $str;
        } else {
            return '<font color="red">您好，您的身份为普通会员，此帖只允许VIP会员查看！</font>';
        }
    } else {
        return $str;
    }
}
function setBbsZan($type)
{
	$cfgValue= new CfgValue('user');
	if($type == 'get'){
		return $cfgValue -> getValue(MYID.'_bbs_zan');
	}else{
	$cfgValue -> intoOne(
		array(
			MYID.'_bbs_zan' => 'isok'
			)
		);
	}
}