2001-04-15 16:37:53 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
2001-04-15 17:32:12 +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$
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
include('extension.inc');
|
|
|
|
include('common.'.$phpEx);
|
|
|
|
|
|
|
|
$pagetype = "viewonline";
|
|
|
|
$page_title = "Who's Online";
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
|
|
|
$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE, $session_length);
|
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
2001-04-19 15:05:39 +00:00
|
|
|
$total_posts = get_db_stat('postcount');
|
|
|
|
$total_users = get_db_stat('usercount');
|
|
|
|
$newest_userdata = get_db_stat('newestuser');
|
2001-04-15 16:37:53 +00:00
|
|
|
$newest_user = $newest_userdata["username"];
|
|
|
|
$newest_uid = $newest_userdata["user_id"];
|
|
|
|
|
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
|
2001-04-16 00:02:06 +00:00
|
|
|
$sql = "SELECT u.username, u.user_id, f.forum_name, f.forum_id, s.session_page, s.session_logged_in, s.session_time
|
2001-04-15 16:37:53 +00:00
|
|
|
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
|
|
|
|
LEFT JOIN ".FORUMS_TABLE." f ON f.forum_id = s.session_page
|
2001-04-16 00:02:06 +00:00
|
|
|
WHERE u.user_id = s.session_user_id
|
2001-04-19 14:17:56 +00:00
|
|
|
AND s.session_time >= ".(time()-300)."
|
2001-04-16 00:02:06 +00:00
|
|
|
ORDER BY s.session_time DESC";
|
2001-04-15 16:37:53 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
if(!$result)
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't obtain user/online information.", __LINE__, __FILE__);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
$onlinerow = $db->sql_fetchrowset($result);
|
|
|
|
if(!$onlinerow)
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't fetchrow", __LINE__, __FILE__);
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"L_WHOSONLINE" => $l_whosonline,
|
|
|
|
"L_USERNAME" => $l_username,
|
2001-04-19 14:17:56 +00:00
|
|
|
"L_LOCATION" => $l_forum_location,
|
|
|
|
"L_LAST_UPDATE" => $l_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-04-15 16:37:53 +00:00
|
|
|
$online_count = $db->sql_numrows($result);
|
|
|
|
if($online_count)
|
|
|
|
{
|
2001-04-15 19:35:52 +00:00
|
|
|
for($i = 0; $i < $online_count; $i++)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
|
|
|
|
2001-05-04 00:35:31 +00:00
|
|
|
if(!(ix % 2))
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-05-04 00:35:31 +00:00
|
|
|
if(isset($theme['td_color1']))
|
|
|
|
{
|
|
|
|
$row_color = "#".$theme['td_color1'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$row_color = "#DDDDDD";
|
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-04 00:35:31 +00:00
|
|
|
if(isset($theme['td_color2']))
|
|
|
|
{
|
|
|
|
$row_color = "#".$theme['td_color2'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$row_color = "#CCCCCC";
|
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-04-19 14:46:11 +00:00
|
|
|
if($onlinerow[$i]['user_id'] != ANONYMOUS && $onlinerow[$i]['user_id'] != DELETED)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-04-19 14:46:11 +00:00
|
|
|
if($onlinerow[$i]['session_logged_in'])
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
$logged_on = TRUE;
|
|
|
|
$active_users++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
$logged_on = FALSE;
|
|
|
|
$guest_users++;
|
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-19 14:46:11 +00:00
|
|
|
$username = $l_anonymous;
|
|
|
|
$logged_on = FALSE;
|
2001-04-19 14:17:56 +00:00
|
|
|
$guest_users++;
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-04-19 14:46:11 +00:00
|
|
|
if($onlinerow[$i]['forum_name'] == "")
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
|
|
|
switch($onlinerow[$i]['session_page'])
|
|
|
|
{
|
|
|
|
case PAGE_INDEX:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_forum_index;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_LOGIN:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_logging_on;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_SEARCH:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_searching;
|
|
|
|
$location_url = "search.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_REGISTER:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_registering;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_VIEWPROFILE:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_viewing_profiles;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_ALTERPROFILE:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_altering_profile;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_VIEWONLINE:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_viewing_online;
|
|
|
|
$location_url = "viewonline.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_VIEWMEMBERS:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_viewing_members;
|
|
|
|
$location_url = "memberlist.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case PAGE_FAQ:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_viewing_faq;
|
|
|
|
$location_url = "faq.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-04-19 14:17:56 +00:00
|
|
|
$location = $l_forum_index;
|
|
|
|
$location_url = "index.".$phpEx;
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-06 16:16:22 +00:00
|
|
|
$location_url = append_sid("viewforum.".$phpEx."?".POST_FORUM_URL."=".$onlinerow[$i]['forum_id']);
|
2001-04-15 16:37:53 +00:00
|
|
|
$location = $onlinerow[$i]['forum_name'];
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:46:11 +00:00
|
|
|
//
|
|
|
|
// What would be nice here is to let
|
|
|
|
// the template designer decide whether
|
|
|
|
// to display all users, registered users
|
|
|
|
// or just logged in users ... but we need
|
|
|
|
// if... constructs in the templating system
|
|
|
|
// for that ...
|
|
|
|
//
|
|
|
|
if($logged_on)
|
2001-04-19 14:17:56 +00:00
|
|
|
{
|
|
|
|
$template->assign_block_vars("userrow",
|
2001-04-19 21:17:16 +00:00
|
|
|
array(
|
|
|
|
"ROW_COLOR" => $row_color,
|
2001-04-19 14:17:56 +00:00
|
|
|
"USERNAME" => $username,
|
2001-04-19 14:46:11 +00:00
|
|
|
"LOGGED_ON" => $logged_on,
|
2001-05-04 00:35:31 +00:00
|
|
|
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow[$i]['session_time'], $board_config['default__timezone']),
|
2001-04-19 14:17:56 +00:00
|
|
|
"LOCATION" => $location,
|
2001-05-06 16:16:22 +00:00
|
|
|
"U_USER_PROFILE" => append_sid("profile.".$phpEx."?mode=viewprofile&".POST_USERS_URL."=".$onlinerow[$i]['user_id']),
|
|
|
|
"U_FORUM_LOCATION" => append_sid($location_url)
|
2001-04-19 14:17:56 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:17:56 +00:00
|
|
|
$template->assign_vars(array(
|
2001-04-19 14:24:58 +00:00
|
|
|
"ACTIVE_USERS" => $active_users,
|
|
|
|
"GUEST_USERS" => $guest_users
|
2001-04-19 14:17:56 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2001-04-15 16:37:53 +00:00
|
|
|
$template->pparse("body");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(GENERAL_ERROR, "There are no users currently browsing this forum");
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
include('includes/page_tail.'.$phpEx);
|
|
|
|
|
|
|
|
?>
|