请选择 进入手机版 | 继续访问电脑版

Discuz!大师网

搜索
查看: 1091|回复: 0

Discuz!帖子刷新后阅读数增加随机值的方法

[复制链接]
发表于 2017-4-7 03:57:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
有些站长对于帖子阅读数增长缓慢的状况很不满足,希望能增加的快一些,本文就介绍一种阅读数增加随机值的方法!
找到:source/module/forum/forum_viewthread.php文件
搜索代码:
function viewthread_updateviews($tableid)

  1. function viewthread_updateviews($tableid){
  2.         global $_G;
  3.         if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {
  4.                 if(!$tableid && $_G['setting']['optimizeviews']) {
  5.                         if($_G['forum_thread']['addviews']) {
  6.                                 if($_G['forum_thread']['addviews'] < 100) {
  7.                                         C::t('forum_threadaddviews')->update_by_tid($_G['tid']);
  8.                                 } else {
  9.                                                 if(!discuz_process::islocked('update_thread_view')) {
  10.                                                         $row = C::t('forum_threadaddviews')->fetch($_G['tid']);
  11.                                                         C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0));
  12.                                                         C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+1), true);
  13.                                                         discuz_process::unlock('update_thread_view');
  14.                                                 }
  15.                                 }
  16.                         } else {
  17.                                 C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => 1), false, true);
  18.                         }
  19.                 } else {
  20.                         C::t('forum_thread')->increase($_G['tid'], array('views' => 1), true, $tableid);
  21.                 }
  22.         }
  23.         dsetcookie('viewid', 'tid_'.$_G['tid']);
  24. }
复制代码


修改为
  1. function viewthread_updateviews($tableid) {
  2.         global $_G;
  3.         $randnum = rand(2,10);
  4.         if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {
  5.                 if(!$tableid && $_G['setting']['optimizeviews']) {
  6.                                 if($_G['forum_thread']['addviews']) {
  7.                                         if($_G['forum_thread']['addviews'] < 100) {
  8.                                                 C::t('forum_threadaddviews')->update_by_tid($_G['tid']);
  9.                                         } else {
  10.                                                 if(!discuz_process::islocked('update_thread_view')) {
  11.                                                         $row = C::t('forum_threadaddviews')->fetch($_G['tid']);
  12.                                                         C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => $randnum));
  13.                                                         C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+$randnum), true);
  14.                                                         discuz_process::unlock('update_thread_view');
  15.                                                 }
  16.                                         }
  17.                                 }else {
  18.                                         C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => $randnum), false, true);
  19.                                 }
  20.                 } else {
  21.                                 C::t('forum_thread')->increase($_G['tid'], array('views' => $randnum), true, $tableid);
  22.                 }
  23.         }
  24.         dsetcookie('viewid', 'tid_'.$_G['tid']);
  25. }
复制代码
修改总结
这里$randnum = rand(2,10); 表示每次增加2到10个随机值,可以自行再修改;


回复 马甲回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|网站地图|小黑屋|展会网|Discuz站长论坛 |天天打卡

GMT+8, 2024-3-29 02:09 , Processed in 0.023409 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表