Discuz 7.2 评分系统BUG

分类:问题集 | 作者:凹凸曼 | 发表于2011/05/27 Discuz 7.2 评分系统BUG已关闭评论

最近论坛管理员反应评分的系统,不合理!又发现一个BUG

BUG:普通用户A 评帖子B , 用户A 没有积分(交子)都可以打分,并且不扣分

评分如图:

修补BUG:

        文件misc.php  535行插入如下代码:

      /*bug修复 判断extcredits是否有足够*/
        $addcre=1;
        $query=$db->query("select extcredits1 from {$tablepre}members where uid=".$discuz_uid);
        $arr=$db->fetch_row($query);
        if(intval($creditsarray[1])<=0){
            $addcre=0;
           
        }
        if($addcre){
            if(($arr[0]-intval($creditsarray[1]) * 1)<0){
                     showmessage('ajax_thread_rate_jiaozi_invalid');
            } 
        }else{
            if(($arr[0]+intval($creditsarray[1]) * 1)<0){
                     showmessage('ajax_thread_rate_jiaozi_invalid');
            }             
        }  
        /****/
   文件misc.php  676行插入如下代码:
        /*bug修补  */
                    if($ratelog['score']<0)
                    $addcre=1;
                    else
                    $addcre=0;
                    /*end*/

  include/global.func.php文件 替换函数updatecredits为如下代码:

function updatecredits($uids, $creditsarray, $coef = 1, $extrasql = '') {
 if($uids && ((!empty($creditsarray) && is_array($creditsarray)) || $extrasql)) {
  global $db, $tablepre, $discuz_uid, $creditnotice, $cookiecredits,$addcre;
  $self = $creditnotice && $uids == $discuz_uid;
  if($self && !isset($cookiecredits)) {
   $cookiecredits = !empty($_COOKIE['discuz_creditnotice']) ? explode('D', $_COOKIE['discuz_creditnotice']) : array_fill(0, 9, 0);
  }
  $creditsadd = $comma = '';
  foreach($creditsarray as $id => $addcredits) {
   $creditsadd .= $comma.'extcredits'.$id.'=extcredits'.$id.'+('.intval($addcredits).')*('.$coef.')';
            /*bug修补  */ 
            if($addcre)
            $creditsdel .= $comma.'extcredits'.$id.'=extcredits'.$id.'-('.intval($addcredits).')*('.$coef.')';
    else
            $creditsdel .= $comma.'extcredits'.$id.'=extcredits'.$id.'+('.intval($addcredits).')*('.$coef.')'; 
            /**end bug**/
            $comma = ', ';
   if($self) {
    $cookiecredits[$id] += intval($addcredits) * $coef;
   }
  }
  if($self) {
   dsetcookie('discuz_creditnotice', implode('D', $cookiecredits).'D'.$discuz_uid, 43200, 0);
  }
  if($creditsadd || $extrasql) {

   $db->query("UPDATE {$tablepre}members SET $creditsadd ".($creditsadd && $extrasql ? ', ' : '')." $extrasql WHERE uid IN ('$uids')", 'UNBUFFERED');
           /*bug修复 评分用户的更新积分*/
            $db->query("UPDATE {$tablepre}members SET $creditsdel ".($creditsdel && $extrasql ? ', ' : '')." $extrasql WHERE uid IN ('$discuz_uid')", 'UNBUFFERED'); 
    /**end bug**/
        }
 }
}

    文件templates/default/messages.lang.php  数组里$language 加一行代码

'ajax_thread_rate_jiaozi_invalid' => '对不起,您的交子数不足。',  //文字根据需要更改

本文出自 “凹凸曼” 博客,请务必保留此出处 http://www.apoyl.com/?p=801

Tag:

日志信息 »

该日志于2011-05-27 07:50由 凹凸曼 发表在问题集分类下, 评论已关闭。

目前盖楼

抱歉,评论被关闭

« »