|
发表于 2017-11-15 11:49:18
|
显示全部楼层
|阅读模式
来自 中国–河南–新乡
有些站长对于帖子阅读数增长缓慢的状况很不满足,希望能增加的快一些,本文就介绍一种阅读数增加随机值的方法!
找到: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;
- $randnum = 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' => $randnum));
- C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+$randnum), true);
- discuz_process::unlock('update_thread_view');
- }
- }
- }else {
- C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => $randnum), false, true);
- }
- } else {
- C::t('forum_thread')->increase($_G['tid'], array('views' => $randnum), true, $tableid);
- }
- }
- dsetcookie('viewid', 'tid_'.$_G['tid']);
复制代码 修改总结
这里$randnum = rand(2,10); 标示每次增加2到10个随机值,可以自行再修改;
|
|