Removed duplicate users improved guest user output

git-svn-id: file:///svn/phpbb/trunk@904 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-08-18 13:49:29 +00:00
parent d78809cb5f
commit 7f3db9c245
2 changed files with 190 additions and 95 deletions

View file

@ -9,20 +9,44 @@
<tr>
<td class="tablebg"><table width="100%" cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="cat" colspan="3" align="center"><span class="gen"><b>{TOTAL_USERS_ONLINE}</b></span><br /><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
<td class="cat" colspan="3" align="center"><span class="gen"><b>{TOTAL_REGISTERED_USERS_ONLINE}</b></span><br /><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
<tr>
<th width="35%">&nbsp;{L_USERNAME}&nbsp;</th>
<th width="25%">&nbsp;{L_LAST_UPDATE}&nbsp;</th>
<th width="40%">&nbsp;{L_LOCATION}&nbsp;</th>
</tr>
<!-- BEGIN reguserrow -->
<tr bgcolor="{reguserrow.ROW_COLOR}">
<td width="35%">&nbsp;<span class="gen"><a href="{reguserrow.U_USER_PROFILE}">{reguserrow.USERNAME}</a></span>&nbsp;</td>
<td width="25%" align="center">&nbsp;<span class="gen">{reguserrow.LASTUPDATE}</span>&nbsp;</td>
<td width="40%">&nbsp;<span class="gen"><a href="{reguserrow.U_FORUM_LOCATION}">{reguserrow.LOCATION}</a></span>&nbsp;</td>
<!-- BEGIN reg_user_row -->
<tr bgcolor="{reg_user_row.ROW_COLOR}">
<td width="35%">&nbsp;<span class="gen"><a href="{reg_user_row.U_USER_PROFILE}">{reg_user_row.USERNAME}</a></span>&nbsp;</td>
<td width="25%" align="center">&nbsp;<span class="gen">{reg_user_row.LASTUPDATE}</span>&nbsp;</td>
<td width="40%">&nbsp;<span class="gen"><a href="{reg_user_row.U_FORUM_LOCATION}">{reg_user_row.LOCATION}</a></span>&nbsp;</td>
</tr>
<!-- END reguserrow -->
<!-- END reg_user_row -->
</table></td>
</tr>
</table>
<br clear="all" />
<table width="98%" cellpadding="1" cellspacing="0" border="0" align="center">
<tr>
<td class="tablebg"><table width="100%" cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="cat" colspan="3" align="center"><span class="gen"><b>{TOTAL_GUEST_USERS_ONLINE}</b></span><br /><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
<tr>
<th width="35%">&nbsp;{L_USERNAME}&nbsp;</th>
<th width="25%">&nbsp;{L_LAST_UPDATE}&nbsp;</th>
<th width="40%">&nbsp;{L_LOCATION}&nbsp;</th>
</tr>
<!-- BEGIN guest_user_row -->
<tr bgcolor="{guest_user_row.ROW_COLOR}">
<td width="35%">&nbsp;<span class="gen"><a href="{guest_user_row.U_USER_PROFILE}">{guest_user_row.USERNAME}</a></span>&nbsp;</td>
<td width="25%" align="center">&nbsp;<span class="gen">{guest_user_row.LASTUPDATE}</span>&nbsp;</td>
<td width="40%">&nbsp;<span class="gen"><a href="{guest_user_row.U_FORUM_LOCATION}">{guest_user_row.LOCATION}</a></span>&nbsp;</td>
</tr>
<!-- END guest_user_row -->
</table></td>
</tr>
</table>

View file

@ -25,9 +25,6 @@ $phpbb_root_path = "./";
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$pagetype = "viewonline";
$page_title = "Who's Online";
//
// Start session management
//
@ -41,6 +38,7 @@ init_userprefs($userdata);
// Output page header and load
// viewonline template
//
$page_title = $lang['Who_is_online'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
@ -61,16 +59,29 @@ $template->assign_var_from_handle("JUMPBOX", "jumpbox");
// End header
//
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, s.session_page, s.session_logged_in, s.session_time
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, s.session_page, s.session_logged_in, s.session_time
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
WHERE u.user_id = s.session_user_id
AND s.session_time >= " . (time()-300) . "
WHERE u.user_id <> " . ANONYMOUS . "
AND u.user_id = s.session_user_id
AND s.session_time >= " . ( time() - 300 ) . "
AND s.session_logged_in = " . TRUE . "
ORDER BY s.session_time DESC";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain user/online information.", "", __LINE__, __FILE__, $sql);
message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
}
$onlinerow = $db->sql_fetchrowset($result);
$onlinerow_reg = $db->sql_fetchrowset($result);
$sql = "SELECT session_page, session_logged_in, session_time
FROM " . SESSIONS_TABLE . "
WHERE session_logged_in = 0
AND session_time >= " . ( time() - 300 ) . "
ORDER BY session_time DESC";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql);
}
$onlinerow_guest = $db->sql_fetchrowset($result);
$sql = "SELECT forum_name, forum_id
FROM " . FORUMS_TABLE;
@ -97,62 +108,40 @@ $template->assign_vars(array(
$active_users = 0;
$guest_users = 0;
$online_count = $db->sql_numrows($result);
if($online_count)
//
// Registered users ...
//
if( count($onlinerow_reg) )
{
$count_reg = 0;
$count_anon = 0;
$registered_users = 0;
$hidden_users = 0;
for($i = 0; $i < $online_count; $i++)
$displayed_userid_list = "";
for($i = 0; $i < count($onlinerow_reg); $i++)
{
if($onlinerow[$i]['user_id'] != ANONYMOUS)
if( !eregi("," . $onlinerow_reg[$i]['user_id'], $displayed_userid_list) )
{
if($onlinerow[$i]['session_logged_in'])
if( $onlinerow_reg[$i]['user_allow_viewonline'] )
{
if($onlinerow[$i]['user_allow_viewonline'])
{
$username = $onlinerow[$i]['username'];
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username'];
$hidden = FALSE;
$logged_on = TRUE;
$active_users++;
$registered_users++;
}
else
{
$username = $onlinerow[$i]['username'];
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username'];
$hidden = TRUE;
$logged_on = TRUE;
$hidden_users++;
}
}
else
{
if($onlinerow[$i]['user_allow_viewonline'])
{
$username = $onlinerow[$i]['username'];
$hidden = FALSE;
$logged_on = FALSE;
$guest_users++;
}
else
{
$username = $onlinerow[$i]['username'];
$hidden = TRUE;
$logged_on = FALSE;
$guest_users++;
}
}
}
else
{
$username = $lang['Anonymous'];
$hidden = FALSE;
$logged_on = FALSE;
$guest_users++;
}
if($onlinerow[$i]['session_page'] < 1)
if($onlinerow_reg[$i]['session_page'] < 1)
{
switch($onlinerow[$i]['session_page'])
switch($onlinerow_reg[$i]['session_page'])
{
case PAGE_INDEX:
$location = $lang['Forum_index'];
@ -197,58 +186,140 @@ if($online_count)
}
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow[$i]['session_page']);
$location = $forum_data[$onlinerow[$i]['session_page']];
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['session_page']);
$location = $forum_data[$onlinerow_reg[$i]['session_page']];
}
if( $logged_on && ( !$hidden || $userdata['user_level'] == ADMIN ) )
if( !$hidden || $userdata['user_level'] == ADMIN )
{
$row_color = ( !($count_reg % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($count_reg % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$count_reg++;
$row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("reguserrow", array(
$template->assign_block_vars("reg_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $username,
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow[$i]['session_time'], $board_config['default__timezone']),
"LOCATION" => $location,
"U_USER_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $onlinerow[$i]['user_id']),
"U_FORUM_LOCATION" => append_sid($location_url))
);
}
else if( !$hidden || $userdata['user_level'] == ADMIN )
{
$row_color = ( !($count_reg % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($count_reg % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$count_reg++;
$template->assign_block_vars("anonuserrow", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['Guest'],
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow[$i]['session_time'], $board_config['default__timezone']),
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['session_time'], $board_config['default__timezone']),
"LOCATION" => $location,
"U_USER_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $onlinerow_reg[$i]['user_id']),
"U_FORUM_LOCATION" => append_sid($location_url))
);
}
}
}
$l_h_user_s = ($hidden_users == 1) ? $lang['User'] : $lang['Users'];
$l_r_user_s = ($registered_users == 1) ? $lang['User'] : $lang['Users'];
$l_is_are = ($registered_users == 1) ? $lang['is'] : $lang['are'];
$template->assign_vars(array(
"ACTIVE_USERS" => $active_users,
"HIDDEN_USERS" => $hidden_users,
"GUEST_USERS" => $guest_users)
"TOTAL_REGISTERED_USERS_ONLINE" => $lang['There'] . " $l_is_are $logged_visible_online " . $lang['Registered'] . " $l_r_user_s " . $lang['and'] . " $logged_hidden_online " . $lang['Hidden'] . " $l_h_user_s " . $lang['online'])
);
$template->pparse("body");
}
else
{
message_die(GENERAL_MESSAGE, "There are no users currently browsing this forum");
$template->assign_vars(array(
"TOTAL_REGISTERED_USERS_ONLINE" => $lang['There'] . " " . $lang['are'] . " 0 " . $lang['Registered'] . " " . $lang['Users'] . " " . $lang['and'] . " 0 " . $lang['Hidden'] . " " . $lang['Users'] . " " . $lang['online'],
"L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing'])
);
}
//
// Guest users
//
if( count($onlinerow_guest) )
{
$guest_users = 0;
for($i = 0; $i < count($onlinerow_guest); $i++)
{
$guest_users++;
if($onlinerow_guest[$i]['session_page'] < 1)
{
switch($onlinerow_guest[$i]['session_page'])
{
case PAGE_INDEX:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
break;
case PAGE_POSTING:
$location = $lang['Posting_message'];
$location_url = "index.$phpEx";
break;
case PAGE_LOGIN:
$location = $lang['Logging_on'];
$location_url = "index.$phpEx";
break;
case PAGE_SEARCH:
$location = $lang['Searching_forums'];
$location_url = "search.$phpEx";
break;
case PAGE_PROFILE:
$location = $lang['Viewing_profile'];
$location_url = "index.$phpEx";
break;
case PAGE_VIEWONLINE:
$location = $lang['Viewing_online'];
$location_url = "viewonline.$phpEx";
break;
case PAGE_VIEWMEMBERS:
$location = $lang['Viewing_member_list'];
$location_url = "memberlist.$phpEx";
break;
case PAGE_PRIVMSGS:
$location = $lang['Viewing_priv_msgs'];
$location_url = "privmsg.$phpEx";
break;
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "faq.$phpEx";
break;
default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
}
}
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']);
$location = $forum_data[$onlinerow_guest[$i]['session_page']];
}
$row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars("guest_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['Guest'],
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['default__timezone']),
"LOCATION" => $location,
"U_FORUM_LOCATION" => append_sid($location_url))
);
}
$l_g_user_s = ($guest_users == 1) ? $lang['User'] : $lang['Users'];
$l_is_are = ($guest_users == 1) ? $lang['is'] : $lang['are'];
$template->assign_vars(array(
"TOTAL_GUEST_USERS_ONLINE" => $lang['There'] . " $l_is_are $guests_online " . $lang['Guest'] . " $l_g_user_s " . $lang['online'])
);
}
else
{
$template->assign_vars(array(
"TOTAL_GUEST_USERS_ONLINE" => $lang['There'] . " " . $lang['are'] . " 0 " . $lang['Guest'] . " " . $lang['Users'] . " " . $lang['online'],
"L_NO_GUESTS_BROWSING" => $lang['No_guests_browsing'])
);
}
$template->pparse("body");
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>