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-05-17 14:48:39 +00:00
|
|
|
//
|
|
|
|
// Output page header and load
|
|
|
|
// viewonline template
|
|
|
|
//
|
2001-04-15 16:37:53 +00:00
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
|
2001-05-17 14:48:39 +00:00
|
|
|
$template->set_filenames(array(
|
|
|
|
"body" => "viewonline_body.tpl",
|
|
|
|
"jumpbox" => "jumpbox.tpl")
|
|
|
|
);
|
|
|
|
$jumpbox = make_jumpbox();
|
|
|
|
$template->assign_vars(array(
|
|
|
|
"JUMPBOX_LIST" => $jumpbox,
|
|
|
|
"SELECT_NAME" => POST_FORUM_URL)
|
|
|
|
);
|
|
|
|
$template->assign_var_from_handle("JUMPBOX", "jumpbox");
|
|
|
|
//
|
|
|
|
// End header
|
|
|
|
//
|
|
|
|
|
2001-07-01 15:22:51 +00:00
|
|
|
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, 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
|
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);
|
2001-05-13 16:02:30 +00:00
|
|
|
$sql = "SELECT forum_name, forum_id
|
|
|
|
FROM ".FORUMS_TABLE;
|
|
|
|
$forums_result = $db->sql_query($sql);
|
|
|
|
if(!$forums_result)
|
|
|
|
{
|
|
|
|
error_die(SQL_QUERY, "Couldn't obtain user/online forums information.", __LINE__, __FILE__);
|
|
|
|
}
|
2001-05-13 20:31:37 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while($forumsrow = $db->sql_fetchrow($forums_result))
|
|
|
|
{
|
|
|
|
$forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name'];
|
|
|
|
}
|
|
|
|
}
|
2001-05-13 16:02:30 +00:00
|
|
|
|
2001-05-13 20:31:37 +00:00
|
|
|
if(!$onlinerow || !$forum_data)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-05-13 20:31:37 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't fetchrow.", __LINE__, __FILE__);
|
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'],
|
|
|
|
"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-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-13 17:13:10 +00:00
|
|
|
if(!($i % 2))
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-07-01 15:22:51 +00:00
|
|
|
$row_color = "#" . $theme['td_color1'];
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-01 15:22:51 +00:00
|
|
|
$row_color = "#" . $theme['td_color2'];
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-07-01 15:22:51 +00:00
|
|
|
if($onlinerow[$i]['user_id'] != ANONYMOUS)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
2001-04-19 14:46:11 +00:00
|
|
|
if($onlinerow[$i]['session_logged_in'])
|
|
|
|
{
|
2001-07-01 15:22:51 +00:00
|
|
|
if($onlinerow[$i]['user_allow_viewonline'])
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
$hidden = FALSE;
|
|
|
|
$logged_on = TRUE;
|
|
|
|
$active_users++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$username = $onlinerow[$i]['username'];
|
|
|
|
$hidden = TRUE;
|
|
|
|
$logged_on = TRUE;
|
|
|
|
$hidden_users++;
|
|
|
|
}
|
2001-04-19 14:46:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-01 15:22:51 +00:00
|
|
|
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++;
|
|
|
|
}
|
2001-04-19 14:46:11 +00:00
|
|
|
}
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-01 15:22:51 +00:00
|
|
|
$username = $lang['Anonymous'];
|
|
|
|
$hidden = FALSE;
|
2001-04-19 14:46:11 +00:00
|
|
|
$logged_on = FALSE;
|
2001-04-19 14:17:56 +00:00
|
|
|
$guest_users++;
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
2001-05-13 20:31:37 +00:00
|
|
|
if($onlinerow[$i]['session_page'] < 1)
|
2001-04-15 16:37:53 +00:00
|
|
|
{
|
|
|
|
switch($onlinerow[$i]['session_page'])
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
case PAGE_LOGIN:
|
2001-07-01 15:22:51 +00:00
|
|
|
$location = $lang['Loggin_on'];
|
|
|
|
$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-07-01 15:22:51 +00:00
|
|
|
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $onlinerow[$i]['session_page']);
|
2001-05-13 20:31:37 +00:00
|
|
|
$location = $forum_data[$onlinerow[$i]['session_page']];
|
2001-04-15 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
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 ...
|
|
|
|
//
|
2001-07-01 15:22:51 +00:00
|
|
|
if( $logged_on && ( !$hidden || $userdata['user_level'] == ADMIN ) )
|
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-07-01 15:22:51 +00:00
|
|
|
"U_USER_PROFILE" => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $onlinerow[$i]['user_id']),
|
2001-05-06 16:16:22 +00:00
|
|
|
"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-07-01 15:22:51 +00:00
|
|
|
"ACTIVE_USERS" => $active_users,
|
|
|
|
"HIDDEN_USERS" => $hidden_users,
|
2001-04-19 14:24:58 +00:00
|
|
|
"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);
|
|
|
|
|
2001-07-01 15:22:51 +00:00
|
|
|
?>
|