1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-15 22:26:32 +02:00

Enable/Disable online listing + time online

git-svn-id: file:///svn/phpbb/trunk@3841 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen
2003-04-15 22:57:05 +00:00
parent d9dcb502a9
commit dce7e4c2b8
3 changed files with 116 additions and 108 deletions

View File

@ -50,32 +50,31 @@ else
// Last visit date/time // Last visit date/time
$s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : ''; $s_last_visit = ($user->data['user_id'] != ANONYMOUS) ? $user->format_date($user->data['session_last_visit']) : '';
// Get users online list
$userlist_ary = array();
$userlist_visible = array();
$logged_visible_online = 0; // Get users online list ... if required
$logged_hidden_online = 0; $l_online_users = $online_userlist = $l_online_record = '';
$guests_online = 0; if (!empty($config['load_online']) && !empty($config['load_online_time']))
$online_userlist = '';
$prev_user_id = 0;
$prev_user_ip = $reading_sql = '';
if (!empty($_REQUEST['f']))
{ {
$reading_sql = 'AND s.session_page LIKE \'%f=' . intval($_REQUEST['f']) . '%\''; $userlist_ary = $userlist_visible = array();
} $logged_visible_online = $logged_hidden_online = $guests_online = 0;
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_allow_viewonline $prev_user_id = 0;
$prev_user_ip = $reading_sql = '';
if (!empty($_REQUEST['f']))
{
$reading_sql = "AND s.session_page LIKE '%f=" . intval($_REQUEST['f']) . "%'";
}
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip, s.session_allow_viewonline
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s
WHERE s.session_time >= " . (time() - 300) . " WHERE s.session_time >= " . (time() - (intval($config['load_online_time']) * 60)) . "
$reading_sql $reading_sql
AND u.user_id = s.session_user_id AND u.user_id = s.session_user_id
ORDER BY u.username ASC, s.session_ip ASC"; ORDER BY u.username ASC, s.session_ip ASC";
$result = $db->sql_query($sql, false); $result = $db->sql_query($sql, false);
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 therefor not a guest
if ($row['user_id'] != ANONYMOUS) if ($row['user_id'] != ANONYMOUS)
{ {
@ -117,41 +116,41 @@ while ($row = $db->sql_fetchrow($result))
} }
$prev_session_ip = $row['session_ip']; $prev_session_ip = $row['session_ip'];
} }
if ($online_userlist == '') if ($online_userlist == '')
{ {
$online_userlist = $user->lang['NONE']; $online_userlist = $user->lang['NONE'];
} }
if (empty($_REQUEST['f'])) if (empty($_REQUEST['f']))
{ {
$online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist; $online_userlist = $user->lang['Registered_users'] . ' ' . $online_userlist;
} }
else else
{ {
$l_online = ($guests_online == 1) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests']; $l_online = ($guests_online == 1) ? $user->lang['Browsing_forum_guest'] : $user->lang['Browsing_forum_guests'];
$online_userlist = sprintf($l_online, $online_userlist, $guests_online); $online_userlist = sprintf($l_online, $online_userlist, $guests_online);
} }
$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;
if ($total_online_users > $config['record_online_users']) if ($total_online_users > $config['record_online_users'])
{ {
set_config('record_online_users', $total_online_users); set_config('record_online_users', $total_online_users);
set_config('record_online_date', time()); set_config('record_online_date', time());
} }
// Build online listing // Build online listing
$vars_online = array( $vars_online = array(
'ONLINE'=> array('total_online_users', 'l_t_user_s'), 'ONLINE'=> array('total_online_users', 'l_t_user_s'),
'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('guests_online', 'l_g_user_s')
); );
foreach ($vars_online as $l_prefix => $var_ary) foreach ($vars_online as $l_prefix => $var_ary)
{ {
switch ($$var_ary[0]) switch ($$var_ary[0])
{ {
case 0: case 0:
@ -166,13 +165,17 @@ foreach ($vars_online as $l_prefix => $var_ary)
$$var_ary[1] = $user->lang[$l_prefix . '_USERS_TOTAL']; $$var_ary[1] = $user->lang[$l_prefix . '_USERS_TOTAL'];
break; break;
} }
} }
unset($vars_online); unset($vars_online);
$l_online_users = sprintf($l_t_user_s, $total_online_users); $l_online_users = sprintf($l_t_user_s, $total_online_users);
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online); $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
$l_online_users .= sprintf($l_g_user_s, $guests_online); $l_online_users .= sprintf($l_g_user_s, $guests_online);
$l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date']));
$l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES';
$l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']);
}
// Obtain number of new private messages if user is logged in // Obtain number of new private messages if user is logged in
@ -248,13 +251,14 @@ $template->assign_vars(array(
'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time())), 'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time())),
'TOTAL_USERS_ONLINE' => $l_online_users, 'TOTAL_USERS_ONLINE' => $l_online_users,
'LOGGED_IN_USER_LIST' => $online_userlist, 'LOGGED_IN_USER_LIST' => $online_userlist,
'RECORD_USERS' => sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'])), 'RECORD_USERS' => $l_online_record,
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
'L_LOGIN_LOGOUT' => $l_login_logout, 'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => $user->lang['FORUM_INDEX'], 'L_INDEX' => $user->lang['FORUM_INDEX'],
'L_ONLINE_EXPLAIN' => $l_online_time,
'U_PRIVATEMSGS' => 'ucp.'.$phpEx.$SID.'&mode=pm&folder=inbox', 'U_PRIVATEMSGS' => 'ucp.'.$phpEx.$SID.'&mode=pm&folder=inbox',
'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID, 'U_MEMBERLIST' => 'memberlist.'.$phpEx.$SID,
@ -280,6 +284,7 @@ $template->assign_vars(array(
'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'],
'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'],
'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], ''), 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang[$tz], ''),
'S_DISPLAY_ONLINE_LIST' => (!empty($config['load_online'])) ? 1 : 0,
'T_STYLESHEET_DATA' => $user->theme['css_data'], 'T_STYLESHEET_DATA' => $user->theme['css_data'],
'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'], 'T_STYLESHEET_LINK' => 'templates/' . $user->theme['css_external'],

View File

@ -848,7 +848,8 @@ $lang = array(
'Guest_users_zero_online' => 'There are 0 Guest users online', 'Guest_users_zero_online' => 'There are 0 Guest users online',
'Guest_user_online' => 'There is %d Guest user online', 'Guest_user_online' => 'There is %d Guest user online',
'No_users_browsing' => 'There are no users currently browsing this forum', 'No_users_browsing' => 'There are no users currently browsing this forum',
'ONLINE_EXPLAIN' => 'This data is based on users active over the past five minutes', 'VIEW_ONLINE_TIME' => 'This data is based on users active over the past %d minute', // 1 minute
'VIEW_ONLINE_TIMES' => 'This data is based on users active over the past %d minutes', // 2 minutes, etc.
'Forum_Location' => 'Forum Location', 'Forum_Location' => 'Forum Location',
'Last_updated' => 'Last Updated', 'Last_updated' => 'Last Updated',
'Forum_index' => 'Forum index', 'Forum_index' => 'Forum index',

View File

@ -40,7 +40,7 @@
<!-- ENDIF --> <!-- ENDIF -->
<!-- BEGINELSE --> <!-- BEGINELSE -->
<tr> <tr>
<td class="row1" colspan="5" height="28" align="center">{L_NO_FORUMS}</td> <td class="row1" colspan="5" height="28" align="center"><span class="gensmall">{L_NO_FORUMS}</span></td>
</tr> </tr>
<!-- END forumrow --> <!-- END forumrow -->
</table> </table>
@ -54,6 +54,7 @@
<br clear="all" /> <br clear="all" />
<!-- IF S_DISPLAY_ONLINE_LIST -->
<table class="tablebg" width="100%" cellspacing="1" cellpadding="2" border="0"> <table class="tablebg" width="100%" cellspacing="1" cellpadding="2" border="0">
<tr> <tr>
<td class="cat" colspan="2" height="28"><a class="cattitle" href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a></td> <td class="cat" colspan="2" height="28"><a class="cattitle" href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a></td>
@ -68,6 +69,7 @@
</tr> </tr>
<!-- ENDIF --> <!-- ENDIF -->
</table> </table>
<!-- ENDIF -->
<!-- IF not S_USER_LOGGED_IN --> <!-- IF not S_USER_LOGGED_IN -->
<form method="post" action="{S_LOGIN_ACTION}"><table class="tablebg" width="100%" cellspacing="1" cellpadding="3" border="0"> <form method="post" action="{S_LOGIN_ACTION}"><table class="tablebg" width="100%" cellspacing="1" cellpadding="3" border="0">