Skip to content

Commit 05f4aa8

Browse files
authored
Merge pull request #9128 from sbulen/21_bot_views
[2.1] Bots - reduce topic view updates
2 parents cbe74ca + 5abed91 commit 05f4aa8

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

Sources/Display.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,14 @@ function Display()
126126
$_REQUEST['start'] = 'new';
127127
}
128128

129-
// Add 1 to the number of views of this topic (except for robots).
130-
if (!$user_info['possibly_robot'] && (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic))
129+
// Add 1 to the number of views of this topic (except for guests/bots, per setting).
130+
// no_guest_views is stricter, & won't log bots or guests.
131+
if (empty($modSettings['no_guest_views']))
132+
$check = !$user_info['possibly_robot'];
133+
else
134+
$check = !$user_info['is_guest'];
135+
136+
if ($check && (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $topic))
131137
{
132138
$smcFunc['db_query']('', '
133139
UPDATE {db_prefix}topics

Sources/ManageSettings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ function ModifyBasicSettings($return_config = false)
219219
array('check', 'hitStats'),
220220
'',
221221

222+
// Guest stats.
223+
array('check', 'no_guest_views'),
224+
'',
225+
222226
// Option-ish things... miscellaneous sorta.
223227
array('check', 'disallow_sendBody'),
224228
'',

Themes/default/languages/Help.english.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@
421421
// argument(s): scripturl
422422
$helptxt['who_enabled'] = 'This setting allows you to turn on or off the <a href="%1$s?action=who" target="_blank" rel="noopener">Who\'s Online</a> page, which shows who is browsing the forum and what they are doing.';
423423

424+
$helptxt['no_guest_views'] = 'This setting disables incrementing views for guests as well as bots. Bot activity can cause excessive IO, and is often disguised as guest activity, so this may help during a bot attack.';
425+
424426
$helptxt['recycle_enable'] = '&quot;Recycles&quot; deleted topics and posts to the specified board.';
425427

426428
$helptxt['enableReportPM'] = 'This setting allows your users to report personal messages they receive to the administration team. This may be useful in helping to track down any abuse of the personal messaging system.';

Themes/default/languages/ManageSettings.english.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
$txt['timeLoadPageEnable'] = 'Display time taken to create every page';
104104
$txt['disableHostnameLookup'] = 'Disable hostname lookups';
105105
$txt['who_enabled'] = 'Enable who\'s online list';
106+
$txt['no_guest_views'] = 'Disable counting views for guests and bots';
106107
$txt['meta_keywords'] = 'Meta keywords associated with forum';
107108
$txt['meta_keywords_note'] = 'For search engines. Leave blank for default.';
108109
$txt['settings_error'] = 'Warning: Updating of Settings.php failed, the settings cannot be saved.';

0 commit comments

Comments
 (0)