From 2b94b8790a929f74c775b8585eb5e2f70eaa2602 Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Sun, 15 Mar 2026 13:07:53 -0700 Subject: [PATCH 1/2] Add option to disable logging of guests/bots in log_online Signed-off-by: Shawn Bulen --- Languages/en_US/Help.php | 1 + Languages/en_US/ManageSettings.php | 1 + Sources/Actions/Admin/Features.php | 1 + Sources/User.php | 4 ++++ Themes/default/BoardIndex.template.php | 2 +- 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Languages/en_US/Help.php b/Languages/en_US/Help.php index 1b7993fcbd..a410cc31b2 100644 --- a/Languages/en_US/Help.php +++ b/Languages/en_US/Help.php @@ -437,6 +437,7 @@ // argument(s): scripturl $helptxt['who_enabled'] = 'This setting allows you to turn on or off the Who’s Online page, which shows who is browsing the forum and what they are doing.'; +$helptxt['no_guest_logging'] = 'This setting prevents guests from being included in the Users Online counts. Guest and bot activity can cause excessive IO, so this may help during a bot attack.'; $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.'; $helptxt['recycle_enable'] = '"Recycles" deleted topics and posts to the specified board.'; diff --git a/Languages/en_US/ManageSettings.php b/Languages/en_US/ManageSettings.php index 2ae9c82f78..77b45c5e03 100644 --- a/Languages/en_US/ManageSettings.php +++ b/Languages/en_US/ManageSettings.php @@ -109,6 +109,7 @@ $txt['timeLoadPageEnable'] = 'Display time taken to create every page'; $txt['disableHostnameLookup'] = 'Disable hostname lookups'; $txt['who_enabled'] = 'Enable who’s online list'; +$txt['no_guest_logging'] = 'Do not include guests or bots in Users Online stats'; $txt['no_guest_views'] = 'Disable counting views for guests and bots'; $txt['settings_error'] = 'Warning: Updating of Settings.php failed, the settings cannot be saved.'; $txt['image_proxy_enabled'] = 'Enable Image Proxy'; diff --git a/Sources/Actions/Admin/Features.php b/Sources/Actions/Admin/Features.php index cd0023c4a7..bebec8e2b5 100644 --- a/Sources/Actions/Admin/Features.php +++ b/Sources/Actions/Admin/Features.php @@ -1651,6 +1651,7 @@ public static function basicConfigVars(): array '', // Guest stats. + ['check', 'no_guest_logging'], ['check', 'no_guest_views'], '', diff --git a/Sources/User.php b/Sources/User.php index b748d936c3..e108f1fa33 100644 --- a/Sources/User.php +++ b/Sources/User.php @@ -1204,6 +1204,10 @@ public function logOnline(bool $force = false): void self::logSpider(); } + // Don't log guests anymore - helps during bot attacks. + if (!empty(Config::$modSettings['no_guest_logging']) && !empty(User::$me->is_guest)) + return; + // Don't mark them as online more than every so often. if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { return; diff --git a/Themes/default/BoardIndex.template.php b/Themes/default/BoardIndex.template.php index ee42a66088..695bd0fe4a 100644 --- a/Themes/default/BoardIndex.template.php +++ b/Themes/default/BoardIndex.template.php @@ -499,7 +499,7 @@ function template_ic_block_online()

- ', Utils::$context['show_who'] ? '' : '', '', Lang::getTxt('online', file: 'General'), ': ', Lang::getTxt('number_of_guests', [Utils::$context['num_guests']], file: 'General'), ', ', Lang::getTxt('number_of_members', [Utils::$context['num_users_online']], file: 'General'); + ', Utils::$context['show_who'] ? '' : '', '', Lang::getTxt('online', file: 'General'), ': ', empty(Config::$modSettings['no_guest_logging']) ? Lang::getTxt('number_of_guests', [Utils::$context['num_guests']], file: 'General') . ', ' : '', Lang::getTxt('number_of_members', [Utils::$context['num_users_online']], file: 'General'); // Handle hidden users and buddies. $bracketList = []; From 66a20ec25e1ea819afa0a6639edaedd52c3b88c2 Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Sun, 15 Mar 2026 13:12:34 -0700 Subject: [PATCH 2/2] Add option to disable logging of guests/bots in log_online Signed-off-by: Shawn Bulen --- Sources/User.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/User.php b/Sources/User.php index e108f1fa33..92e1ab6e8b 100644 --- a/Sources/User.php +++ b/Sources/User.php @@ -1205,8 +1205,9 @@ public function logOnline(bool $force = false): void } // Don't log guests anymore - helps during bot attacks. - if (!empty(Config::$modSettings['no_guest_logging']) && !empty(User::$me->is_guest)) + if (!empty(Config::$modSettings['no_guest_logging']) && !empty(User::$me->is_guest)) { return; + } // Don't mark them as online more than every so often. if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {