2001-04-15 16:37:53 +00:00
|
|
|
<?php
|
2001-08-30 22:20:23 +00:00
|
|
|
/***************************************************************************
|
2001-08-26 13:53:41 +00:00
|
|
|
* viewonline.php
|
2001-08-30 22:20:23 +00:00
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
2001-04-15 16:37:53 +00:00
|
|
|
* $Id$
|
2001-08-30 22:20:23 +00:00
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2001-04-15 16:37:53 +00:00
|
|
|
|
2002-03-18 13:35:43 +00:00
|
|
|
define('IN_PHPBB', true);
|
2002-03-31 00:06:34 +00:00
|
|
|
$phpbb_root_path = './';
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
2001-04-15 16:37:53 +00:00
|
|
|
|
|
|
|
// Start session management
|
2002-07-14 14:45:26 +00:00
|
|
|
$userdata = $session->start();
|
2002-10-04 13:09:10 +00:00
|
|
|
$auth->acl($userdata);
|
|
|
|
$user = new user($userdata);
|
2001-04-15 16:37:53 +00:00
|
|
|
// End session management
|
2001-07-13 16:14:37 +00:00
|
|
|
|
2002-02-14 02:03:20 +00:00
|
|
|
//
|
|
|
|
// Forum info
|
|
|
|
//
|
2002-08-13 16:34:17 +00:00
|
|
|
$sql = "SELECT forum_id, forum_name
|
2001-07-16 21:12:09 +00:00
|
|
|
FROM " . FORUMS_TABLE;
|
2002-07-14 14:45:26 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while( $row = $db->sql_fetchrow($result) )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2002-07-14 14:45:26 +00:00
|
|
|
$forum_data[$row['forum_id']] = $row['forum_name'];
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
//
|
2002-02-14 02:03:20 +00:00
|
|
|
// Get user list
|
2001-08-18 13:49:29 +00:00
|
|
|
//
|
2002-07-16 12:45:17 +00:00
|
|
|
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_colour, s.session_time, s.session_page, s.session_ip
|
2002-07-14 14:45:26 +00:00
|
|
|
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
|
2002-03-31 00:06:34 +00:00
|
|
|
WHERE u.user_id = s.session_user_id
|
2002-04-20 00:22:29 +00:00
|
|
|
AND s.session_time >= ".( time() - 300 ) . "
|
2002-07-14 14:45:26 +00:00
|
|
|
ORDER BY u.username ASC, s.session_ip ASC, s.session_time DESC";
|
|
|
|
$result = $db->sql_query($sql);
|
2001-11-03 13:54:04 +00:00
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
$guest_users = 0;
|
|
|
|
$registered_users = 0;
|
|
|
|
$hidden_users = 0;
|
|
|
|
|
|
|
|
$reg_counter = 0;
|
|
|
|
$guest_counter = 0;
|
|
|
|
$prev_user = 0;
|
2002-04-04 01:56:12 +00:00
|
|
|
$prev_ip = '';
|
2001-08-18 13:49:29 +00:00
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
while ( $row = $db->sql_fetchrow($result) )
|
|
|
|
{
|
2002-04-04 01:56:12 +00:00
|
|
|
$view_online = false;
|
2002-02-14 02:03:20 +00:00
|
|
|
|
2002-10-08 20:11:59 +00:00
|
|
|
if ( $row['user_id'] )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2002-04-02 16:09:00 +00:00
|
|
|
$user_id = $row['user_id'];
|
2002-02-14 02:22:42 +00:00
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
if ( $user_id != $prev_user )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2002-04-02 16:09:00 +00:00
|
|
|
$username = $row['username'];
|
2001-11-05 00:23:14 +00:00
|
|
|
|
2002-07-16 12:45:17 +00:00
|
|
|
if ( $row['user_colour'] )
|
|
|
|
{
|
|
|
|
$username = '<b style="color:#' . $row['user_colour'] . '">' . $username . '</b>';
|
|
|
|
}
|
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
if ( !$row['user_allow_viewonline'] )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2002-10-08 20:11:59 +00:00
|
|
|
$view_online = ( $auth->acl_get('a_') ) ? true : false;
|
2002-04-02 16:09:00 +00:00
|
|
|
$hidden_users++;
|
|
|
|
|
2002-04-04 11:25:56 +00:00
|
|
|
$username = '<i>' . $username . '</i>';
|
2002-02-14 02:22:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-04 01:56:12 +00:00
|
|
|
$view_online = true;
|
2002-04-02 16:09:00 +00:00
|
|
|
$registered_users++;
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
$which_counter = 'reg_counter';
|
|
|
|
$which_row = 'reg_user_row';
|
|
|
|
$prev_user = $user_id;
|
2002-02-14 02:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-02 16:09:00 +00:00
|
|
|
if ( $row['session_ip'] != $prev_ip )
|
|
|
|
{
|
2002-04-20 00:22:29 +00:00
|
|
|
$username = $lang['Guest'];
|
2002-04-04 01:56:12 +00:00
|
|
|
$view_online = true;
|
2002-04-02 16:09:00 +00:00
|
|
|
$guest_users++;
|
2002-08-13 16:34:17 +00:00
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
$which_counter = 'guest_counter';
|
|
|
|
$which_row = 'guest_user_row';
|
|
|
|
}
|
2002-02-14 02:03:20 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
$prev_ip = $row['session_ip'];
|
2001-04-15 16:37:53 +00:00
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
if ( $view_online )
|
2001-12-24 16:34:27 +00:00
|
|
|
{
|
2002-07-14 14:45:26 +00:00
|
|
|
preg_match('/\/?([a-z]+)\.' . $phpEx . '/', $row['session_page'], $on_page);
|
|
|
|
|
|
|
|
switch ( $on_page[1] )
|
2002-04-02 16:09:00 +00:00
|
|
|
{
|
2002-07-14 14:45:26 +00:00
|
|
|
case 'index':
|
|
|
|
$location = $lang['Forum_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];
|
|
|
|
|
2002-10-08 20:11:59 +00:00
|
|
|
if ( $auth->acl_get('f_list', $forum_id) )
|
2002-07-14 14:45:26 +00:00
|
|
|
{
|
|
|
|
$location = '';
|
|
|
|
switch ( $on_page[1] )
|
|
|
|
{
|
|
|
|
case 'posting':
|
|
|
|
$location = sprintf($lang['Posting_message'], $forum_data[$forum_id]);
|
|
|
|
break;
|
|
|
|
case 'viewtopic':
|
|
|
|
$location = sprintf($lang['Reading_topic'], $forum_data[$forum_id]);
|
|
|
|
break;
|
|
|
|
case 'viewforum':
|
|
|
|
$location .= $forum_data[$forum_id];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$location_url = "viewforum.$phpEx$SID&f=$forum_id";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-04-02 16:09:00 +00:00
|
|
|
$location = $lang['Forum_index'];
|
2002-07-14 14:45:26 +00:00
|
|
|
$location_url = "index.$phpEx$SID";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'search':
|
|
|
|
$location = $lang['Searching_forums'];
|
|
|
|
$location_url = "search.$phpEx$SID";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'profile':
|
|
|
|
$location = $lang['Viewing_profile'];
|
|
|
|
$location_url = "index.$phpEx$SID";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'faq':
|
|
|
|
$location = $lang['Viewing_FAQ'];
|
|
|
|
$location_url = "faq.$phpEx$SID";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'viewonline':
|
|
|
|
$location = $lang['Viewing_online'];
|
|
|
|
$location_url = "viewonline.$phpEx$SID";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'memberslist':
|
|
|
|
$location = $lang['Viewing_member_list'];
|
|
|
|
$location_url = "memberlist.$phpEx$SID";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$location = $lang['Forum_index'];
|
|
|
|
$location_url = "index.$phpEx$SID";
|
|
|
|
break;
|
2002-04-02 16:09:00 +00:00
|
|
|
}
|
2002-02-14 02:06:32 +00:00
|
|
|
|
2002-10-08 20:11:59 +00:00
|
|
|
$template->assign_block_vars($which_row, array(
|
2002-04-02 16:09:00 +00:00
|
|
|
'USERNAME' => $username,
|
2002-10-04 13:09:10 +00:00
|
|
|
'LASTUPDATE' => $user->format_date($row['session_time']),
|
2002-04-02 16:09:00 +00:00
|
|
|
'FORUM_LOCATION' => $location,
|
2001-04-19 14:17:56 +00:00
|
|
|
|
2002-08-13 16:34:17 +00:00
|
|
|
'S_ROW_COUNT' => $$which_counter,
|
2002-07-14 14:45:26 +00:00
|
|
|
|
|
|
|
'U_USER_PROFILE' => "profile.$phpEx$SID&mode=viewprofile&u=" . $user_id,
|
|
|
|
'U_FORUM_LOCATION' => $location_url)
|
2002-02-14 02:03:20 +00:00
|
|
|
);
|
2002-04-02 16:09:00 +00:00
|
|
|
|
|
|
|
$$which_counter++;
|
2002-02-14 02:03:20 +00:00
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 16:09:00 +00:00
|
|
|
if( $registered_users == 0 )
|
|
|
|
{
|
|
|
|
$l_r_user_s = $lang['Reg_users_zero_online'];
|
|
|
|
}
|
|
|
|
else if( $registered_users == 1 )
|
|
|
|
{
|
|
|
|
$l_r_user_s = $lang['Reg_user_online'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$l_r_user_s = $lang['Reg_users_online'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $hidden_users == 0 )
|
|
|
|
{
|
|
|
|
$l_h_user_s = $lang['Hidden_users_zero_online'];
|
|
|
|
}
|
|
|
|
else if( $hidden_users == 1 )
|
|
|
|
{
|
|
|
|
$l_h_user_s = $lang['Hidden_user_online'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$l_h_user_s = $lang['Hidden_users_online'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $guest_users == 0 )
|
|
|
|
{
|
|
|
|
$l_g_user_s = $lang['Guest_users_zero_online'];
|
|
|
|
}
|
|
|
|
else if( $guest_users == 1 )
|
|
|
|
{
|
|
|
|
$l_g_user_s = $lang['Guest_user_online'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$l_g_user_s = $lang['Guest_users_online'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2002-08-13 16:34:17 +00:00
|
|
|
'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $registered_users) . sprintf($l_h_user_s, $hidden_users),
|
2002-07-14 14:45:26 +00:00
|
|
|
'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users),
|
2002-04-02 16:09:00 +00:00
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
'L_WHOSONLINE' => $lang['Who_is_online'],
|
|
|
|
'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
|
|
|
|
'L_USERNAME' => $lang['Username'],
|
|
|
|
'L_FORUM_LOCATION' => $lang['Forum_Location'],
|
2002-08-13 16:34:17 +00:00
|
|
|
'L_LAST_UPDATE' => $lang['Last_updated'],
|
2002-07-14 14:45:26 +00:00
|
|
|
'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'],
|
|
|
|
'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
|
|
|
|
);
|
2002-04-02 16:09:00 +00:00
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
$page_title = $lang['Who_is_online'];
|
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
2002-04-02 16:09:00 +00:00
|
|
|
|
2002-07-14 14:45:26 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
'body' => 'viewonline_body.html')
|
|
|
|
);
|
|
|
|
make_jumpbox('viewforum.'.$phpEx);
|
2001-08-18 13:49:29 +00:00
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
2001-04-15 16:37:53 +00:00
|
|
|
|
2001-11-05 00:23:14 +00:00
|
|
|
?>
|