China
|
本帖最后由 roxmake 于 2019-3-27 06:07 编辑
Find: the source/module/forum/forum_viewthread.php file
Search code:
- function viewthread_updateviews($tableid)
Copy the Code Find the code:
- 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']);
- }
Copy the Code Modify to:
- 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']);
- }
Copy the Code The main changes are:
1. Create random number variables:
Rand (2,10) represents a random number between 2 and 10;
2. Modify the original update methods:
Respectively is:
- 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);
Copy the Code
Modify to:
- 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);
Copy the Code Done!
|
|