[原创]同一ID可以在限制时间后再次投票[后台设置投票间隔,各版块独立]

上一篇 / 下一篇  2005-10-31 07:33:30

查看( 1588 ) / 评论( 25 )


QUOTE:
本来是应人而弄的
而rubbishman已经弄好一个了

但是既然写好了
留着也没用
发出来留念也不错

(此贴只是同一个问题的另外的一个解决方法而已).


QUOTE:
功能: 现在的投票是 一个ID只能投一票!而这个插件可以后台设置同一ID投票间隔(即同一ID可以再次投票),各版块独立
名称: 同一ID可以在限制时间后再次投票
作者: lu5266
版本: 2.5
升级: cdb_forums
文件: admin/forums.php  templates/default/admincp.lang.php   misc.php    viewthread.php  
第一步:升级数据库

ALTER TABLE `cdb_forums` ADD `limitime` INT( 10 ) DEFAULT '-1' NOT NULL AFTER `replycredits` ;
第二步:修改admin/forums.php

查找:

showsetting('forums_edit_replycredits', 'replycreditsnew', $forum['replycredits'], 'text');
在下面加上

                        showsetting('forums_edit_limitime', 'limitimenew', $forum['limitime'], 'text');
查找:

replycredits='".intval($replycreditsnew)."',
在后面加上:

limitime='".intval($limitimenew)."',
第三步:修改templates/default/admincp.lang.php

查找

'forums_edit_replycredits_comment' => '会员在本版回复所获得的积分,设置 -1 为按全论坛默认设定',
在下面加上

        'forums_edit_limitime' => '投票时间限制:(单位为:小时)',
        'forums_edit_limitime_comment' => '用同一个ID投票时间间隔,设置 -1 为无限期,即:同一个ID只能投票一次',
第四步:修改misc.php


查找:

        if(in_array($discuz_user, $pollarray['voters'])) {
                showmessage('thread_poll_voted');
        }
替换为:

//=======================同一ID可以在限制时间后再次投票  start  by lu5266=============
  $query = $db->query("SELECT limitime FROM $table_forums WHERE fid='$fid'");
  $poll_lim = $db->fetch_array($query);
  $limitime=$poll_lim['limitime'];
  foreach ($pollarray['voters'] as $key=> $value) {
     $value=explode(",",$value);
     if($discuz_user==$value[0])
     $polltime=$value[1];
     $pollanother['voters'][]=$value[0];
  }   
if(in_array($discuz_user, $pollanother['voters']) &&  ( $limitime == -1 || $mtime[1]-$polltime< $limitime*60*60 )) {
                  showmessage('thread_poll_voted');
        }
//=======================同一ID可以在限制时间后再次投票  end  by www.5466.ik8.com=========
查找:

$pollarray['voters'][] = $discuz_user;
替换为:

       
     /*-------------change by lu5266----------------*/
     if( in_array($discuz_user, $pollanother['voters']))
            $pollarray['voters'][] = $discuz_user.','.$timestamp.',1';
     else $pollarray['voters'][] = $discuz_user.','.$timestamp;
    /*-------------change by lu5266----------------*/
第五步:修改viewthread.php


查找:

$allowvote = $allowvote && $discuz_uid && (empty($thread['closed']) || $alloweditpoll) && !in_array($discuz_user, $pollopts['voters']);
替换为:

                 //=======================同一ID可以在限制时间后再次投票  start  by lu5266=============
                          $query = $db->query("SELECT limitime FROM $table_forums WHERE fid='$fid'");
              $poll_lim = $db->fetch_array($query);
              $limitime=$poll_lim['limitime'];              
              foreach ($pollopts['voters'] as $key=> $value) {
                $value=explode(",",$value);
               if($discuz_user==$value[0])
                 $polltime=$value[1];               
                if($value[2]==NULL)
                   $pollanother['voters'][]=$value[0];            
               }               
            $pollopts['voters']=$pollanother['voters'];
            if(in_array($discuz_user, $pollopts['voters']) && $limitime==-1)   $allowvote=0;
                        else   
            $allowvote = $allowvote && $discuz_uid && (empty($thread['closed']) || $alloweditpoll) && !(in_array($discuz_user, $pollopts['voters']) && ($mtime[1]-$polltime< $limitime*60*60));
//=======================同一ID可以在限制时间后再次投票  end  by www.5466.ik8.com=========
第六: 步更新缓存

完成!

[ 本帖最后由 lu5266 于 2005-10-31 07:54 编辑 ]

TAG:

我来说两句

(可选)

Open Toolbar