欢迎光临
我们一直在努力

论坛人气弱?Discuz帖子刷新后阅读数进行随机值增加方法

建站超值云服务器,限时71元/月

$viewrand = rand(2,10);

,

       C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $row[‘addviews’]+
1), true);

  C::t(‘forum_threadaddviews’)->insert(array(‘tid’ => $_G[‘tid’], ‘addviews’ => 
1), false, true);

  C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => 
1), true, $tableid);

,

       C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $row[‘addviews’]+$viewrand), true);

  C::t(‘forum_threadaddviews’)->insert(array(‘tid’ => $_G[‘tid’], ‘addviews’ => $viewrand), false, true);

  C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $viewrand), true, $tableid);

,论坛人气弱?想改阅读数的站长可以围观!

找到:source/module/forum/forum_viewthread.php文件

搜索代码:

function viewthread_updateviews($tableid)


找到代码:

function viewthread_updateviews($tableid) {

        global $_G;



        if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {

                if(!$tableid && $_G['setting']['optimizeviews']) {

                        if($_G['forum_thread']['addviews']) {

                                if($_G['forum_thread']['addviews'] < 100) {

                                        C::t('forum_threadaddviews')->update_by_tid($_G['tid']);

                                } else {

                                        if(!discuz_process::islocked('update_thread_view')) {

                                                $row = C::t('forum_threadaddviews')->fetch($_G['tid']);

                                                C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0));

                                                C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+1), true);

                                                discuz_process::unlock('update_thread_view');

                                        }

                                }

                        } else {

                                C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => 1), false, true);

                        }

                } else {

                        C::t('forum_thread')->increase($_G['tid'], array('views' => 1), true, $tableid);

                }

        }

        dsetcookie('viewid', 'tid_'.$_G['tid']);

}


修改为:

function viewthread_updateviews($tableid) {

        global $_G;


        $viewrand = rand(2,10); 


        if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {
                
                if(!$tableid && $_G['setting']['optimizeviews']) {

                        if($_G['forum_thread']['addviews']) {

                                if($_G['forum_thread']['addviews'] < 100) {

                                        C::t('forum_threadaddviews')->update_by_tid($_G['tid']);

                                } else {

                                        if(!discuz_process::islocked('update_thread_view')) {

                                                $row = C::t('forum_threadaddviews')->fetch($_G['tid']);

                                                C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => $viewrand));

                                                C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+$viewrand), true);

                                                discuz_process::unlock('update_thread_view');

                                        }

                                }

                        } else {

                                C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => $viewrand), false, true);

                        }

                } else {

                        C::t('forum_thread')->increase($_G['tid'], array('views' => $viewrand), true, $tableid);

                }

        }

        dsetcookie('viewid', 'tid_'.$_G['tid']);

}


主要修改的是:

1.创建随机数变量:

$viewrand = rand(2,10);


rand(2,10)表示的2-10之间的随机数;

2.修改原有的几个更新方法:

分别是:

       C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $row[‘addviews’]+
1), true);

  C::t(‘forum_threadaddviews’)->insert(array(‘tid’ => $_G[‘tid’], ‘addviews’ => 
1), false, true);

  C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => 
1), true, $tableid);


改为:

       C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $row[‘addviews’]+$viewrand), true);

  C::t(‘forum_threadaddviews’)->insert(array(‘tid’ => $_G[‘tid’], ‘addviews’ => $viewrand), false, true);

  C::t(‘forum_thread’)->increase($_G[‘tid’], array(‘views’ => $viewrand), true, $tableid);

就好了!

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 论坛人气弱?Discuz帖子刷新后阅读数进行随机值增加方法
分享到: 更多 (0)