2001-04-15 16:37:53 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
2001-08-26 13:53:41 +00:00
|
|
|
* viewonline.php
|
2001-04-15 16:37:53 +00:00
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2001-07-13 16:14:37 +00:00
|
|
|
$phpbb_root_path = "./";
|
|
|
|
include($phpbb_root_path . 'extension.inc');
|
|
|
|
include($phpbb_root_path . 'common.'.$phpEx);
|
2001-04-15 16:37:53 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
|
|
|
$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE, $session_length);
|
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
2001-05-17 14:48:39 +00:00
|
|
|
//
|
|
|
|
// Output page header and load
|
|
|
|
// viewonline template
|
|
|
|
//
|
2001-08-18 13:49:29 +00:00
|
|
|
$page_title = $lang['Who_is_online'];
|
2001-07-13 16:14:37 +00:00
|
|
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
2001-04-15 16:37:53 +00:00
|
|
|
|
2001-05-17 14:48:39 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "viewonline_body.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
2001-07-13 16:14:37 +00:00
|
|
|
|
2001-05-17 14:48:39 +00:00
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
2001-07-31 22:30:41 +00:00
|
|
|
"L_GO" => $lang['Go'],
|
|
|
|
"L_JUMP_TO" => $lang['Jump_to'],
|
|
|
|
"L_SELECT_FORUM" => $lang['Select_forum'],
|
2001-05-17 14:48:39 +00:00
|
|
|
"JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"SELECT_NAME" => POST_FORUM_URL)
|
|
|
|
);
|
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
|
|
|
//
|
|
|
|
// End header
|
|
|
|
//
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, s.session_page, s.session_logged_in, s.session_time
|
2001-07-13 16:14:37 +00:00
|
|
|
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s
|
2001-08-18 13:49:29 +00:00
|
|
|
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 . "
|
2001-04-16 00:02:06 +00:00
|
|
|
ORDER BY s.session_time DESC";
|
2001-07-13 16:14:37 +00:00
|
|
|
if(!$result = $db->sql_query($sql))
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql);
|
|
|
|
}
|
|
|
|
$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);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
2001-08-18 13:49:29 +00:00
|
|
|
$onlinerow_guest = $db->sql_fetchrowset($result);
|
2001-07-13 16:14:37 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$sql = "SELECT forum_name, forum_id
|
2001-07-16 21:12:09 +00:00
|
|
|
FROM " . FORUMS_TABLE;
|
2001-07-13 16:14:37 +00:00
|
|
|
if($forums_result = $db->sql_query($sql))
|
2001-05-13 20:31:37 +00:00
|
|
|
{
|
|
|
|
while($forumsrow = $db->sql_fetchrow($forums_result))
|
|
|
|
{
|
|
|
|
$forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name'];
|
|
|
|
}
|
|
|
|
}
|
2001-07-13 16:14:37 +00:00
|
|
|
else
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-07-13 16:14:37 +00:00
|
|
|
message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2001-07-01 15:22:51 +00:00
|
|
|
"L_WHOSONLINE" => $lang['Who_is_online'],
|
2001-07-31 22:30:41 +00:00
|
|
|
"L_ONLINE_EXPLAIN" => $lang['Online_explain'],
|
2001-07-01 15:22:51 +00:00
|
|
|
"L_USERNAME" => $lang['Username'],
|
|
|
|
"L_LOCATION" => $lang['Location'],
|
|
|
|
"L_LAST_UPDATE" => $lang['Last_updated'])
|
2001-04-15 16:37:53 +00:00
|
|
|
);
|
|
|
|
|
2001-04-19 14:17:56 +00:00
|
|
|
$active_users = 0;
|
|
|
|
$guest_users = 0;
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
//
|
|
|
|
// Registered users ...
|
|
|
|
//
|
|
|
|
if( count($onlinerow_reg) )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
$registered_users = 0;
|
|
|
|
$hidden_users = 0;
|
|
|
|
|
|
|
|
$displayed_userid_list = "";
|
2001-07-19 00:57:12 +00:00
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
for($i = 0; $i < count($onlinerow_reg); $i++)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
if( !eregi("," . $onlinerow_reg[$i]['user_id'], $displayed_userid_list) )
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-08-26 13:53:41 +00:00
|
|
|
if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
|
2001-04-19 14:46:11 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
|
|
|
|
|
|
|
|
$username = $onlinerow_reg[$i]['username'];
|
|
|
|
$hidden = FALSE;
|
|
|
|
$registered_users++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$displayed_userid_list .= "," . $onlinerow_reg[$i]['user_id'];
|
|
|
|
|
|
|
|
$username = $onlinerow_reg[$i]['username'];
|
|
|
|
$hidden = TRUE;
|
|
|
|
$hidden_users++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($onlinerow_reg[$i]['session_page'] < 1)
|
|
|
|
{
|
|
|
|
switch($onlinerow_reg[$i]['session_page'])
|
2001-07-01 15:22:51 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
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";
|
2001-07-01 15:22:51 +00:00
|
|
|
}
|
2001-04-19 14:46:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['session_page']);
|
|
|
|
$location = $forum_data[$onlinerow_reg[$i]['session_page']];
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !$hidden || $userdata['user_level'] == ADMIN )
|
|
|
|
{
|
|
|
|
$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("reg_user_row", array(
|
|
|
|
"ROW_COLOR" => "#" . $row_color,
|
|
|
|
"ROW_CLASS" => $row_class,
|
|
|
|
"USERNAME" => $username,
|
|
|
|
"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&" . POST_USERS_URL . "=" . $onlinerow_reg[$i]['user_id']),
|
|
|
|
"U_FORUM_LOCATION" => append_sid($location_url))
|
|
|
|
);
|
2001-04-19 14:46:11 +00:00
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
2001-08-18 13:49:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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(
|
|
|
|
"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'])
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$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++;
|
2001-04-15 16:37:53 +00:00
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
if($onlinerow_guest[$i]['session_page'] < 1)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
switch($onlinerow_guest[$i]['session_page'])
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
|
|
|
case PAGE_INDEX:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Forum_index'];
|
|
|
|
$location_url = "index.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
2001-07-13 16:14:37 +00:00
|
|
|
case PAGE_POSTING:
|
2001-07-18 17:15:02 +00:00
|
|
|
$location = $lang['Posting_message'];
|
2001-07-16 21:12:09 +00:00
|
|
|
$location_url = "index.$phpEx";
|
2001-07-13 16:14:37 +00:00
|
|
|
break;
|
2001-04-15 16:37:53 +00:00
|
|
|
case PAGE_LOGIN:
|
2001-07-16 21:12:09 +00:00
|
|
|
$location = $lang['Logging_on'];
|
2001-07-01 15:22:51 +00:00
|
|
|
$location_url = "index.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_SEARCH:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Searching_forums'];
|
|
|
|
$location_url = "search.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
2001-07-01 15:36:55 +00:00
|
|
|
case PAGE_PROFILE:
|
|
|
|
$location = $lang['Viewing_profile'];
|
2001-07-01 15:22:51 +00:00
|
|
|
$location_url = "index.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_VIEWONLINE:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Viewing_online'];
|
|
|
|
$location_url = "viewonline.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_VIEWMEMBERS:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Viewing_member_list'];
|
|
|
|
$location_url = "memberlist.$phpEx";
|
|
|
|
break;
|
|
|
|
case PAGE_PRIVMSGS:
|
|
|
|
$location = $lang['Viewing_priv_msgs'];
|
|
|
|
$location_url = "privmsg.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_FAQ:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Viewing_FAQ'];
|
|
|
|
$location_url = "faq.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Forum_index'];
|
|
|
|
$location_url = "index.$phpEx";
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']);
|
|
|
|
$location = $forum_data[$onlinerow_guest[$i]['session_page']];
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
$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))
|
|
|
|
);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
$l_g_user_s = ($guest_users == 1) ? $lang['User'] : $lang['Users'];
|
|
|
|
$l_is_are = ($guest_users == 1) ? $lang['is'] : $lang['are'];
|
|
|
|
|
2001-04-19 14:17:56 +00:00
|
|
|
$template->assign_vars(array(
|
2001-08-18 13:49:29 +00:00
|
|
|
"TOTAL_GUEST_USERS_ONLINE" => $lang['There'] . " $l_is_are $guests_online " . $lang['Guest'] . " $l_g_user_s " . $lang['online'])
|
2001-04-19 14:17:56 +00:00
|
|
|
);
|
|
|
|
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-18 13:49:29 +00:00
|
|
|
$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'])
|
|
|
|
);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-08-18 13:49:29 +00:00
|
|
|
$template->pparse("body");
|
|
|
|
|
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-07-01 15:22:51 +00:00
|
|
|
?>
|