root / trunk / phpBB / viewonline.php
History | View | Annotate | Download (13.2 kB)
| 1 | 146 | psotfx | <?php
|
|---|---|---|---|
| 2 | 8146 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package phpBB3 |
| 5 | 8146 | acydburn | * @copyright (c) 2005 phpBB Group |
| 6 | 11653 | git-gate | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
| 7 | 5114 | acydburn | * |
| 8 | 5114 | acydburn | */ |
| 9 | 146 | psotfx | |
| 10 | 5114 | acydburn | /**
|
| 11 | 5883 | acydburn | * @ignore |
| 12 | 5114 | acydburn | */ |
| 13 | 2305 | psotfx | define('IN_PHPBB', true); |
| 14 | 7954 | acydburn | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 15 | 4441 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | 6015 | acydburn | include($phpbb_root_path . 'common.' . $phpEx); |
| 17 | 146 | psotfx | |
| 18 | 146 | psotfx | // Start session management
|
| 19 | 5247 | acydburn | $user->session_begin();
|
| 20 | 2958 | psotfx | $auth->acl($user->data); |
| 21 | 8033 | acydburn | $user->setup('memberlist'); |
| 22 | 3969 | psotfx | |
| 23 | 4259 | psotfx | // Get and set some variables
|
| 24 | 4742 | psotfx | $mode = request_var('mode', ''); |
| 25 | 4743 | psotfx | $session_id = request_var('s', ''); |
| 26 | 4742 | psotfx | $start = request_var('start', 0); |
| 27 | 4742 | psotfx | $sort_key = request_var('sk', 'b'); |
| 28 | 4742 | psotfx | $sort_dir = request_var('sd', 'd'); |
| 29 | 5091 | acydburn | $show_guests= ($config['load_online_guests']) ? request_var('sg', 0) : 0; |
| 30 | 4433 | psotfx | |
| 31 | 7889 | acydburn | // Can this user view profiles/memberlist?
|
| 32 | 7889 | acydburn | if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) |
| 33 | 7889 | acydburn | {
|
| 34 | 7889 | acydburn | if ($user->data['user_id'] != ANONYMOUS) |
| 35 | 7889 | acydburn | {
|
| 36 | 7889 | acydburn | trigger_error('NO_VIEW_USERS'); |
| 37 | 7889 | acydburn | } |
| 38 | 7889 | acydburn | |
| 39 | 7889 | acydburn | login_box('', $user->lang['LOGIN_EXPLAIN_VIEWONLINE']); |
| 40 | 7889 | acydburn | } |
| 41 | 7889 | acydburn | |
| 42 | 7987 | acydburn | $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_JOINED'], 'c' => $user->lang['SORT_LOCATION']); |
| 43 | 6650 | acydburn | $sort_key_sql = array('a' => 'u.username_clean', 'b' => 's.session_time', 'c' => 's.session_page'); |
| 44 | 4237 | psotfx | |
| 45 | 4237 | psotfx | // Sorting and order
|
| 46 | 6538 | acydburn | if (!isset($sort_key_text[$sort_key])) |
| 47 | 6538 | acydburn | {
|
| 48 | 6538 | acydburn | $sort_key = 'b'; |
| 49 | 6538 | acydburn | } |
| 50 | 6538 | acydburn | |
| 51 | 4441 | psotfx | $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); |
| 52 | 4237 | psotfx | |
| 53 | 4742 | psotfx | // Whois requested
|
| 54 | 8095 | acydburn | if ($mode == 'whois' && $auth->acl_get('a_') && $session_id) |
| 55 | 4742 | psotfx | {
|
| 56 | 5091 | acydburn | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 57 | 4237 | psotfx | |
| 58 | 4742 | psotfx | $sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip |
| 59 | 5091 | acydburn | FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s |
| 60 | 5091 | acydburn | WHERE s.session_id = '" . $db->sql_escape($session_id) . "' |
| 61 | 5091 | acydburn | AND u.user_id = s.session_user_id";
|
| 62 | 4742 | psotfx | $result = $db->sql_query($sql); |
| 63 | 4742 | psotfx | |
| 64 | 4742 | psotfx | if ($row = $db->sql_fetchrow($result)) |
| 65 | 4742 | psotfx | {
|
| 66 | 8095 | acydburn | $template->assign_var('WHOIS', user_ipwhois($row['session_ip'])); |
| 67 | 4742 | psotfx | } |
| 68 | 4742 | psotfx | $db->sql_freeresult($result); |
| 69 | 4742 | psotfx | |
| 70 | 4742 | psotfx | // Output the page
|
| 71 | 4742 | psotfx | page_header($user->lang['WHO_IS_ONLINE']); |
| 72 | 4742 | psotfx | |
| 73 | 4742 | psotfx | $template->set_filenames(array( |
| 74 | 4742 | psotfx | 'body' => 'viewonline_whois.html') |
| 75 | 4742 | psotfx | ); |
| 76 | 6015 | acydburn | make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
| 77 | 4742 | psotfx | |
| 78 | 4742 | psotfx | page_footer(); |
| 79 | 4742 | psotfx | } |
| 80 | 4742 | psotfx | |
| 81 | 2137 | psotfx | // Forum info
|
| 82 | 4441 | psotfx | $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id |
| 83 | 4441 | psotfx | FROM ' . FORUMS_TABLE . ' |
| 84 | 4441 | psotfx | ORDER BY left_id ASC';
|
| 85 | 4441 | psotfx | $result = $db->sql_query($sql, 600); |
| 86 | 2673 | psotfx | |
| 87 | 7987 | acydburn | $forum_data = array(); |
| 88 | 3346 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 89 | 146 | psotfx | {
|
| 90 | 6829 | acydburn | $forum_data[$row['forum_id']] = $row; |
| 91 | 290 | psotfx | } |
| 92 | 3969 | psotfx | $db->sql_freeresult($result); |
| 93 | 146 | psotfx | |
| 94 | 5091 | acydburn | $guest_counter = 0; |
| 95 | 3969 | psotfx | |
| 96 | 5091 | acydburn | // Get number of online guests (if we do not display them)
|
| 97 | 5091 | acydburn | if (!$show_guests) |
| 98 | 5091 | acydburn | {
|
| 99 | 6497 | acydburn | switch ($db->sql_layer) |
| 100 | 6090 | davidmj | {
|
| 101 | 6090 | davidmj | case 'sqlite': |
| 102 | 6090 | davidmj | $sql = 'SELECT COUNT(session_ip) as num_guests |
| 103 | 6090 | davidmj | FROM ( |
| 104 | 6090 | davidmj | SELECT DISTINCT session_ip |
| 105 | 6090 | davidmj | FROM ' . SESSIONS_TABLE . ' |
| 106 | 6090 | davidmj | WHERE session_user_id = ' . ANONYMOUS . ' |
| 107 | 6090 | davidmj | AND session_time >= ' . (time() - ($config['load_online_time'] * 60)) . |
| 108 | 8146 | acydburn | ')';
|
| 109 | 6090 | davidmj | break;
|
| 110 | 6090 | davidmj | |
| 111 | 6090 | davidmj | default:
|
| 112 | 6090 | davidmj | $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests |
| 113 | 6090 | davidmj | FROM ' . SESSIONS_TABLE . ' |
| 114 | 6090 | davidmj | WHERE session_user_id = ' . ANONYMOUS . ' |
| 115 | 6090 | davidmj | AND session_time >= ' . (time() - ($config['load_online_time'] * 60)); |
| 116 | 6497 | acydburn | break;
|
| 117 | 6090 | davidmj | } |
| 118 | 5091 | acydburn | $result = $db->sql_query($sql); |
| 119 | 5699 | acydburn | $guest_counter = (int) $db->sql_fetchfield('num_guests'); |
| 120 | 5091 | acydburn | $db->sql_freeresult($result); |
| 121 | 5091 | acydburn | } |
| 122 | 5091 | acydburn | |
| 123 | 2137 | psotfx | // Get user list
|
| 124 | 8438 | acydburn | $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id |
| 125 | 3969 | psotfx | FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s |
| 126 | 2448 | psotfx | WHERE u.user_id = s.session_user_id |
| 127 | 8146 | acydburn | AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) . |
| 128 | 5091 | acydburn | ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . ' |
| 129 | 4237 | psotfx | ORDER BY ' . $order_by; |
| 130 | 2673 | psotfx | $result = $db->sql_query($sql); |
| 131 | 1260 | psotfx | |
| 132 | 5091 | acydburn | $prev_id = $prev_ip = $user_list = array(); |
| 133 | 5091 | acydburn | $logged_visible_online = $logged_hidden_online = $counter = 0; |
| 134 | 5091 | acydburn | |
| 135 | 3346 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 136 | 2465 | psotfx | {
|
| 137 | 5091 | acydburn | if ($row['user_id'] != ANONYMOUS && !isset($prev_id[$row['user_id']])) |
| 138 | 146 | psotfx | {
|
| 139 | 7889 | acydburn | $view_online = $s_user_hidden = false; |
| 140 | 7889 | acydburn | $user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] . '" class="username-coloured"' : ''; |
| 141 | 9428 | acydburn | |
| 142 | 7889 | acydburn | $username_full = ($row['user_type'] != USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '<span' . $user_colour . '>' . $row['username'] . '</span>'; |
| 143 | 6015 | acydburn | |
| 144 | 7755 | kellanved | if (!$row['session_viewonline']) |
| 145 | 4441 | psotfx | {
|
| 146 | 4978 | acydburn | $view_online = ($auth->acl_get('u_viewonline')) ? true : false; |
| 147 | 4441 | psotfx | $logged_hidden_online++;
|
| 148 | 2690 | psotfx | |
| 149 | 7889 | acydburn | $username_full = '<em>' . $username_full . '</em>'; |
| 150 | 7889 | acydburn | $s_user_hidden = true; |
| 151 | 146 | psotfx | } |
| 152 | 4441 | psotfx | else
|
| 153 | 2137 | psotfx | {
|
| 154 | 2473 | psotfx | $view_online = true; |
| 155 | 4441 | psotfx | $logged_visible_online++;
|
| 156 | 2137 | psotfx | } |
| 157 | 4441 | psotfx | |
| 158 | 5091 | acydburn | $prev_id[$row['user_id']] = 1; |
| 159 | 5091 | acydburn | |
| 160 | 5091 | acydburn | if ($view_online) |
| 161 | 5091 | acydburn | {
|
| 162 | 5091 | acydburn | $counter++;
|
| 163 | 5091 | acydburn | } |
| 164 | 5091 | acydburn | |
| 165 | 5091 | acydburn | if (!$view_online || $counter > $start + $config['topics_per_page'] || $counter <= $start) |
| 166 | 5091 | acydburn | {
|
| 167 | 5091 | acydburn | continue;
|
| 168 | 5091 | acydburn | } |
| 169 | 2465 | psotfx | } |
| 170 | 5091 | acydburn | else if ($show_guests && $row['user_id'] == ANONYMOUS && !isset($prev_ip[$row['session_ip']])) |
| 171 | 4441 | psotfx | {
|
| 172 | 5091 | acydburn | $prev_ip[$row['session_ip']] = 1; |
| 173 | 5091 | acydburn | $guest_counter++;
|
| 174 | 5091 | acydburn | $counter++;
|
| 175 | 1616 | psotfx | |
| 176 | 5091 | acydburn | if ($counter > $start + $config['topics_per_page'] || $counter <= $start) |
| 177 | 5091 | acydburn | {
|
| 178 | 5091 | acydburn | continue;
|
| 179 | 5091 | acydburn | } |
| 180 | 5091 | acydburn | |
| 181 | 7889 | acydburn | $s_user_hidden = false; |
| 182 | 7889 | acydburn | $username_full = get_username_string('full', $row['user_id'], $user->lang['GUEST']); |
| 183 | 4441 | psotfx | } |
| 184 | 5091 | acydburn | else
|
| 185 | 5091 | acydburn | {
|
| 186 | 5091 | acydburn | continue;
|
| 187 | 5091 | acydburn | } |
| 188 | 2451 | psotfx | |
| 189 | 9566 | bantu | preg_match('#^([a-z0-9/_-]+)#i', $row['session_page'], $on_page); |
| 190 | 5091 | acydburn | if (!sizeof($on_page)) |
| 191 | 5091 | acydburn | {
|
| 192 | 5091 | acydburn | $on_page[1] = ''; |
| 193 | 5091 | acydburn | } |
| 194 | 4441 | psotfx | |
| 195 | 5091 | acydburn | switch ($on_page[1]) |
| 196 | 2465 | psotfx | {
|
| 197 | 5091 | acydburn | case 'index': |
| 198 | 5091 | acydburn | $location = $user->lang['INDEX']; |
| 199 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 200 | 5595 | acydburn | break;
|
| 201 | 4743 | psotfx | |
| 202 | 5595 | acydburn | case 'adm/index': |
| 203 | 5595 | acydburn | $location = $user->lang['ACP']; |
| 204 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 205 | 5595 | acydburn | break;
|
| 206 | 5595 | acydburn | |
| 207 | 5091 | acydburn | case 'posting': |
| 208 | 5091 | acydburn | case 'viewforum': |
| 209 | 5091 | acydburn | case 'viewtopic': |
| 210 | 8438 | acydburn | $forum_id = $row['session_forum_id']; |
| 211 | 2673 | psotfx | |
| 212 | 5595 | acydburn | if ($forum_id && $auth->acl_get('f_list', $forum_id)) |
| 213 | 5091 | acydburn | {
|
| 214 | 5091 | acydburn | $location = ''; |
| 215 | 6829 | acydburn | $location_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id); |
| 216 | 6829 | acydburn | |
| 217 | 6829 | acydburn | if ($forum_data[$forum_id]['forum_type'] == FORUM_LINK) |
| 218 | 6829 | acydburn | {
|
| 219 | 6829 | acydburn | $location = sprintf($user->lang['READING_LINK'], $forum_data[$forum_id]['forum_name']); |
| 220 | 6829 | acydburn | break;
|
| 221 | 6829 | acydburn | } |
| 222 | 6829 | acydburn | |
| 223 | 5091 | acydburn | switch ($on_page[1]) |
| 224 | 2673 | psotfx | {
|
| 225 | 5091 | acydburn | case 'posting': |
| 226 | 5091 | acydburn | preg_match('#mode=([a-z]+)#', $row['session_page'], $on_page); |
| 227 | 8677 | acydburn | $posting_mode = (!empty($on_page[1])) ? $on_page[1] : ''; |
| 228 | 4970 | psotfx | |
| 229 | 8677 | acydburn | switch ($posting_mode) |
| 230 | 5091 | acydburn | {
|
| 231 | 5091 | acydburn | case 'reply': |
| 232 | 6838 | acydburn | case 'quote': |
| 233 | 6838 | acydburn | $location = sprintf($user->lang['REPLYING_MESSAGE'], $forum_data[$forum_id]['forum_name']); |
| 234 | 5595 | acydburn | break;
|
| 235 | 5595 | acydburn | |
| 236 | 5091 | acydburn | default:
|
| 237 | 6838 | acydburn | $location = sprintf($user->lang['POSTING_MESSAGE'], $forum_data[$forum_id]['forum_name']); |
| 238 | 5595 | acydburn | break;
|
| 239 | 5091 | acydburn | } |
| 240 | 5595 | acydburn | break;
|
| 241 | 3551 | psotfx | |
| 242 | 5091 | acydburn | case 'viewtopic': |
| 243 | 6838 | acydburn | $location = sprintf($user->lang['READING_TOPIC'], $forum_data[$forum_id]['forum_name']); |
| 244 | 5595 | acydburn | break;
|
| 245 | 8120 | kellanved | |
| 246 | 5091 | acydburn | case 'viewforum': |
| 247 | 6838 | acydburn | $location = sprintf($user->lang['READING_FORUM'], $forum_data[$forum_id]['forum_name']); |
| 248 | 5595 | acydburn | break;
|
| 249 | 2673 | psotfx | } |
| 250 | 5091 | acydburn | } |
| 251 | 5091 | acydburn | else
|
| 252 | 5091 | acydburn | {
|
| 253 | 5091 | acydburn | $location = $user->lang['INDEX']; |
| 254 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 255 | 5091 | acydburn | } |
| 256 | 5595 | acydburn | break;
|
| 257 | 698 | psotfx | |
| 258 | 5091 | acydburn | case 'search': |
| 259 | 5091 | acydburn | $location = $user->lang['SEARCHING_FORUMS']; |
| 260 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}search.$phpEx"); |
| 261 | 5595 | acydburn | break;
|
| 262 | 2673 | psotfx | |
| 263 | 5091 | acydburn | case 'faq': |
| 264 | 5091 | acydburn | $location = $user->lang['VIEWING_FAQ']; |
| 265 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}faq.$phpEx"); |
| 266 | 5595 | acydburn | break;
|
| 267 | 2673 | psotfx | |
| 268 | 5091 | acydburn | case 'viewonline': |
| 269 | 5091 | acydburn | $location = $user->lang['VIEWING_ONLINE']; |
| 270 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}viewonline.$phpEx"); |
| 271 | 5595 | acydburn | break;
|
| 272 | 2673 | psotfx | |
| 273 | 5091 | acydburn | case 'memberlist': |
| 274 | 5904 | naderman | $location = (strpos($row['session_page'], 'mode=viewprofile') !== false) ? $user->lang['VIEWING_MEMBER_PROFILE'] : $user->lang['VIEWING_MEMBERS']; |
| 275 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}memberlist.$phpEx"); |
| 276 | 5595 | acydburn | break;
|
| 277 | 4644 | psotfx | |
| 278 | 5595 | acydburn | case 'mcp': |
| 279 | 6829 | acydburn | $location = $user->lang['VIEWING_MCP']; |
| 280 | 6829 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 281 | 6829 | acydburn | break;
|
| 282 | 6829 | acydburn | |
| 283 | 5091 | acydburn | case 'ucp': |
| 284 | 5091 | acydburn | $location = $user->lang['VIEWING_UCP']; |
| 285 | 2673 | psotfx | |
| 286 | 6829 | acydburn | // Grab some common modules
|
| 287 | 6829 | acydburn | $url_params = array( |
| 288 | 6829 | acydburn | 'mode=register' => 'VIEWING_REGISTER', |
| 289 | 6829 | acydburn | 'i=pm&mode=compose' => 'POSTING_PRIVATE_MESSAGE', |
| 290 | 6829 | acydburn | 'i=pm&' => 'VIEWING_PRIVATE_MESSAGES', |
| 291 | 6829 | acydburn | 'i=profile&' => 'CHANGING_PROFILE', |
| 292 | 6829 | acydburn | 'i=prefs&' => 'CHANGING_PREFERENCES', |
| 293 | 6829 | acydburn | ); |
| 294 | 6829 | acydburn | |
| 295 | 6829 | acydburn | foreach ($url_params as $param => $lang) |
| 296 | 5595 | acydburn | {
|
| 297 | 6829 | acydburn | if (strpos($row['session_page'], $param) !== false) |
| 298 | 6829 | acydburn | {
|
| 299 | 6829 | acydburn | $location = $user->lang[$lang]; |
| 300 | 6829 | acydburn | break;
|
| 301 | 6829 | acydburn | } |
| 302 | 6829 | acydburn | } |
| 303 | 5595 | acydburn | |
| 304 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 305 | 5595 | acydburn | break;
|
| 306 | 5595 | acydburn | |
| 307 | 8705 | Kellanved | case 'download/file': |
| 308 | 5595 | acydburn | $location = $user->lang['DOWNLOADING_FILE']; |
| 309 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 310 | 5595 | acydburn | break;
|
| 311 | 5595 | acydburn | |
| 312 | 5595 | acydburn | case 'report': |
| 313 | 5595 | acydburn | $location = $user->lang['REPORTING_POST']; |
| 314 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 315 | 5595 | acydburn | break;
|
| 316 | 5595 | acydburn | |
| 317 | 5091 | acydburn | default:
|
| 318 | 5091 | acydburn | $location = $user->lang['INDEX']; |
| 319 | 6015 | acydburn | $location_url = append_sid("{$phpbb_root_path}index.$phpEx"); |
| 320 | 5595 | acydburn | break;
|
| 321 | 5091 | acydburn | } |
| 322 | 646 | psotfx | |
| 323 | 5091 | acydburn | $template->assign_block_vars('user_row', array( |
| 324 | 5595 | acydburn | 'USERNAME' => $row['username'], |
| 325 | 7889 | acydburn | 'USERNAME_COLOUR' => $row['user_colour'], |
| 326 | 7889 | acydburn | 'USERNAME_FULL' => $username_full, |
| 327 | 5595 | acydburn | 'LASTUPDATE' => $user->format_date($row['session_time']), |
| 328 | 5595 | acydburn | 'FORUM_LOCATION' => $location, |
| 329 | 5595 | acydburn | 'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '', |
| 330 | 7889 | acydburn | 'USER_BROWSER' => ($auth->acl_get('a_user')) ? $row['session_browser'] : '', |
| 331 | 2137 | psotfx | |
| 332 | 7889 | acydburn | 'U_USER_PROFILE' => ($row['user_type'] != USER_IGNORE) ? get_username_string('profile', $row['user_id'], '') : '', |
| 333 | 6015 | acydburn | 'U_USER_IP' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=lookup' . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&s=' . $row['session_id'] : '') . "&sg=$show_guests&start=$start&sk=$sort_key&sd=$sort_dir"), |
| 334 | 6015 | acydburn | 'U_WHOIS' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'mode=whois&s=' . $row['session_id']), |
| 335 | 6015 | acydburn | 'U_FORUM_LOCATION' => $location_url, |
| 336 | 9428 | acydburn | |
| 337 | 7889 | acydburn | 'S_USER_HIDDEN' => $s_user_hidden, |
| 338 | 5091 | acydburn | 'S_GUEST' => ($row['user_id'] == ANONYMOUS) ? true : false, |
| 339 | 7889 | acydburn | 'S_USER_TYPE' => $row['user_type'], |
| 340 | 7889 | acydburn | )); |
| 341 | 2465 | psotfx | } |
| 342 | 3969 | psotfx | $db->sql_freeresult($result); |
| 343 | 5091 | acydburn | unset($prev_id, $prev_ip); |
| 344 | 775 | psotfx | |
| 345 | 6015 | acydburn | $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"), $counter, $config['topics_per_page'], $start); |
| 346 | 3969 | psotfx | |
| 347 | 11015 | git-gate | $order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; |
| 348 | 3651 | psotfx | // Grab group details for legend display
|
| 349 | 7433 | acydburn | if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) |
| 350 | 7433 | acydburn | {
|
| 351 | 11015 | git-gate | $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend |
| 352 | 7433 | acydburn | FROM ' . GROUPS_TABLE . ' |
| 353 | 11346 | git-gate | WHERE group_legend > 0 |
| 354 | 11015 | git-gate | ORDER BY ' . $order_legend . ' ASC'; |
| 355 | 7433 | acydburn | } |
| 356 | 7433 | acydburn | else
|
| 357 | 7433 | acydburn | {
|
| 358 | 11015 | git-gate | $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend |
| 359 | 7433 | acydburn | FROM ' . GROUPS_TABLE . ' g |
| 360 | 7433 | acydburn | LEFT JOIN ' . USER_GROUP_TABLE . ' ug |
| 361 | 7433 | acydburn | ON ( |
| 362 | 7433 | acydburn | g.group_id = ug.group_id |
| 363 | 7433 | acydburn | AND ug.user_id = ' . $user->data['user_id'] . ' |
| 364 | 7433 | acydburn | AND ug.user_pending = 0 |
| 365 | 7433 | acydburn | ) |
| 366 | 11015 | git-gate | WHERE g.group_legend > 0 |
| 367 | 7433 | acydburn | AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') |
| 368 | 11015 | git-gate | ORDER BY g.' . $order_legend . ' ASC'; |
| 369 | 7433 | acydburn | } |
| 370 | 3651 | psotfx | $result = $db->sql_query($sql); |
| 371 | 3651 | psotfx | |
| 372 | 3651 | psotfx | $legend = ''; |
| 373 | 3651 | psotfx | while ($row = $db->sql_fetchrow($result)) |
| 374 | 3651 | psotfx | {
|
| 375 | 6398 | grahamje | if ($row['group_name'] == 'BOTS') |
| 376 | 6398 | grahamje | {
|
| 377 | 6398 | grahamje | $legend .= (($legend != '') ? ', ' : '') . '<span style="color:#' . $row['group_colour'] . '">' . $user->lang['G_BOTS'] . '</span>'; |
| 378 | 6398 | grahamje | } |
| 379 | 6398 | grahamje | else
|
| 380 | 6398 | grahamje | {
|
| 381 | 6398 | grahamje | $legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</a>'; |
| 382 | 6398 | grahamje | } |
| 383 | 3651 | psotfx | } |
| 384 | 3969 | psotfx | $db->sql_freeresult($result); |
| 385 | 3651 | psotfx | |
| 386 | 5678 | acydburn | // Refreshing the page every 60 seconds...
|
| 387 | 6015 | acydburn | meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start")); |
| 388 | 5678 | acydburn | |
| 389 | 3969 | psotfx | // Send data to template
|
| 390 | 2465 | psotfx | $template->assign_vars(array( |
| 391 | 11603 | git-gate | 'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)), |
| 392 | 11603 | git-gate | 'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter), |
| 393 | 6015 | acydburn | 'LEGEND' => $legend, |
| 394 | 6015 | acydburn | 'PAGINATION' => $pagination, |
| 395 | 6015 | acydburn | 'PAGE_NUMBER' => on_page($counter, $config['topics_per_page'], $start), |
| 396 | 2673 | psotfx | |
| 397 | 7038 | davidmj | 'U_SORT_USERNAME' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), |
| 398 | 7038 | davidmj | 'U_SORT_UPDATED' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), |
| 399 | 7038 | davidmj | 'U_SORT_LOCATION' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), |
| 400 | 5091 | acydburn | |
| 401 | 6015 | acydburn | 'U_SWITCH_GUEST_DISPLAY' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sg=' . ((int) !$show_guests)), |
| 402 | 5091 | acydburn | 'L_SWITCH_GUEST_DISPLAY' => ($show_guests) ? $user->lang['HIDE_GUESTS'] : $user->lang['DISPLAY_GUESTS'], |
| 403 | 5091 | acydburn | 'S_SWITCH_GUEST_DISPLAY' => ($config['load_online_guests']) ? true : false) |
| 404 | 2465 | psotfx | ); |
| 405 | 2465 | psotfx | |
| 406 | 5091 | acydburn | // We do not need to load the who is online box here. ;)
|
| 407 | 5091 | acydburn | $config['load_online'] = false; |
| 408 | 5091 | acydburn | |
| 409 | 3969 | psotfx | // Output the page
|
| 410 | 3969 | psotfx | page_header($user->lang['WHO_IS_ONLINE']); |
| 411 | 3969 | psotfx | |
| 412 | 2673 | psotfx | $template->set_filenames(array( |
| 413 | 2673 | psotfx | 'body' => 'viewonline_body.html') |
| 414 | 2673 | psotfx | ); |
| 415 | 6015 | acydburn | make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
| 416 | 146 | psotfx | |
| 417 | 3969 | psotfx | page_footer(); |

