总积分(综合积分)显示在文章页面(read)的方法(For 6.3.2 & 7.0)
2009-03-01 00:18:58 来源:WEB开发网有人要总积分的显示方法,这个数据库里没现成的字段,是根据现有的威望金钱等算出来的
打开read.php
搜索
$read['groupid']==6 && $read['honor'] = '';
下面加上
//总积分计算开始
$usercredit=array(
'postnum' => $read['postnum'],
'digests' => $read['digests'],
'rvrc' => $read['rvrc'],
'money' => $read['money'],
'credit' => $read['credit'],
'onlinetime'=> $read['onlinetime'],
);
include(D_P.'data/bbscache/config.php');
$upgradeset = unserialize($db_upgrade);
foreach($upgradeset as $key=>$val){
if(is_numeric($key)){
foreach(GetCredit($read['uid']) as $key=>$value){
$usercredit[$key] = $value[1];
}
break;
}
}
$read['total'] = CalculateCredit($usercredit,$upgradeset);
//总积分计算结束
然后在这个文件最后
?>
之前,加上
//总积分计算开始
function GetCredit($uid){
global $db,$_CREDITDB;
$credit = array();
if (is_array($_CREDITDB)) {
foreach ($_CREDITDB as $key => $value) {
$credit[$key] = array($value[0],0);
}
}
$query = $db->query("SELECT cid,value FROM pw_membercredit WHERE uid='$uid'");
while ($rt = $db->fetch_array($query)) {
$credit[$rt['cid']] = array($_CREDITDB[$rt['cid']][0],$rt['value']);
}
return $credit;
}
function CalculateCredit($creditdb,$upgradeset){
$credit=0;
foreach($upgradeset as $key=>$val){
if($creditdb[$key] && $val){
if($key == 'rvrc'){
$creditdb[$key] /= 10;
} elseif($key == 'onlinetime'){
$creditdb[$key] /= 3600;
}
$credit += $creditdb[$key]*$val;
}
}
return (int)$credit;
}
//总积分计算结束
然后打开template/wind/read.htm
找到
发帖: $read[postnum]
前面加上
总积分: $read[total]
当然这个位置随您喜好而定
更多精彩
赞助商链接