1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-10 17:45:18 +02:00

Minor changes to whosonline stuff

git-svn-id: file:///svn/phpbb/trunk@1650 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-12-21 01:29:09 +00:00
parent bd5f308f6b
commit df2f8692f0
2 changed files with 194 additions and 61 deletions

View File

@ -28,6 +28,24 @@ $phpbb_root_dir = "./../";
$no_page_header = TRUE; $no_page_header = TRUE;
require('pagestart.inc'); require('pagestart.inc');
// ---------------
// Begin functions
//
function inarray($needle, $haystack)
{
for($i = 0; $i < sizeof($haystack); $i++ )
{
if( $haystack[$i] == $needle )
{
return true;
}
}
return false;
}
//
// End functions
// -------------
// //
// Generate relevant output // Generate relevant output
// //
@ -287,25 +305,20 @@ elseif( $HTTP_GET_VARS['pane'] == 'right' )
// //
// Get users online information. // Get users online information.
// //
$sql = "SELECT u.user_id, u.username, u.user_session_time AS session_time, u.user_session_page AS session_page, session_ip $sql = "SELECT u.user_id, u.username, u.user_session_time, u.user_session_page, s.session_logged_in, s.session_ip, s.session_start
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
WHERE s.session_logged_in = " . TRUE . " WHERE s.session_logged_in = " . TRUE . "
AND u.user_id = s.session_user_id AND u.user_id = s.session_user_id
AND u.user_id <> " . ANONYMOUS . " AND u.user_id <> " . ANONYMOUS . "
AND u.user_session_time >= " . ( time() - 300 ) . " AND u.user_session_time >= " . ( time() - 300 ) . "
ORDER BY s.session_time DESC"; ORDER BY u.user_session_time DESC";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
} }
$onlinerow_reg = $db->sql_fetchrowset($result);
$onlinerow = array(); $sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start
while( $row = $db->sql_fetchrow($result) )
{
$onlinerow[] = $row;
}
$sql = "SELECT session_user_id AS user_id, session_page, session_logged_in, session_time, session_ip
FROM " . SESSIONS_TABLE . " FROM " . SESSIONS_TABLE . "
WHERE session_logged_in = 0 WHERE session_logged_in = 0
AND session_time >= " . ( time() - 300 ) . " AND session_time >= " . ( time() - 300 ) . "
@ -314,11 +327,7 @@ elseif( $HTTP_GET_VARS['pane'] == 'right' )
{ {
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql);
} }
$onlinerow_guest = $db->sql_fetchrowset($result);
while( $row = $db->sql_fetchrow($result) )
{
$onlinerow[] = $row;
}
$sql = "SELECT forum_name, forum_id $sql = "SELECT forum_name, forum_id
FROM " . FORUMS_TABLE; FROM " . FORUMS_TABLE;
@ -334,91 +343,201 @@ elseif( $HTTP_GET_VARS['pane'] == 'right' )
message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql);
} }
$online_count = count($onlinerow); $reg_userid_ary = array();
if($online_count)
{
$count = 0;
for($i = 0; $i < $online_count; $i++) if( count($onlinerow_reg) )
{ {
$username = ( $onlinerow[$i]['user_id'] == ANONYMOUS ) ? $lang['Anonymous'] : $onlinerow[$i]['username']; $registered_users = 0;
if( $onlinerow[$i]['session_page'] < 1 ) for($i = 0; $i < count($onlinerow_reg); $i++)
{ {
switch( $onlinerow[$i]['session_page'] ) if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) )
{
$reg_userid_ary[] = $onlinerow_reg[$i]['user_id'];
$username = $onlinerow_reg[$i]['username'];
if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
{
$registered_users++;
$hidden = FALSE;
}
else
{
$hidden_users++;
$hidden = TRUE;
}
if( $onlinerow_reg[$i]['user_session_page'] < 1 )
{
switch($onlinerow_reg[$i]['user_session_page'])
{ {
case PAGE_INDEX: case PAGE_INDEX:
$location = $lang['Forum_index']; $location = $lang['Forum_index'];
$location_url = "index.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_POSTING: case PAGE_POSTING:
$location = $lang['Posting_message']; $location = $lang['Posting_message'];
$location_url = "index.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_LOGIN: case PAGE_LOGIN:
$location = $lang['Logging_on']; $location = $lang['Logging_on'];
$location_url = "index.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_SEARCH: case PAGE_SEARCH:
$location = $lang['Searching_forums']; $location = $lang['Searching_forums'];
$location_url = "search.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_PROFILE: case PAGE_PROFILE:
$location = $lang['Viewing_profile']; $location = $lang['Viewing_profile'];
$location_url = "index.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_VIEWONLINE: case PAGE_VIEWONLINE:
$location = $lang['Viewing_online']; $location = $lang['Viewing_online'];
$location_url = "viewonline.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_VIEWMEMBERS: case PAGE_VIEWMEMBERS:
$location = $lang['Viewing_member_list']; $location = $lang['Viewing_member_list'];
$location_url = "memberlist.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_PRIVMSGS: case PAGE_PRIVMSGS:
$location = $lang['Viewing_priv_msgs']; $location = $lang['Viewing_priv_msgs'];
$location_url = "privmsg.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
case PAGE_FAQ: case PAGE_FAQ:
$location = $lang['Viewing_FAQ']; $location = $lang['Viewing_FAQ'];
$location_url = "faq.$phpEx"; $location_url = "index.$phpEx?pane=right";
break; break;
default: default:
$location = $lang['Forum_index']; $location = $lang['Forum_index'];
$location_url = "index.$phpEx"; $location_url = "index.$phpEx?pane=right";
} }
} }
else else
{ {
$location_url = append_sid("admin_forum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow[$i]['session_page']); $location_url = append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['user_session_page']);
$location = $forum_data[$onlinerow[$i]['session_page']]; $location = $forum_data[$onlinerow_reg[$i]['user_session_page']];
} }
$row_color = ( !($count % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($count % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
$count++; $reg_ip = decode_ip($onlinerow_reg[$i]['session_ip']);
$ip_address = decode_ip($onlinerow[$i]['session_ip']); $template->assign_block_vars("reg_user_row", array(
if( empty($username) )
{
$username = $lang['Guest'];
}
$template->assign_block_vars("userrow", array(
"ROW_COLOR" => "#" . $row_color, "ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class, "ROW_CLASS" => $row_class,
"USERNAME" => $username, "USERNAME" => $username,
"LOGGED_ON" => $logged_on, "STARTED" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['session_start'], $board_config['board_timezone']),
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow[$i]['session_time'], $board_config['board_timezone']), "LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['user_session_time'], $board_config['board_timezone']),
"LOCATION" => $location, "FORUM_LOCATION" => $location,
"IP_ADDRESS" => $ip_address, "IP_ADDRESS" => $reg_ip,
"U_USER_PROFILE" => append_sid("admin_users.$phpEx?" . POST_USERS_URL . "=" . $onlinerow[$i]['user_id'] . "&mode=edit"))
"U_WHOIS_IP" => "http://www.samspade.org/t/ipwhois?a=$reg_ip",
"U_USER_PROFILE" => append_sid("admin_users.$phpEx?mode=edit&amp;" . POST_USERS_URL . "=" . $onlinerow_reg[$i]['user_id']),
"U_FORUM_LOCATION" => append_sid($location_url))
); );
} }
} }
}
else
{
$template->assign_vars(array(
"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_userip_ary[] = $onlinerow_guest[$i]['session_ip'];
$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?pane=right";
break;
case PAGE_POSTING:
$location = $lang['Posting_message'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_LOGIN:
$location = $lang['Logging_on'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_SEARCH:
$location = $lang['Searching_forums'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_PROFILE:
$location = $lang['Viewing_profile'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_VIEWONLINE:
$location = $lang['Viewing_online'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_VIEWMEMBERS:
$location = $lang['Viewing_member_list'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_PRIVMSGS:
$location = $lang['Viewing_priv_msgs'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "index.$phpEx?pane=right";
break;
default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx?pane=right";
}
}
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'];
$guest_ip = decode_ip($onlinerow_guest[$i]['session_ip']);
$template->assign_block_vars("guest_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $lang['Guest'],
"STARTED" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_start'], $board_config['board_timezone']),
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']),
"FORUM_LOCATION" => $location,
"IP_ADDRESS" => $guest_ip,
"U_WHOIS_IP" => "http://www.samspade.org/t/ipwhois?a=$guest_ip",
"U_FORUM_LOCATION" => append_sid($location_url))
);
}
}
else
{
$template->assign_vars(array(
"L_NO_GUESTS_BROWSING" => $lang['No_users_browsing'])
);
}
$template->pparse("body"); $template->pparse("body");
include('page_footer_admin.'.$phpEx); include('page_footer_admin.'.$phpEx);

View File

@ -47,19 +47,33 @@
<table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline"> <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline">
<tr> <tr>
<th width="25%" height="25" class="thCornerL">&nbsp;{L_USERNAME}&nbsp;</th> <th width="20%" class="thCornerL" height="25">&nbsp;{L_USERNAME}&nbsp;</th>
<th width="25%" height="25" class="thTop">&nbsp;{L_LAST_UPDATE}&nbsp;</th> <th width="20%" height="25" class="thTop">&nbsp;{L_STARTED}&nbsp;</th>
<th width="25%" height="25" class="thTop">&nbsp;{L_LOCATION}&nbsp;</th> <th width="20%" class="thTop">&nbsp;{L_LAST_UPDATE}&nbsp;</th>
<th width="25%" height="25" class="thCornerR">&nbsp;{L_IP_ADDRESS}&nbsp;</th> <th width="20%" class="thCornerR">&nbsp;{L_FORUM_LOCATION}&nbsp;</th>
<th width="20%" height="25" class="thCornerR">&nbsp;{L_IP_ADDRESS}&nbsp;</th>
</tr> </tr>
<!-- BEGIN userrow --> <!-- BEGIN reg_user_row -->
<tr> <tr>
<td width="25%" class="{userrow.ROW_CLASS}">&nbsp;<span class="gen"><a href="{userrow.U_USER_PROFILE}">{userrow.USERNAME}</a></span>&nbsp;</td> <td width="20%" class="{reg_user_row.ROW_CLASS}">&nbsp;<span class="gen"><a href="{reg_user_row.U_USER_PROFILE}" class="gen">{reg_user_row.USERNAME}</a></span>&nbsp;</td>
<td width="25%" align="center" class="{userrow.ROW_CLASS}">&nbsp;<span class="gen">{userrow.LASTUPDATE}</span>&nbsp;</td> <td width="20%" align="center" class="{reg_user_row.ROW_CLASS}">&nbsp;<span class="gen">{reg_user_row.STARTED}</span>&nbsp;</td>
<td width="25%" class="{userrow.ROW_CLASS}">&nbsp;<span class="gen">{userrow.LOCATION}</span>&nbsp;</td> <td width="20%" align="center" nowrap="nowrap" class="{reg_user_row.ROW_CLASS}">&nbsp;<span class="gen">{reg_user_row.LASTUPDATE}</span>&nbsp;</td>
<td width="25%" class="{userrow.ROW_CLASS}">&nbsp;<span class="gen">{userrow.IP_ADDRESS}</span>&nbsp;</td> <td width="20%" class="{reg_user_row.ROW_CLASS}">&nbsp;<span class="gen"><a href="{reg_user_row.U_FORUM_LOCATION}" class="gen">{reg_user_row.FORUM_LOCATION}</a></span>&nbsp;</td>
<td width="20%" class="{reg_user_row.ROW_CLASS}">&nbsp;<span class="gen"><a href="{reg_user_row.U_WHOIS_IP}" class="gen" target="_phpbbwhois">{reg_user_row.IP_ADDRESS}</a></span>&nbsp;</td>
</tr> </tr>
<!-- END userrow --> <!-- END reg_user_row -->
<tr>
<td colspan="5" height="1" class="row3"><img src="templates/subSilver/images/spacer.gif" width="1" height="1" alt="."></td>
</tr>
<!-- BEGIN guest_user_row -->
<tr>
<td width="20%" class="{guest_user_row.ROW_CLASS}">&nbsp;<span class="gen">{guest_user_row.USERNAME}</span>&nbsp;</td>
<td width="20%" align="center" class="{guest_user_row.ROW_CLASS}">&nbsp;<span class="gen">{guest_user_row.STARTED}</span>&nbsp;</td>
<td width="20%" align="center" nowrap="nowrap" class="{guest_user_row.ROW_CLASS}">&nbsp;<span class="gen">{guest_user_row.LASTUPDATE}</span>&nbsp;</td>
<td width="20%" class="{guest_user_row.ROW_CLASS}">&nbsp;<span class="gen"><a href="{guest_user_row.U_FORUM_LOCATION}" class="gen">{guest_user_row.FORUM_LOCATION}</a></span>&nbsp;</td>
<td width="20%" class="{guest_user_row.ROW_CLASS}">&nbsp;<span class="gen"><a href="{guest_user_row.U_WHOIS_IP}" target="_phpbbwhois">{guest_user_row.IP_ADDRESS}</a></span>&nbsp;</td>
</tr>
<!-- END guest_user_row -->
</table> </table>
<br /> <br />