forked from Arathi/phpBB-WAP_RE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewonline.php
More file actions
262 lines (231 loc) · 6.35 KB
/
viewonline.php
File metadata and controls
262 lines (231 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
/***************************************************************************
* viewonline.php
* -------------------
* Разработка: phpBB Group.
* Оптимизация под WAP: Гутник Игорь ( чел ).
* 2010 год
* 简体中文:爱疯的云
* 描述:用户的在线状态记录
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE);
init_userprefs($userdata);
if ( isset($HTTP_POST_VARS['start1']) )
{
$start1 = abs(intval($HTTP_POST_VARS['start1']));
$start1 = ($start1 < 1) ? 1 : $start1;
$start = (($start1 - 1) * $board_config['posts_per_page']);
}
else
{
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
$start = ($start < 0) ? 0 : $start;
}
$page_title = $lang['Who_is_Online'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'viewonline_body.tpl')
);
$sql = "SELECT forum_name, forum_id
FROM " . FORUMS_TABLE;
if ( $result = $db->sql_query($sql) )
{
while( $row = $db->sql_fetchrow($result) )
{
$forum_data[$row['forum_id']] = $row['forum_name'];
}
}
else
{
message_die(GENERAL_ERROR, 'Could not obtain user/online forums information', '', __LINE__, __FILE__, $sql);
}
$is_auth_ary = array();
$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);
$sql = "SELECT u.user_id, u.username, u.user_nic_color, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 3600 ) . "
ORDER BY s.session_time ASC
LIMIT $start, 50";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
$guest_users = 0;
$registered_users = 0;
$hidden_users = 0;
$reg_counter = 0;
$guest_counter = 0;
$prev_user = 0;
$prev_ip = '';
while ( $row = $db->sql_fetchrow($result) )
{
$view_online = false;
if ( $row['session_logged_in'] )
{
$user_id = $row['user_id'];
if ( $user_id != $prev_user )
{
$username = '<span style="color: ' . $row['user_nic_color'] . '">' . $row['username'] . '</span>';
if ( !$row['user_allow_viewonline'] )
{
$view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
$hidden_users++;
$username = '' . $username . '[hid]';
}
else
{
$view_online = true;
$registered_users++;
}
$which_counter = 'reg_counter';
$which_row = 'reg_user_row';
$prev_user = $user_id;
}
}
else
{
if ( $row['session_ip'] != $prev_ip )
{
$username = $lang['Guest'];
$view_online = true;
$guest_users++;
$which_counter = 'guest_counter';
$which_row = 'guest_user_row';
}
}
$prev_ip = $row['session_ip'];
if ( $view_online )
{
if ( $row['session_page'] < 1 || !$is_auth_ary[$row['session_page']]['auth_view'] )
{
switch( $row['session_page'] )
{
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;
case PAGE_ALBUM:
$location = $lang['Album'];
$location_url = "album.$phpEx";
break;
case PAGE_PRAVILA:
$location = $lang['Rules'];
$location_url = "rules.$phpEx";
break;
case PAGE_MEDALS:
$location = $lang['Medals'];
$location_url = "medals.$phpEx";
break;
default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx";
}
}
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $row['session_page']);
$location = $forum_data[$row['session_page']];
}
$template->assign_block_vars("$which_row", array(
'USERNAME' => $username,
'LASTUPDATE' => create_date($board_config['default_dateformat'], $row['session_time'], $board_config['board_timezone']),
'FORUM_LOCATION' => $location,
'U_USER_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $user_id),
'U_FORUM_LOCATION' => append_sid($location_url))
);
$$which_counter++;
}
}
if( $registered_users == 0 )
{
$l_r_user_s = $lang['Reg_users_zero_online'];
}
else if( $registered_users == 1 )
{
$l_r_user_s = $lang['Reg_user_online'];
}
else
{
$l_r_user_s = $lang['Reg_users_online'];
}
if( $hidden_users == 0 )
{
$l_h_user_s = $lang['Hidden_users_zero_online'];
}
else if( $hidden_users == 1 )
{
$l_h_user_s = $lang['Hidden_user_online'];
}
else
{
$l_h_user_s = $lang['Hidden_users_online'];
}
if( $guest_users == 0 )
{
$l_g_user_s = $lang['Guest_users_zero_online'];
}
else if( $guest_users == 1 )
{
$l_g_user_s = $lang['Guest_user_online'];
}
else
{
$l_g_user_s = $lang['Guest_users_online'];
}
$template->assign_vars(array(
'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $registered_users),
'TOTAL_HIDDEN_USERS_ONLINE' => sprintf($l_h_user_s, $hidden_users),
'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_users))
);
if ( $registered_users + $hidden_users == 0 )
{
$template->assign_vars(array(
'L_NO_REGISTERED_USERS_BROWSING' => $lang['No_users_browsing'])
);
}
if ( $guest_users == 0 )
{
$template->assign_vars(array(
'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing'])
);
}
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>