Verzeichnisstruktur phpBB-2.0.0
- Veröffentlicht
- 03.04.2002
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
viewonline.php
001 <?php
002 /***************************************************************************
003 * viewonline.php
004 * -------------------
005 * begin : Saturday, Feb 13, 2001
006 * copyright : (C) 2001 The phpBB Group
007 * email : support@phpbb.com
008 *
009 * $Id$
010 *
011 *
012 ***************************************************************************/
013
014 /***************************************************************************
015 *
016 * This program is free software; you can redistribute it and/or modify
017 * it under the terms of the GNU General Public License as published by
018 * the Free Software Foundation; either version 2 of the License, or
019 * (at your option) any later version.
020 *
021 ***************************************************************************/
022
023 define('IN_PHPBB', true);
024 $phpbb_root_path = './';
025 include($phpbb_root_path . 'extension.inc');
026 include($phpbb_root_path . 'common.'.$phpEx);
027
028 //
029 // Start session management
030 //
031 $userdata = session_pagestart($user_ip, PAGE_VIEWONLINE);
032 init_userprefs($userdata);
033 //
034 // End session management
035 //
036
037 //
038 // Output page header and load viewonline template
039 //
040 $page_title = $lang['Who_is_Online'];
041 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
042
043 $template->set_filenames(array(
044 'body' => 'viewonline_body.tpl')
045 );
046 make_jumpbox('viewforum.'.$phpEx);
047
048 $template->assign_vars(array(
049 'L_WHOSONLINE' => $lang['Who_is_Online'],
050 'L_ONLINE_EXPLAIN' => $lang['Online_explain'],
051 'L_USERNAME' => $lang['Username'],
052 'L_FORUM_LOCATION' => $lang['Forum_Location'],
053 'L_LAST_UPDATE' => $lang['Last_updated'])
054 );
055
056 //
057 // Forum info
058 //
059 $sql = "SELECT forum_name, forum_id
060 FROM " . FORUMS_TABLE;
061 if ( $result = $db->sql_query($sql) )
062 {
063 while( $row = $db->sql_fetchrow($result) )
064 {
065 $forum_data[$row['forum_id']] = $row['forum_name'];
066 }
067 }
068 else
069 {
070 message_die(GENERAL_ERROR, 'Could not obtain user/online forums information', '', __LINE__, __FILE__, $sql);
071 }
072
073 //
074 // Get auth data
075 //
076 $is_auth_ary = array();
077 $is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
078
079 //
080 // Get user list
081 //
082 $sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
083 FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
084 WHERE u.user_id = s.session_user_id
085 AND s.session_time >= ".( time() - 300 ) . "
086 ORDER BY u.username ASC, s.session_ip ASC";
087 if ( !($result = $db->sql_query($sql)) )
088 {
089 message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
090 }
091
092 $guest_users = 0;
093 $registered_users = 0;
094 $hidden_users = 0;
095
096 $reg_counter = 0;
097 $guest_counter = 0;
098 $prev_user = 0;
099 $prev_ip = '';
100
101 while ( $row = $db->sql_fetchrow($result) )
102 {
103 $view_online = false;
104
105 if ( $row['session_logged_in'] )
106 {
107 $user_id = $row['user_id'];
108
109 if ( $user_id != $prev_user )
110 {
111 $username = $row['username'];
112
113 $style_color = '';
114 if ( $row['user_level'] == ADMIN )
115 {
116 $username = '<b style="color:#' . $theme['fontcolor3'] . '">' . $username . '</b>';
117 }
118 else if ( $row['user_level'] == MOD )
119 {
120 $username = '<b style="color:#' . $theme['fontcolor2'] . '">' . $username . '</b>';
121 }
122
123 if ( !$row['user_allow_viewonline'] )
124 {
125 $view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
126 $hidden_users++;
127
128 $username = '<i>' . $username . '</i>';
129 }
130 else
131 {
132 $view_online = true;
133 $registered_users++;
134 }
135
136 $which_counter = 'reg_counter';
137 $which_row = 'reg_user_row';
138 $prev_user = $user_id;
139 }
140 }
141 else
142 {
143 if ( $row['session_ip'] != $prev_ip )
144 {
145 $username = $lang['Guest'];
146 $view_online = true;
147 $guest_users++;
148
149 $which_counter = 'guest_counter';
150 $which_row = 'guest_user_row';
151 }
152 }
153
154 $prev_ip = $row['session_ip'];
155
156 if ( $view_online )
157 {
158 if ( $row['session_page'] < 1 || !$is_auth_ary[$row['session_page']]['auth_view'] )
159 {
160 switch( $row['session_page'] )
161 {
162 case PAGE_INDEX:
163 $location = $lang['Forum_index'];
164 $location_url = "index.$phpEx";
165 break;
166 case PAGE_POSTING:
167 $location = $lang['Posting_message'];
168 $location_url = "index.$phpEx";
169 break;
170 case PAGE_LOGIN:
171 $location = $lang['Logging_on'];
172 $location_url = "index.$phpEx";
173 break;
174 case PAGE_SEARCH:
175 $location = $lang['Searching_forums'];
176 $location_url = "search.$phpEx";
177 break;
178 case PAGE_PROFILE:
179 $location = $lang['Viewing_profile'];
180 $location_url = "index.$phpEx";
181 break;
182 case PAGE_VIEWONLINE:
183 $location = $lang['Viewing_online'];
184 $location_url = "viewonline.$phpEx";
185 break;
186 case PAGE_VIEWMEMBERS:
187 $location = $lang['Viewing_member_list'];
188 $location_url = "memberlist.$phpEx";
189 break;
190 case PAGE_PRIVMSGS:
191 $location = $lang['Viewing_priv_msgs'];
192 $location_url = "privmsg.$phpEx";
193 break;
194 case PAGE_FAQ:
195 $location = $lang['Viewing_FAQ'];
196 $location_url = "faq.$phpEx";
197 break;
198 default:
199 $location = $lang['Forum_index'];
200 $location_url = "index.$phpEx";
201 }
202 }
203 else
204 {
205 $location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $row['session_page']);
206 $location = $forum_data[$row['session_page']];
207 }
208
209 $row_color = ( $$which_counter % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
210 $row_class = ( $$which_counter % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
211
212 $template->assign_block_vars("$which_row", array(
213 'ROW_COLOR' => '#' . $row_color,
214 'ROW_CLASS' => $row_class,
215 'USERNAME' => $username,
216 'LASTUPDATE' => create_date($board_config['default_dateformat'], $row['session_time'], $board_config['board_timezone']),
217 'FORUM_LOCATION' => $location,
218
219 'U_USER_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $user_id),
220 'U_FORUM_LOCATION' => append_sid($location_url))
221 );
222
223 $$which_counter++;
224 }
225 }
226
227 if( $registered_users == 0 )
228 {
229 $l_r_user_s = $lang['Reg_users_zero_online'];
230 }
231 else if( $registered_users == 1 )
232 {
233 $l_r_user_s = $lang['Reg_user_online'];
234 }
235 else
236 {
237 $l_r_user_s = $lang['Reg_users_online'];
238 }
239
240 if( $hidden_users == 0 )
241 {
242 $l_h_user_s = $lang['Hidden_users_zero_online'];
243 }
244 else if( $hidden_users == 1 )
245 {
246 $l_h_user_s = $lang['Hidden_user_online'];
247 }
248 else
249 {
250 $l_h_user_s = $lang['Hidden_users_online'];
251 }
252
253 if( $guest_users == 0 )
254 {
255 $l_g_user_s = $lang['Guest_users_zero_online'];
256 }
257 else if( $guest_users == 1 )
258 {
259 $l_g_user_s = $lang['Guest_user_online'];
260 }
261 else
262 {
263 $l_g_user_s = $lang['Guest_users_online'];
264 }
265
266 $template->assign_vars(array(
267 'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $registered_users) . sprintf($l_h_user_s, $hidden_users),
268 'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users))
269 );
270
271 if ( $registered_users + $hidden_users == 0 )
272 {
273 $template->assign_vars(array(
274 'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
275 );
276 }
277
278 if ( $guest_users == 0 )
279 {
280 $template->assign_vars(array(
281 'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'])
282 );
283 }
284
285 $template->pparse('body');
286
287 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
288
289 ?>