mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
change viewonline page slightly.
Mental Note: Step away from using in_array in conjunction with huge arrays (and within a loop), might get slow. ;) git-svn-id: file:///svn/phpbb/trunk@5091 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
9841f6145c
commit
4269b318a2
7 changed files with 231 additions and 167 deletions
|
@ -95,6 +95,7 @@ $display_vars = array(
|
||||||
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_online' => array('lang' => 'YES_ONLINE', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_online' => array('lang' => 'YES_ONLINE', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
|
'load_online_guests'=> array('lang' => 'YES_ONLINE_GUESTS', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'type' => 'text:4:3', 'explain' => true),
|
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'type' => 'text:4:3', 'explain' => true),
|
||||||
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'type' => 'radio:yes_no', 'explain' => false),
|
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'type' => 'radio:yes_no', 'explain' => false),
|
||||||
|
@ -331,7 +332,7 @@ if ($mode == 'auth')
|
||||||
if ($config_fields = $method($new))
|
if ($config_fields = $method($new))
|
||||||
{
|
{
|
||||||
// Check if we need to create config fields for this plugin
|
// Check if we need to create config fields for this plugin
|
||||||
foreach($config_fields as $field)
|
foreach ($config_fields as $field)
|
||||||
{
|
{
|
||||||
if (!isset($config[$field]))
|
if (!isset($config[$field]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -334,7 +334,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list
|
||||||
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
|
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id
|
||||||
FROM ' . FORUMS_TABLE . '
|
FROM ' . FORUMS_TABLE . '
|
||||||
ORDER BY left_id ASC';
|
ORDER BY left_id ASC';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql, 600);
|
||||||
|
|
||||||
$right = $padding = 0;
|
$right = $padding = 0;
|
||||||
$padding_store = array('0' => 0);
|
$padding_store = array('0' => 0);
|
||||||
|
@ -1529,25 +1529,38 @@ function page_header($page_title = '')
|
||||||
{
|
{
|
||||||
$userlist_ary = $userlist_visible = array();
|
$userlist_ary = $userlist_visible = array();
|
||||||
$logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0;
|
$logged_visible_online = $logged_hidden_online = $guests_online = $prev_user_id = 0;
|
||||||
$prev_user_ip = $prev_session_ip = $reading_sql = '';
|
$prev_session_ip = $reading_sql = '';
|
||||||
|
|
||||||
if (!empty($_REQUEST['f']))
|
if (!empty($_REQUEST['f']))
|
||||||
{
|
{
|
||||||
$f = request_var('f', 0);
|
$f = request_var('f', 0);
|
||||||
$reading_sql = "AND s.session_page LIKE '%f=$f%'";
|
$reading_sql = " AND s.session_page LIKE '%f=$f%'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get number of online guests
|
||||||
|
if (!$config['load_online_guests'])
|
||||||
|
{
|
||||||
|
$sql = 'SELECT COUNT(DISTINCT s.session_ip) as num_guests FROM ' . SESSIONS_TABLE . ' s
|
||||||
|
WHERE s.session_user_id = ' . ANONYMOUS . '
|
||||||
|
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
|
||||||
|
$reading_sql;
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$guests_online = (int) $db->sql_fetchfield('num_guests', 0, $result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT u.username, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_viewonline
|
$sql = 'SELECT u.username, u.user_id, u.user_type, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_viewonline
|
||||||
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
|
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
|
||||||
WHERE s.session_time >= ' . (time() - (intval($config['load_online_time']) * 60)) . "
|
WHERE s.session_time >= ' . (time() - (intval($config['load_online_time']) * 60)) .
|
||||||
$reading_sql
|
$reading_sql .
|
||||||
AND u.user_id = s.session_user_id
|
((!$config['load_online_guests']) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . '
|
||||||
ORDER BY u.username ASC, s.session_ip ASC";
|
AND u.user_id = s.session_user_id
|
||||||
|
ORDER BY u.username ASC, s.session_ip ASC';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
// User is logged in and therefor not a guest
|
// User is logged in and therefore not a guest
|
||||||
if ($row['user_id'] != ANONYMOUS)
|
if ($row['user_id'] != ANONYMOUS)
|
||||||
{
|
{
|
||||||
// Skip multiple sessions for one user
|
// Skip multiple sessions for one user
|
||||||
|
|
|
@ -70,6 +70,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_load', '0');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1');
|
||||||
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_guests', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1');
|
||||||
|
|
|
@ -730,6 +730,8 @@ $lang += array(
|
||||||
'ONLINE_LENGTH_EXPLAIN' => 'Time in minutes after which inactive users will not appear in viewonline listings, lower equals less processing.',
|
'ONLINE_LENGTH_EXPLAIN' => 'Time in minutes after which inactive users will not appear in viewonline listings, lower equals less processing.',
|
||||||
'YES_ONLINE' => 'Enable online user listings',
|
'YES_ONLINE' => 'Enable online user listings',
|
||||||
'YES_ONLINE_EXPLAIN' => 'Display online user information on index, forum and topic pages.',
|
'YES_ONLINE_EXPLAIN' => 'Display online user information on index, forum and topic pages.',
|
||||||
|
'YES_ONLINE_GUESTS' => 'Enable online guest listings in viewonline',
|
||||||
|
'YES_ONLINE_GUESTS_EXPLAIN' => 'Allow display of guest user informations in viewonline.',
|
||||||
'YES_ONLINE_TRACK' => 'Enable display of user online img',
|
'YES_ONLINE_TRACK' => 'Enable display of user online img',
|
||||||
'YES_ONLINE_TRACK_EXPLAIN' => 'Display online information for user in profiles and viewtopic.',
|
'YES_ONLINE_TRACK_EXPLAIN' => 'Display online information for user in profiles and viewtopic.',
|
||||||
'YES_BIRTHDAYS' => 'Enable birthday listing',
|
'YES_BIRTHDAYS' => 'Enable birthday listing',
|
||||||
|
|
|
@ -92,6 +92,7 @@ $lang += array(
|
||||||
'DELETE_MARKED' => 'Delete Marked',
|
'DELETE_MARKED' => 'Delete Marked',
|
||||||
'DESCENDING' => 'Descending',
|
'DESCENDING' => 'Descending',
|
||||||
'DISABLED' => 'Disabled',
|
'DISABLED' => 'Disabled',
|
||||||
|
'DISPLAY_GUESTS' => 'Display Guests',
|
||||||
'DISPLAY_MESSAGES' => 'Display messages from previous',
|
'DISPLAY_MESSAGES' => 'Display messages from previous',
|
||||||
'DISPLAY_POSTS' => 'Display posts from previous',
|
'DISPLAY_POSTS' => 'Display posts from previous',
|
||||||
'DISPLAY_TOPICS' => 'Display topics from previous',
|
'DISPLAY_TOPICS' => 'Display topics from previous',
|
||||||
|
@ -151,6 +152,7 @@ $lang += array(
|
||||||
'HIDDEN_USERS_ZERO_TOTAL' => '0 Hidden and ',
|
'HIDDEN_USERS_ZERO_TOTAL' => '0 Hidden and ',
|
||||||
'HIDDEN_USER_ONLINE' => '%d Hidden user online',
|
'HIDDEN_USER_ONLINE' => '%d Hidden user online',
|
||||||
'HIDDEN_USER_TOTAL' => '%d Hidden and ',
|
'HIDDEN_USER_TOTAL' => '%d Hidden and ',
|
||||||
|
'HIDE_GUESTS' => 'Hide Guests',
|
||||||
'HIDE_ME' => 'Hide my online status this session',
|
'HIDE_ME' => 'Hide my online status this session',
|
||||||
'HOURS' => 'Hours',
|
'HOURS' => 'Hours',
|
||||||
|
|
||||||
|
@ -404,6 +406,7 @@ $lang += array(
|
||||||
'VIEWING_FAQ' => 'Viewing FAQ',
|
'VIEWING_FAQ' => 'Viewing FAQ',
|
||||||
'VIEWING_MEMBERS' => 'Viewing member details',
|
'VIEWING_MEMBERS' => 'Viewing member details',
|
||||||
'VIEWING_ONLINE' => 'Viewing who is online',
|
'VIEWING_ONLINE' => 'Viewing who is online',
|
||||||
|
'VIEWING_UCP' => 'Viewing user control panel',
|
||||||
'VIEWS' => 'Views',
|
'VIEWS' => 'Views',
|
||||||
'VIEW_BOOKMARKS' => 'View bookmarks',
|
'VIEW_BOOKMARKS' => 'View bookmarks',
|
||||||
'VIEW_LATEST_POST' => 'View latest post',
|
'VIEW_LATEST_POST' => 'View latest post',
|
||||||
|
|
|
@ -2,39 +2,48 @@
|
||||||
|
|
||||||
<!-- $Id$ -->
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<h4>{TOTAL_REGISTERED_USERS_ONLINE}</h4>
|
||||||
|
<h4>{TOTAL_GUEST_USERS_ONLINE}<!-- IF S_SWITCH_GUEST_DISPLAY --> [ <a href="{U_SWITCH_GUEST_DISPLAY}">{L_SWITCH_GUEST_DISPLAY}</a> ]<!-- ENDIF --></h4>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<!-- IF PAGINATION -->
|
||||||
|
<table width="100%" cellspacing="1">
|
||||||
|
<tr>
|
||||||
|
<td class="nav" valign="middle" nowrap="nowrap"> {PAGE_NUMBER}<br /></td>
|
||||||
|
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a> <!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> <a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<table class="tablebg" width="100%" cellspacing="1">
|
<table class="tablebg" width="100%" cellspacing="1">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="40%"><a class="th" href="{U_SORT_USERNAME}">{L_USERNAME}</a></th>
|
<th width="40%"><a class="th" href="{U_SORT_USERNAME}">{L_USERNAME}</a></th>
|
||||||
<th width="20%"><a class="th" href="{U_SORT_UPDATED}">{L_LAST_UPDATED}</a></th>
|
<th width="20%"><a class="th" href="{U_SORT_UPDATED}">{L_LAST_UPDATED}</a></th>
|
||||||
<th width="40%"><a class="th" href="{U_SORT_LOCATION}">{L_FORUM_LOCATION}</a></th>
|
<th width="40%"><a class="th" href="{U_SORT_LOCATION}">{L_FORUM_LOCATION}</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<!-- BEGIN user_row -->
|
||||||
<td class="cat" colspan="3"><h4>{TOTAL_REGISTERED_USERS_ONLINE}</h4></td>
|
|
||||||
</tr>
|
|
||||||
<!-- BEGIN reg_user_row -->
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1"><p class="gen"><!-- IF reg_user_row.U_USER_PROFILE --><a href="{reg_user_row.U_USER_PROFILE}"><!-- ENDIF -->{reg_user_row.USERNAME}<!-- IF reg_user_row.U_USER_PROFILE --></a><!-- ENDIF --></p><!-- IF reg_user_row.USER_IP --><p class="gensmall">{L_IP}: <a href="{reg_user_row.U_USER_IP}">{reg_user_row.USER_IP}</a> » <a href="{reg_user_row.U_WHOIS}" onclick="popup('{reg_user_row.U_WHOIS}', 750, 500);return false">{L_WHOIS}</a></p><!-- ENDIF --></td>
|
<td class="row1"><p class="gen"><!-- IF user_row.U_USER_PROFILE --><a href="{user_row.U_USER_PROFILE}"><!-- ENDIF -->{user_row.USERNAME}<!-- IF user_row.U_USER_PROFILE --></a><!-- ENDIF --></p><!-- IF user_row.USER_IP --><p class="gensmall">{L_IP}: <a href="{user_row.U_USER_IP}">{user_row.USER_IP}</a> » <a href="{user_row.U_WHOIS}" onclick="popup('{user_row.U_WHOIS}', 750, 500);return false">{L_WHOIS}</a></p><!-- ENDIF --></td>
|
||||||
<td class="row2" align="center" nowrap="nowrap"><p class="genmed"> {reg_user_row.LASTUPDATE}</p></td>
|
<td class="row2" align="center" nowrap="nowrap"><p class="genmed"> {user_row.LASTUPDATE}</p></td>
|
||||||
<td class="row1"><p class="genmed"><a href="{reg_user_row.U_FORUM_LOCATION}">{reg_user_row.FORUM_LOCATION}</a></p></td>
|
<td class="row1"><p class="genmed"><a href="{user_row.U_FORUM_LOCATION}">{user_row.FORUM_LOCATION}</a></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END reg_user_row -->
|
<!-- END user_row -->
|
||||||
<!-- IF LEGEND -->
|
<!-- IF LEGEND -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1" colspan="3"><b class="gensmall">{L_LEGEND} :: {LEGEND}</b></td>
|
<td class="row1" colspan="3"><b class="gensmall">{L_LEGEND} :: {LEGEND}</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<tr>
|
|
||||||
<td class="cat" colspan="3"><h4>{TOTAL_GUEST_USERS_ONLINE}</h4></td>
|
|
||||||
</tr>
|
|
||||||
<!-- BEGIN guest_user_row -->
|
|
||||||
<tr>
|
|
||||||
<td class="row1"><p class="gen">{guest_user_row.USERNAME}</p><!-- IF guest_user_row.USER_IP --><p class="gensmall">{L_IP}: <a href="{guest_user_row.U_USER_IP}">{guest_user_row.USER_IP}</a> » <a href="{guest_user_row.U_WHOIS}" onclick="popup('{guest_user_row.U_WHOIS}', 750, 500);return false">{L_WHOIS}</a></p><!-- ENDIF --></td>
|
|
||||||
<td class="row2" align="center" nowrap="nowrap"><p class="genmed">{guest_user_row.LASTUPDATE}</p></td>
|
|
||||||
<td class="row1"><p class="genmed"><a href="{guest_user_row.U_FORUM_LOCATION}">{guest_user_row.FORUM_LOCATION}</a></p></td>
|
|
||||||
</tr>
|
|
||||||
<!-- END guest_user_row -->
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<!-- IF PAGINATION -->
|
||||||
|
<table width="100%" cellspacing="1">
|
||||||
|
<tr>
|
||||||
|
<td class="nav" valign="middle" nowrap="nowrap"> {PAGE_NUMBER}<br /></td>
|
||||||
|
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a> <!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> <a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<div class="gensmall" align="right">{L_ONLINE_EXPLAIN}</div>
|
<div class="gensmall" align="right">{L_ONLINE_EXPLAIN}</div>
|
||||||
|
|
||||||
<br clear="all" />
|
<br clear="all" />
|
||||||
|
|
|
@ -27,9 +27,10 @@ $session_id = request_var('s', '');
|
||||||
$start = request_var('start', 0);
|
$start = request_var('start', 0);
|
||||||
$sort_key = request_var('sk', 'b');
|
$sort_key = request_var('sk', 'b');
|
||||||
$sort_dir = request_var('sd', 'd');
|
$sort_dir = request_var('sd', 'd');
|
||||||
|
$show_guests= ($config['load_online_guests']) ? request_var('sg', 0) : 0;
|
||||||
|
|
||||||
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED']);
|
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED']);
|
||||||
$sort_key_sql = array('a' => 'username', 'b' => 'session_time', 'c' => 'session_page');
|
$sort_key_sql = array('a' => 'u.username', 'b' => 's.session_time', 'c' => 's.session_page');
|
||||||
|
|
||||||
// Sorting and order
|
// Sorting and order
|
||||||
$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
|
$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
|
||||||
|
@ -37,12 +38,12 @@ $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC
|
||||||
// Whois requested
|
// Whois requested
|
||||||
if ($mode == 'whois')
|
if ($mode == 'whois')
|
||||||
{
|
{
|
||||||
include($phpbb_root_path.'includes/functions_user.'.$phpEx);
|
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||||
|
|
||||||
$sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip
|
$sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip
|
||||||
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s
|
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s
|
||||||
WHERE s.session_id = '$session_id'
|
WHERE s.session_id = '" . $db->sql_escape($session_id) . "'
|
||||||
AND u.user_id = s.session_user_id";
|
AND u.user_id = s.session_user_id";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
if ($row = $db->sql_fetchrow($result))
|
if ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -81,28 +82,40 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$guest_counter = 0;
|
||||||
|
|
||||||
|
// Get number of online guests (if we do not display them)
|
||||||
|
if (!$show_guests)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests FROM ' . SESSIONS_TABLE . '
|
||||||
|
WHERE session_user_id = ' . ANONYMOUS . '
|
||||||
|
AND session_time >= ' . (time() - ($config['load_online_time'] * 60));
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
$guest_counter = (int) $db->sql_fetchfield('num_guests', 0, $result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
// Get user list
|
// Get user list
|
||||||
$sql = 'SELECT u.user_id, u.username, u.user_type, u.user_allow_viewonline, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_viewonline
|
$sql = 'SELECT u.user_id, u.username, u.user_type, u.user_allow_viewonline, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_viewonline
|
||||||
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
|
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
|
||||||
WHERE u.user_id = s.session_user_id
|
WHERE u.user_id = s.session_user_id
|
||||||
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . '
|
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
|
||||||
|
((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . '
|
||||||
ORDER BY ' . $order_by;
|
ORDER BY ' . $order_by;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$prev_ip = $prev_id = array();
|
$prev_id = $prev_ip = $user_list = array();
|
||||||
$logged_visible_online = $logged_hidden_online = $guests_online = $reg_counter = $guest_counter = 0;
|
$logged_visible_online = $logged_hidden_online = $counter = 0;
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$view_online = false;
|
if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']]))
|
||||||
|
|
||||||
if ($row['user_id'] != ANONYMOUS && !in_array($row['user_id'], $prev_id))
|
|
||||||
{
|
{
|
||||||
$username = $row['username'];
|
$view_online = false;
|
||||||
|
|
||||||
if ($row['user_colour'])
|
if ($row['user_colour'])
|
||||||
{
|
{
|
||||||
$username = '<b style="color:#' . $row['user_colour'] . '">' . $username . '</b>';
|
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$row['user_allow_viewonline'] || !$row['session_viewonline'])
|
if (!$row['user_allow_viewonline'] || !$row['session_viewonline'])
|
||||||
|
@ -110,7 +123,7 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
$view_online = ($auth->acl_get('u_viewonline')) ? true : false;
|
$view_online = ($auth->acl_get('u_viewonline')) ? true : false;
|
||||||
$logged_hidden_online++;
|
$logged_hidden_online++;
|
||||||
|
|
||||||
$username = '<i>' . $username . '</i>';
|
$row['username'] = '<i>' . $row['username'] . '</i>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -118,131 +131,145 @@ while ($row = $db->sql_fetchrow($result))
|
||||||
$logged_visible_online++;
|
$logged_visible_online++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$which_counter = 'reg_counter';
|
$prev_id[$row['user_id']] = 1;
|
||||||
$which_row = 'reg_user_row';
|
|
||||||
$prev_id[] = $row['user_id'];
|
|
||||||
}
|
|
||||||
else if (!in_array($row['session_ip'], $prev_ip))
|
|
||||||
{
|
|
||||||
$username = $user->lang['GUEST'];
|
|
||||||
$view_online = true;
|
|
||||||
$guests_online++;
|
|
||||||
|
|
||||||
$which_counter = 'guest_counter';
|
if ($view_online)
|
||||||
$which_row = 'guest_user_row';
|
|
||||||
}
|
|
||||||
|
|
||||||
$prev_ip[] = $row['session_ip'];
|
|
||||||
|
|
||||||
if ($view_online)
|
|
||||||
{
|
|
||||||
preg_match('#^([a-z]+)#i', $row['session_page'], $on_page);
|
|
||||||
|
|
||||||
switch ($on_page[1])
|
|
||||||
{
|
{
|
||||||
case 'index':
|
$counter++;
|
||||||
$location = $user->lang['INDEX'];
|
|
||||||
$location_url = "index.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'posting':
|
|
||||||
case 'viewforum':
|
|
||||||
case 'viewtopic':
|
|
||||||
preg_match('#f=([0-9]+)#', $row['session_page'], $forum_id);
|
|
||||||
$forum_id = $forum_id[1];
|
|
||||||
|
|
||||||
if ($auth->acl_get('f_list', $forum_id))
|
|
||||||
{
|
|
||||||
$location = '';
|
|
||||||
switch ($on_page[1])
|
|
||||||
{
|
|
||||||
case 'posting':
|
|
||||||
preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page);
|
|
||||||
|
|
||||||
switch ($on_page[1])
|
|
||||||
{
|
|
||||||
case 'reply':
|
|
||||||
$location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'viewtopic':
|
|
||||||
$location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'viewforum':
|
|
||||||
$location .= sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$location_url = "viewforum.$phpEx$SID&f=$forum_id";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$location = $user->lang['INDEX'];
|
|
||||||
$location_url = "index.$phpEx$SID";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'search':
|
|
||||||
$location = $user->lang['SEARCHING_FORUMS'];
|
|
||||||
$location_url = "search.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'faq':
|
|
||||||
$location = $user->lang['VIEWING_FAQ'];
|
|
||||||
$location_url = "faq.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'viewonline':
|
|
||||||
$location = $user->lang['VIEWING_ONLINE'];
|
|
||||||
$location_url = "viewonline.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'memberlist':
|
|
||||||
$location = $user->lang['VIEWING_MEMBERS'];
|
|
||||||
$location_url = "memberlist.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'ucp':
|
|
||||||
$location = $user->lang['VIEWING_UCP'];
|
|
||||||
$location_url = '';
|
|
||||||
|
|
||||||
default:
|
|
||||||
$location = $user->lang['INDEX'];
|
|
||||||
$location_url = "index.$phpEx$SID";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_block_vars($which_row, array(
|
if (!$view_online || $counter > $start + $config['topics_per_page'] || $counter <= $start)
|
||||||
'USERNAME' => $username,
|
{
|
||||||
'LASTUPDATE' => $user->format_date($row['session_time']),
|
continue;
|
||||||
'FORUM_LOCATION'=> $location,
|
}
|
||||||
'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '',
|
|
||||||
|
|
||||||
'U_USER_PROFILE' => ($row['user_type'] <> USER_IGNORE) ? "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] : '',
|
|
||||||
'U_USER_IP' => "viewonline.$phpEx$SID" . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&mode=lookup&s=' . $row['session_id'] : ''),
|
|
||||||
'U_WHOIS' => "viewonline.$phpEx$SID&mode=whois&s=" . $row['session_id'],
|
|
||||||
'U_FORUM_LOCATION' => $location_url)
|
|
||||||
);
|
|
||||||
|
|
||||||
$$which_counter++;
|
|
||||||
}
|
}
|
||||||
|
else if ($show_guests && $row['user_id'] == ANONYMOUS && !isset($prev_ip[$row['session_ip']]))
|
||||||
|
{
|
||||||
|
$prev_ip[$row['session_ip']] = 1;
|
||||||
|
$guest_counter++;
|
||||||
|
$counter++;
|
||||||
|
|
||||||
|
if ($counter > $start + $config['topics_per_page'] || $counter <= $start)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['username'] = $user->lang['GUEST'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
preg_match('#^([a-z]+)#i', $row['session_page'], $on_page);
|
||||||
|
if (!sizeof($on_page))
|
||||||
|
{
|
||||||
|
$on_page[1] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($on_page[1])
|
||||||
|
{
|
||||||
|
case 'index':
|
||||||
|
$location = $user->lang['INDEX'];
|
||||||
|
$location_url = "index.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'posting':
|
||||||
|
case 'viewforum':
|
||||||
|
case 'viewtopic':
|
||||||
|
preg_match('#f=([0-9]+)#', $row['session_page'], $forum_id);
|
||||||
|
$forum_id = (sizeof($forum_id)) ? $forum_id[1] : 0;
|
||||||
|
|
||||||
|
if ($auth->acl_get('f_list', $forum_id))
|
||||||
|
{
|
||||||
|
$location = '';
|
||||||
|
switch ($on_page[1])
|
||||||
|
{
|
||||||
|
case 'posting':
|
||||||
|
preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page);
|
||||||
|
|
||||||
|
switch ($on_page[1])
|
||||||
|
{
|
||||||
|
case 'reply':
|
||||||
|
$location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'viewtopic':
|
||||||
|
$location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'viewforum':
|
||||||
|
$location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$location_url = "viewforum.$phpEx$SID&f=$forum_id";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$location = $user->lang['INDEX'];
|
||||||
|
$location_url = "index.$phpEx$SID";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'search':
|
||||||
|
$location = $user->lang['SEARCHING_FORUMS'];
|
||||||
|
$location_url = "search.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'faq':
|
||||||
|
$location = $user->lang['VIEWING_FAQ'];
|
||||||
|
$location_url = "faq.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'viewonline':
|
||||||
|
$location = $user->lang['VIEWING_ONLINE'];
|
||||||
|
$location_url = "viewonline.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'memberlist':
|
||||||
|
$location = $user->lang['VIEWING_MEMBERS'];
|
||||||
|
$location_url = "memberlist.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'ucp':
|
||||||
|
$location = $user->lang['VIEWING_UCP'];
|
||||||
|
$location_url = '';
|
||||||
|
|
||||||
|
default:
|
||||||
|
$location = $user->lang['INDEX'];
|
||||||
|
$location_url = "index.$phpEx$SID";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_block_vars('user_row', array(
|
||||||
|
'USERNAME' => $row['username'],
|
||||||
|
'LASTUPDATE' => $user->format_date($row['session_time']),
|
||||||
|
'FORUM_LOCATION'=> $location,
|
||||||
|
'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '',
|
||||||
|
|
||||||
|
'U_USER_PROFILE' => ($row['user_type'] != USER_IGNORE && $row['user_id'] != ANONYMOUS) ? "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] : '',
|
||||||
|
'U_USER_IP' => "{$phpbb_root_path}viewonline.$phpEx$SID" . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&s=' . $row['session_id'] : '') . "&mode=lookup&sg=$show_guests&start=$start&sk=$sort_key&sd=$sort_dir",
|
||||||
|
'U_WHOIS' => "{$phpbb_root_path}viewonline.$phpEx$SID&mode=whois&s=" . $row['session_id'],
|
||||||
|
'U_FORUM_LOCATION' => $phpbb_root_path . $location_url,
|
||||||
|
|
||||||
|
'S_GUEST' => ($row['user_id'] == ANONYMOUS) ? true : false,
|
||||||
|
'S_USER_TYPE' => $row['user_type'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
unset($prev_id);
|
unset($prev_id, $prev_ip);
|
||||||
unset($prev_ip);
|
|
||||||
|
|
||||||
|
|
||||||
// Generate reg/hidden/guest online text
|
// Generate reg/hidden/guest online text
|
||||||
$vars_online = array(
|
$vars_online = array(
|
||||||
'REG' => array('logged_visible_online', 'l_r_user_s'),
|
'REG' => array('logged_visible_online', 'l_r_user_s'),
|
||||||
'HIDDEN'=> array('logged_hidden_online', 'l_h_user_s'),
|
'HIDDEN'=> array('logged_hidden_online', 'l_h_user_s'),
|
||||||
'GUEST' => array('guests_online', 'l_g_user_s')
|
'GUEST' => array('guest_counter', 'l_g_user_s')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($vars_online as $l_prefix => $var_ary)
|
foreach ($vars_online as $l_prefix => $var_ary)
|
||||||
|
@ -264,34 +291,42 @@ foreach ($vars_online as $l_prefix => $var_ary)
|
||||||
}
|
}
|
||||||
unset($vars_online);
|
unset($vars_online);
|
||||||
|
|
||||||
|
$pagination = generate_pagination("{$phpbb_root_path}viewonline.$phpEx$SID&sg=$show_guests&sk=$sort_key&sd=$sort_dir", $counter, $config['topics_per_page'], $start);
|
||||||
|
|
||||||
// Grab group details for legend display
|
// Grab group details for legend display
|
||||||
$sql = 'SELECT group_name, group_colour, group_type
|
$sql = 'SELECT group_id, group_name, group_colour, group_type
|
||||||
FROM ' . GROUPS_TABLE . "
|
FROM ' . GROUPS_TABLE . '
|
||||||
WHERE group_colour <> ''
|
WHERE group_legend = 1';
|
||||||
AND group_type NOT IN (" . GROUP_HIDDEN . ', ' . GROUP_SPECIAL . ')';
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$legend = '';
|
$legend = '';
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$legend .= (($legend != '') ? ', ' : '') . '<span style="color:#' . $row['group_colour'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</span>';
|
$legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="memberlist.' . $phpEx . $SID . '&mode=group&g=' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</a>';
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
|
||||||
// Send data to template
|
// Send data to template
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $logged_visible_online) . sprintf($l_h_user_s, $logged_hidden_online),
|
'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $logged_visible_online) . sprintf($l_h_user_s, $logged_hidden_online),
|
||||||
'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guests_online),
|
'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_counter),
|
||||||
'LEGEND' => $legend,
|
'LEGEND' => $legend,
|
||||||
'META' => '<meta http-equiv="refresh" content="60; url=viewonline.' . $phpEx . $SID . '">',
|
'META' => '<meta http-equiv="refresh" content="60; url=viewonline.' . $phpEx . $SID . '">',
|
||||||
|
'PAGINATION' => $pagination,
|
||||||
|
'PAGE_NUMBER' => on_page($counter, $config['topics_per_page'], $start),
|
||||||
|
|
||||||
'U_SORT_USERNAME' => "viewonline.$phpEx$SID&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
|
'U_SORT_USERNAME' => "{$phpbb_root_path}viewonline.$phpEx$SID&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||||
'U_SORT_UPDATED' => "viewonline.$phpEx$SID&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
|
'U_SORT_UPDATED' => "{$phpbb_root_path}viewonline.$phpEx$SID&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||||
'U_SORT_LOCATION' => "viewonline.$phpEx$SID&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'))
|
'U_SORT_LOCATION' => "{$phpbb_root_path}viewonline.$phpEx$SID&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
|
||||||
|
|
||||||
|
'U_SWITCH_GUEST_DISPLAY' => "{$phpbb_root_path}viewonline.$phpEx$SID&sg=" . ((int) !$show_guests),
|
||||||
|
'L_SWITCH_GUEST_DISPLAY' => ($show_guests) ? $user->lang['HIDE_GUESTS'] : $user->lang['DISPLAY_GUESTS'],
|
||||||
|
'S_SWITCH_GUEST_DISPLAY' => ($config['load_online_guests']) ? true : false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// We do not need to load the who is online box here. ;)
|
||||||
|
$config['load_online'] = false;
|
||||||
|
|
||||||
// Output the page
|
// Output the page
|
||||||
page_header($user->lang['WHO_IS_ONLINE']);
|
page_header($user->lang['WHO_IS_ONLINE']);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue