From ec0f60ac8b0144f0fc90375912e5fd0f01b9a8e6 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Fri, 16 Oct 2026 21:57:46 -0700 Subject: [PATCH] Log index, board and topic views again Moving the logging block below the maintenance/KickGuest chain in smf_main() meant requests with no action (BoardIndex, MessageIndex, Display) returned before writeLog() and trackStats() were reached. Members, guests and bots browsing the index, boards and topics were no longer shown in Who's Online, last-active was not updated for them, and hit stats were undercounted. Run the logging block after the maintenance and KickGuest checks, so kicked guests are still not logged, but before the default-action branch. Both earlier branches return on every path, so the `elseif (empty($_REQUEST['action']))` becomes a plain `if`. $no_stat_actions and the integrate_pre_log_stats hook stay where they were. Follow-up to #9215. Reported at https://www.simplemachines.org/community/index.php?topic=595172.0 Co-authored-by: Claude --- index.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index 2dad182a086..3e9092e7be5 100644 --- a/index.php +++ b/index.php @@ -283,7 +283,20 @@ function smf_main() // If guest access is off, a guest can only do one of the very few following actions. elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) return 'KickGuest'; - elseif (empty($_REQUEST['action'])) + + $should_log = !is_filtered_request($no_stat_actions, 'action'); + if ($should_log) + { + // Log this user as online. + writeLog(); + + // Track forum statistics and hits...? + if (!empty($modSettings['hitStats'])) + trackStats(array('hits' => '+')); + } + unset($no_stat_actions); + + if (empty($_REQUEST['action'])) { // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. if (empty($board) && empty($topic)) @@ -325,18 +338,6 @@ function smf_main() } } - $should_log = !is_filtered_request($no_stat_actions, 'action'); - if ($should_log) - { - // Log this user as online. - writeLog(); - - // Track forum statistics and hits...? - if (!empty($modSettings['hitStats'])) - trackStats(array('hits' => '+')); - } - unset($no_stat_actions); - // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function). $actionArray = array( 'agreement' => array('Agreement.php', 'Agreement'),