On the homepage, for each forum. I want to display how many guests and how many registered users are visiting that forum or any topic inside that forum.
Here is the code:
in
Code: Select all
/includes/functions_display.php
Code: Select all
$sql_registered_online = "SELECT COUNT(DISTINCT s.session_user_id) AS num_users
FROM phpbb3_sessions s, phpbb3_sessions_keys k
WHERE s.session_user_id <> 0
AND s.session_time >= " . (time() - 300) . "
AND s.session_forum_id = $forum_id";
$result_registered_online = $db->sql_query($sql_registered_online);
$row_registered_online = $db->sql_fetchrow($result_registered_online);
$db->sql_freeresult($result_registered_online);
$sql_guests_online = "SELECT COUNT(*) AS num_guests
FROM phpbb3_sessions
WHERE session_user_id = 0
AND session_time >= " . (time() - 300) . "
AND session_forum_id = " . $forum_id;
$result_guests_online = $db->sql_query($sql_guests_online);
$row_guests_online = $db->sql_fetchrow($result_guests_online);
$db->sql_freeresult($result_guests_online);
$registered_online = $row_registered_online['num_users'];
$guests_online = $row_guests_online['num_guests'];
$users_online = $guests_online + $registered_online;
Code: Select all
'GUESTS_ONLINE' => $guests_online,
'REGISTERED_ONLINE' => $registered_online,
'USERS_ONLINE' => $users_online,
Code: Select all
/styles/prosilver/template/forumlist_body.html
Code: Select all
<!-- IF forumrow.USERS_ONLINE > 0 -->
<br/>
<b>{forumrow.USERS_ONLINE} user online:</b> <!-- ENDIF --><!-- IF forumrow.GUESTS_ONLINE > 0 --><b style="color:green;">{forumrow.GUESTS_ONLINE} ospit<!-- IF forumrow.GUESTS_ONLINE == 1 -->e<!-- ENDIF --><!-- IF forumrow.GUESTS_ONLINE > 1 -->i<!-- ENDIF --></b> <!-- ENDIF --><!-- IF forumrow.REGISTERED_ONLINE > 0 && forumrow.GUESTS_ONLINE > 0 --><b>e</b> <!-- ENDIF --><!-- IF forumrow.REGISTERED_ONLINE > 0 --><b style="color:#b7720b;">{forumrow.REGISTERED_ONLINE} utent<!-- IF forumrow.REGISTERED_ONLINE == 1 -->e<!-- ENDIF --><!-- IF forumrow.REGISTERED_ONLINE > 1 -->i<!-- ENDIF --></b><!-- ENDIF -->