|
1 <?php |
|
2 /** |
|
3 * |
|
4 * @package phpBB3 |
|
5 * @version $Id$ |
|
6 * @copyright (c) 2005 phpBB Group |
|
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
8 * |
|
9 */ |
|
10 |
|
11 /** |
|
12 * @ignore |
|
13 */ |
|
14 define('IN_PHPBB', true); |
|
15 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
|
16 $phpEx = substr(strrchr(__FILE__, '.'), 1); |
|
17 include($phpbb_root_path . 'common.' . $phpEx); |
|
18 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
|
19 |
|
20 // Start session management |
|
21 $user->session_begin(); |
|
22 $auth->acl($user->data); |
|
23 $user->setup(array('memberlist', 'groups')); |
|
24 |
|
25 // Grab data |
|
26 $mode = request_var('mode', ''); |
|
27 $action = request_var('action', ''); |
|
28 $user_id = request_var('u', ANONYMOUS); |
|
29 $username = request_var('un', '', true); |
|
30 $group_id = request_var('g', 0); |
|
31 $topic_id = request_var('t', 0); |
|
32 |
|
33 // Check our mode... |
|
34 if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders'))) |
|
35 { |
|
36 trigger_error('NO_MODE'); |
|
37 } |
|
38 |
|
39 switch ($mode) |
|
40 { |
|
41 case 'email': |
|
42 break; |
|
43 |
|
44 default: |
|
45 // Can this user view profiles/memberlist? |
|
46 if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) |
|
47 { |
|
48 if ($user->data['user_id'] != ANONYMOUS) |
|
49 { |
|
50 trigger_error('NO_VIEW_USERS'); |
|
51 } |
|
52 |
|
53 login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST'])); |
|
54 } |
|
55 break; |
|
56 } |
|
57 |
|
58 $start = request_var('start', 0); |
|
59 $submit = (isset($_POST['submit'])) ? true : false; |
|
60 |
|
61 $default_key = 'c'; |
|
62 $sort_key = request_var('sk', $default_key); |
|
63 $sort_dir = request_var('sd', 'a'); |
|
64 |
|
65 |
|
66 // Grab rank information for later |
|
67 $ranks = $cache->obtain_ranks(); |
|
68 |
|
69 |
|
70 // What do you want to do today? ... oops, I think that line is taken ... |
|
71 switch ($mode) |
|
72 { |
|
73 case 'leaders': |
|
74 // Display a listing of board admins, moderators |
|
75 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
|
76 |
|
77 $page_title = $user->lang['THE_TEAM']; |
|
78 $template_html = 'memberlist_leaders.html'; |
|
79 |
|
80 $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false); |
|
81 |
|
82 $admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array(); |
|
83 foreach ($user_ary as $forum_id => $forum_ary) |
|
84 { |
|
85 foreach ($forum_ary as $auth_option => $id_ary) |
|
86 { |
|
87 if (!$forum_id) |
|
88 { |
|
89 if ($auth_option == 'a_') |
|
90 { |
|
91 $admin_id_ary = array_merge($admin_id_ary, $id_ary); |
|
92 } |
|
93 else |
|
94 { |
|
95 $global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary); |
|
96 } |
|
97 continue; |
|
98 } |
|
99 else |
|
100 { |
|
101 $mod_id_ary = array_merge($mod_id_ary, $id_ary); |
|
102 } |
|
103 |
|
104 if ($forum_id) |
|
105 { |
|
106 foreach ($id_ary as $id) |
|
107 { |
|
108 $forum_id_ary[$id][] = $forum_id; |
|
109 } |
|
110 } |
|
111 } |
|
112 } |
|
113 |
|
114 $admin_id_ary = array_unique($admin_id_ary); |
|
115 $global_mod_id_ary = array_unique($global_mod_id_ary); |
|
116 |
|
117 $mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary); |
|
118 $mod_id_ary = array_unique($mod_id_ary); |
|
119 |
|
120 // Admin group id... |
|
121 $sql = 'SELECT group_id |
|
122 FROM ' . GROUPS_TABLE . " |
|
123 WHERE group_name = 'ADMINISTRATORS'"; |
|
124 $result = $db->sql_query($sql); |
|
125 $admin_group_id = (int) $db->sql_fetchfield('group_id'); |
|
126 $db->sql_freeresult($result); |
|
127 |
|
128 // Get group memberships for the admin id ary... |
|
129 $admin_memberships = group_memberships($admin_group_id, $admin_id_ary); |
|
130 |
|
131 $admin_user_ids = array(); |
|
132 |
|
133 if (!empty($admin_memberships)) |
|
134 { |
|
135 // ok, we only need the user ids... |
|
136 foreach ($admin_memberships as $row) |
|
137 { |
|
138 $admin_user_ids[$row['user_id']] = true; |
|
139 } |
|
140 } |
|
141 unset($admin_memberships); |
|
142 |
|
143 $sql = 'SELECT forum_id, forum_name |
|
144 FROM ' . FORUMS_TABLE; |
|
145 $result = $db->sql_query($sql); |
|
146 |
|
147 $forums = array(); |
|
148 while ($row = $db->sql_fetchrow($result)) |
|
149 { |
|
150 $forums[$row['forum_id']] = $row['forum_name']; |
|
151 } |
|
152 $db->sql_freeresult($result); |
|
153 |
|
154 $sql = $db->sql_build_query('SELECT', array( |
|
155 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.username_clean, u.user_colour, u.user_rank, u.user_posts, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', |
|
156 |
|
157 'FROM' => array( |
|
158 USERS_TABLE => 'u', |
|
159 GROUPS_TABLE => 'g' |
|
160 ), |
|
161 |
|
162 'LEFT_JOIN' => array( |
|
163 array( |
|
164 'FROM' => array(USER_GROUP_TABLE => 'ug'), |
|
165 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] |
|
166 ) |
|
167 ), |
|
168 |
|
169 'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . ' |
|
170 AND u.group_id = g.group_id', |
|
171 |
|
172 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' |
|
173 )); |
|
174 $result = $db->sql_query($sql); |
|
175 |
|
176 while ($row = $db->sql_fetchrow($result)) |
|
177 { |
|
178 $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod'; |
|
179 |
|
180 // We sort out admins not within the 'Administrators' group. |
|
181 // Else, we will list those as admin only having the permission to view logs for example. |
|
182 if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']])) |
|
183 { |
|
184 // Remove from admin_id_ary, because the user may be a mod instead |
|
185 unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]); |
|
186 |
|
187 if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary)) |
|
188 { |
|
189 continue; |
|
190 } |
|
191 else |
|
192 { |
|
193 $which_row = 'mod'; |
|
194 } |
|
195 } |
|
196 |
|
197 $s_forum_select = ''; |
|
198 $undisclosed_forum = false; |
|
199 |
|
200 if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary)) |
|
201 { |
|
202 if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']]))) |
|
203 { |
|
204 foreach ($forum_id_ary[$row['user_id']] as $forum_id) |
|
205 { |
|
206 if (isset($forums[$forum_id])) |
|
207 { |
|
208 if ($auth->acl_get('f_list', $forum_id)) |
|
209 { |
|
210 $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>'; |
|
211 } |
|
212 else |
|
213 { |
|
214 $undisclosed_forum = true; |
|
215 } |
|
216 } |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 // If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then... |
|
222 if (!$s_forum_select && $undisclosed_forum) |
|
223 { |
|
224 // $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>'; |
|
225 continue; |
|
226 } |
|
227 |
|
228 // The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden. |
|
229 if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) |
|
230 { |
|
231 $group_name = $user->lang['GROUP_UNDISCLOSED']; |
|
232 $u_group = ''; |
|
233 } |
|
234 else |
|
235 { |
|
236 $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; |
|
237 $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); |
|
238 } |
|
239 |
|
240 $rank_title = $rank_img = ''; |
|
241 get_user_rank($row['user_rank'], (($row['user_id'] == ANONYMOUS) ? false : $row['user_posts']), $rank_title, $rank_img, $rank_img_src); |
|
242 |
|
243 $template->assign_block_vars($which_row, array( |
|
244 'USER_ID' => $row['user_id'], |
|
245 'FORUMS' => $s_forum_select, |
|
246 'RANK_TITLE' => $rank_title, |
|
247 'GROUP_NAME' => $group_name, |
|
248 'GROUP_COLOR' => $row['group_colour'], |
|
249 |
|
250 'RANK_IMG' => $rank_img, |
|
251 'RANK_IMG_SRC' => $rank_img_src, |
|
252 |
|
253 'U_GROUP' => $u_group, |
|
254 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '', |
|
255 |
|
256 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), |
|
257 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), |
|
258 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), |
|
259 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), |
|
260 )); |
|
261 } |
|
262 $db->sql_freeresult($result); |
|
263 |
|
264 $template->assign_vars(array( |
|
265 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) |
|
266 ); |
|
267 break; |
|
268 |
|
269 case 'contact': |
|
270 |
|
271 $page_title = $user->lang['IM_USER']; |
|
272 $template_html = 'memberlist_im.html'; |
|
273 |
|
274 if (!$auth->acl_get('u_sendim')) |
|
275 { |
|
276 trigger_error('NOT_AUTHORISED'); |
|
277 } |
|
278 |
|
279 $presence_img = ''; |
|
280 switch ($action) |
|
281 { |
|
282 case 'aim': |
|
283 $lang = 'AIM'; |
|
284 $sql_field = 'user_aim'; |
|
285 $s_select = 'S_SEND_AIM'; |
|
286 $s_action = ''; |
|
287 break; |
|
288 |
|
289 case 'msnm': |
|
290 $lang = 'MSNM'; |
|
291 $sql_field = 'user_msnm'; |
|
292 $s_select = 'S_SEND_MSNM'; |
|
293 $s_action = ''; |
|
294 break; |
|
295 |
|
296 case 'jabber': |
|
297 $lang = 'JABBER'; |
|
298 $sql_field = 'user_jabber'; |
|
299 $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER'; |
|
300 $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"); |
|
301 break; |
|
302 |
|
303 default: |
|
304 trigger_error('NO_MODE', E_USER_ERROR); |
|
305 break; |
|
306 } |
|
307 |
|
308 // Grab relevant data |
|
309 $sql = "SELECT user_id, username, user_email, user_lang, $sql_field |
|
310 FROM " . USERS_TABLE . " |
|
311 WHERE user_id = $user_id |
|
312 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; |
|
313 $result = $db->sql_query($sql); |
|
314 $row = $db->sql_fetchrow($result); |
|
315 $db->sql_freeresult($result); |
|
316 |
|
317 if (!$row) |
|
318 { |
|
319 trigger_error('NO_USER'); |
|
320 } |
|
321 else if (empty($row[$sql_field])) |
|
322 { |
|
323 trigger_error('IM_NO_DATA'); |
|
324 } |
|
325 |
|
326 // Post data grab actions |
|
327 switch ($action) |
|
328 { |
|
329 case 'jabber': |
|
330 add_form_key('memberlist_messaging'); |
|
331 |
|
332 if ($submit && @extension_loaded('xml') && $config['jab_enable']) |
|
333 { |
|
334 if (check_form_key('memberlist_messaging')) |
|
335 { |
|
336 |
|
337 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
|
338 |
|
339 $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); |
|
340 $message = utf8_normalize_nfc(request_var('message', '', true)); |
|
341 |
|
342 if (empty($message)) |
|
343 { |
|
344 trigger_error('EMPTY_MESSAGE_IM'); |
|
345 } |
|
346 |
|
347 $messenger = new messenger(false); |
|
348 |
|
349 $messenger->template('profile_send_im', $row['user_lang']); |
|
350 $messenger->subject(htmlspecialchars_decode($subject)); |
|
351 |
|
352 $messenger->replyto($user->data['user_email']); |
|
353 $messenger->im($row['user_jabber'], $row['username']); |
|
354 |
|
355 $messenger->assign_vars(array( |
|
356 'BOARD_CONTACT' => $config['board_contact'], |
|
357 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), |
|
358 'TO_USERNAME' => htmlspecialchars_decode($row['username']), |
|
359 'MESSAGE' => htmlspecialchars_decode($message)) |
|
360 ); |
|
361 |
|
362 $messenger->send(NOTIFY_IM); |
|
363 |
|
364 $s_select = 'S_SENT_JABBER'; |
|
365 } |
|
366 else |
|
367 { |
|
368 trigger_error('FORM_INVALID'); |
|
369 } |
|
370 } |
|
371 break; |
|
372 } |
|
373 |
|
374 // Send vars to the template |
|
375 $template->assign_vars(array( |
|
376 'IM_CONTACT' => $row[$sql_field], |
|
377 'A_IM_CONTACT' => addslashes($row[$sql_field]), |
|
378 |
|
379 'U_AIM_CONTACT' => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '', |
|
380 'U_AIM_MESSAGE' => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&message=' . urlencode($config['sitename']) : '', |
|
381 |
|
382 'USERNAME' => $row['username'], |
|
383 'CONTACT_NAME' => $row[$sql_field], |
|
384 'SITENAME' => $config['sitename'], |
|
385 |
|
386 'PRESENCE_IMG' => $presence_img, |
|
387 |
|
388 'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang], |
|
389 'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']), |
|
390 |
|
391 $s_select => true, |
|
392 'S_IM_ACTION' => $s_action) |
|
393 ); |
|
394 |
|
395 break; |
|
396 |
|
397 case 'viewprofile': |
|
398 // Display a profile |
|
399 if ($user_id == ANONYMOUS && !$username) |
|
400 { |
|
401 trigger_error('NO_USER'); |
|
402 } |
|
403 |
|
404 // Get user... |
|
405 $sql = 'SELECT * |
|
406 FROM ' . USERS_TABLE . ' |
|
407 WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id"); |
|
408 $result = $db->sql_query($sql); |
|
409 $member = $db->sql_fetchrow($result); |
|
410 $db->sql_freeresult($result); |
|
411 |
|
412 if (!$member) |
|
413 { |
|
414 trigger_error('NO_USER'); |
|
415 } |
|
416 |
|
417 // a_user admins and founder are able to view inactive users and bots to be able to manage them more easily |
|
418 // Normal users are able to see at least users having only changed their profile settings but not yet reactivated. |
|
419 if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER) |
|
420 { |
|
421 if ($member['user_type'] == USER_IGNORE) |
|
422 { |
|
423 trigger_error('NO_USER'); |
|
424 } |
|
425 else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE) |
|
426 { |
|
427 trigger_error('NO_USER'); |
|
428 } |
|
429 } |
|
430 |
|
431 $user_id = (int) $member['user_id']; |
|
432 |
|
433 // Get group memberships |
|
434 // Also get visiting user's groups to determine hidden group memberships if necessary. |
|
435 $auth_hidden_groups = ($user_id === (int) $user->data['user_id'] || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? true : false; |
|
436 $sql_uid_ary = ($auth_hidden_groups) ? array($user_id) : array($user_id, (int) $user->data['user_id']); |
|
437 |
|
438 // Do the SQL thang |
|
439 $sql = 'SELECT g.group_id, g.group_name, g.group_type, ug.user_id |
|
440 FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug |
|
441 WHERE ' . $db->sql_in_set('ug.user_id', $sql_uid_ary) . ' |
|
442 AND g.group_id = ug.group_id |
|
443 AND ug.user_pending = 0'; |
|
444 $result = $db->sql_query($sql); |
|
445 |
|
446 // Divide data into profile data and current user data |
|
447 $profile_groups = $user_groups = array(); |
|
448 while ($row = $db->sql_fetchrow($result)) |
|
449 { |
|
450 $row['user_id'] = (int) $row['user_id']; |
|
451 $row['group_id'] = (int) $row['group_id']; |
|
452 |
|
453 if ($row['user_id'] == $user_id) |
|
454 { |
|
455 $profile_groups[] = $row; |
|
456 } |
|
457 else |
|
458 { |
|
459 $user_groups[$row['group_id']] = $row['group_id']; |
|
460 } |
|
461 } |
|
462 $db->sql_freeresult($result); |
|
463 |
|
464 // Filter out hidden groups and sort groups by name |
|
465 $group_data = $group_sort = array(); |
|
466 foreach ($profile_groups as $row) |
|
467 { |
|
468 if ($row['group_type'] == GROUP_SPECIAL) |
|
469 { |
|
470 // Lookup group name in language dictionary |
|
471 if (isset($user->lang['G_' . $row['group_name']])) |
|
472 { |
|
473 $row['group_name'] = $user->lang['G_' . $row['group_name']]; |
|
474 } |
|
475 } |
|
476 else if (!$auth_hidden_groups && $row['group_type'] == GROUP_HIDDEN && !isset($user_groups[$row['group_id']])) |
|
477 { |
|
478 // Skip over hidden groups the user cannot see |
|
479 continue; |
|
480 } |
|
481 |
|
482 $group_sort[$row['group_id']] = utf8_clean_string($row['group_name']); |
|
483 $group_data[$row['group_id']] = $row; |
|
484 } |
|
485 unset($profile_groups); |
|
486 unset($user_groups); |
|
487 asort($group_sort); |
|
488 |
|
489 $group_options = ''; |
|
490 foreach ($group_sort as $group_id => $null) |
|
491 { |
|
492 $row = $group_data[$group_id]; |
|
493 |
|
494 $group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . $row['group_name'] . '</option>'; |
|
495 } |
|
496 unset($group_data); |
|
497 unset($group_sort); |
|
498 |
|
499 // What colour is the zebra |
|
500 $sql = 'SELECT friend, foe |
|
501 FROM ' . ZEBRA_TABLE . " |
|
502 WHERE zebra_id = $user_id |
|
503 AND user_id = {$user->data['user_id']}"; |
|
504 |
|
505 $result = $db->sql_query($sql); |
|
506 $row = $db->sql_fetchrow($result); |
|
507 $foe = ($row['foe']) ? true : false; |
|
508 $friend = ($row['friend']) ? true : false; |
|
509 $db->sql_freeresult($result); |
|
510 |
|
511 if ($config['load_onlinetrack']) |
|
512 { |
|
513 $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline |
|
514 FROM ' . SESSIONS_TABLE . " |
|
515 WHERE session_user_id = $user_id"; |
|
516 $result = $db->sql_query($sql); |
|
517 $row = $db->sql_fetchrow($result); |
|
518 $db->sql_freeresult($result); |
|
519 |
|
520 $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; |
|
521 $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; |
|
522 unset($row); |
|
523 } |
|
524 |
|
525 if ($config['load_user_activity']) |
|
526 { |
|
527 display_user_activity($member); |
|
528 } |
|
529 |
|
530 // Do the relevant calculations |
|
531 $memberdays = max(1, round((time() - $member['user_regdate']) / 86400)); |
|
532 $posts_per_day = $member['user_posts'] / $memberdays; |
|
533 $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0; |
|
534 |
|
535 |
|
536 if ($member['user_sig']) |
|
537 { |
|
538 $member['user_sig'] = censor_text($member['user_sig']); |
|
539 |
|
540 if ($member['user_sig_bbcode_bitfield']) |
|
541 { |
|
542 include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); |
|
543 $bbcode = new bbcode(); |
|
544 $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']); |
|
545 } |
|
546 |
|
547 $member['user_sig'] = bbcode_nl2br($member['user_sig']); |
|
548 $member['user_sig'] = smiley_text($member['user_sig']); |
|
549 } |
|
550 |
|
551 $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); |
|
552 |
|
553 // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links |
|
554 $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; |
|
555 |
|
556 // Only check if the user is logged in |
|
557 if ($user->data['is_registered']) |
|
558 { |
|
559 if (!class_exists('p_master')) |
|
560 { |
|
561 include($phpbb_root_path . 'includes/functions_module.' . $phpEx); |
|
562 } |
|
563 $module = new p_master(); |
|
564 |
|
565 $module->list_modules('ucp'); |
|
566 $module->list_modules('mcp'); |
|
567 |
|
568 $user_notes_enabled = ($module->loaded('notes', 'user_notes')) ? true : false; |
|
569 $warn_user_enabled = ($module->loaded('warn', 'warn_user')) ? true : false; |
|
570 $zebra_enabled = ($module->loaded('zebra')) ? true : false; |
|
571 $friends_enabled = ($module->loaded('zebra', 'friends')) ? true : false; |
|
572 $foes_enabled = ($module->loaded('zebra', 'foes')) ? true : false; |
|
573 |
|
574 unset($module); |
|
575 } |
|
576 |
|
577 $template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled)); |
|
578 |
|
579 // Custom Profile Fields |
|
580 $profile_fields = array(); |
|
581 if ($config['load_cpf_viewprofile']) |
|
582 { |
|
583 include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
|
584 $cp = new custom_profile(); |
|
585 $profile_fields = $cp->generate_profile_fields_template('grab', $user_id); |
|
586 $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array(); |
|
587 } |
|
588 |
|
589 // If the user has m_approve permission or a_user permission, then list then display unapproved posts |
|
590 if ($auth->acl_getf_global('m_approve') || $auth->acl_get('a_user')) |
|
591 { |
|
592 $sql = 'SELECT COUNT(post_id) as posts_in_queue |
|
593 FROM ' . POSTS_TABLE . ' |
|
594 WHERE poster_id = ' . $user_id . ' |
|
595 AND post_approved = 0'; |
|
596 $result = $db->sql_query($sql); |
|
597 $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); |
|
598 $db->sql_freeresult($result); |
|
599 } |
|
600 else |
|
601 { |
|
602 $member['posts_in_queue'] = 0; |
|
603 } |
|
604 |
|
605 $template->assign_vars(array( |
|
606 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $member['posts_in_queue']), |
|
607 |
|
608 'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day), |
|
609 'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage), |
|
610 |
|
611 'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '', |
|
612 'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '', |
|
613 'SIGNATURE' => $member['user_sig'], |
|
614 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], |
|
615 |
|
616 'AVATAR_IMG' => $poster_avatar, |
|
617 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), |
|
618 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), |
|
619 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), |
|
620 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), |
|
621 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), |
|
622 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), |
|
623 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), |
|
624 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), |
|
625 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), |
|
626 |
|
627 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), |
|
628 'S_GROUP_OPTIONS' => $group_options, |
|
629 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false, |
|
630 |
|
631 'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '', |
|
632 'U_USER_BAN' => ($auth->acl_get('m_ban') && $user_id != $user->data['user_id']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=ban&mode=user&u=' . $user_id, true, $user->session_id) : '', |
|
633 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', |
|
634 |
|
635 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_id) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_id}&hash=" . generate_link_hash('switchperm')) : '', |
|
636 |
|
637 'S_USER_NOTES' => ($user_notes_enabled) ? true : false, |
|
638 'S_WARN_USER' => ($warn_user_enabled) ? true : false, |
|
639 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, |
|
640 'U_ADD_FRIEND' => (!$friend && !$foe && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', |
|
641 'U_ADD_FOE' => (!$friend && !$foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '', |
|
642 'U_REMOVE_FRIEND' => ($friend && $friends_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', |
|
643 'U_REMOVE_FOE' => ($foe && $foes_enabled) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '', |
|
644 )); |
|
645 |
|
646 if (!empty($profile_fields['row'])) |
|
647 { |
|
648 $template->assign_vars($profile_fields['row']); |
|
649 } |
|
650 |
|
651 if (!empty($profile_fields['blockrow'])) |
|
652 { |
|
653 foreach ($profile_fields['blockrow'] as $field_data) |
|
654 { |
|
655 $template->assign_block_vars('custom_fields', $field_data); |
|
656 } |
|
657 } |
|
658 |
|
659 // Inactive reason/account? |
|
660 if ($member['user_type'] == USER_INACTIVE) |
|
661 { |
|
662 $user->add_lang('acp/common'); |
|
663 |
|
664 $inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN']; |
|
665 |
|
666 switch ($member['user_inactive_reason']) |
|
667 { |
|
668 case INACTIVE_REGISTER: |
|
669 $inactive_reason = $user->lang['INACTIVE_REASON_REGISTER']; |
|
670 break; |
|
671 |
|
672 case INACTIVE_PROFILE: |
|
673 $inactive_reason = $user->lang['INACTIVE_REASON_PROFILE']; |
|
674 break; |
|
675 |
|
676 case INACTIVE_MANUAL: |
|
677 $inactive_reason = $user->lang['INACTIVE_REASON_MANUAL']; |
|
678 break; |
|
679 |
|
680 case INACTIVE_REMIND: |
|
681 $inactive_reason = $user->lang['INACTIVE_REASON_REMIND']; |
|
682 break; |
|
683 } |
|
684 |
|
685 $template->assign_vars(array( |
|
686 'S_USER_INACTIVE' => true, |
|
687 'USER_INACTIVE_REASON' => $inactive_reason) |
|
688 ); |
|
689 } |
|
690 |
|
691 // Now generate page title |
|
692 $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']); |
|
693 $template_html = 'memberlist_view.html'; |
|
694 |
|
695 break; |
|
696 |
|
697 case 'email': |
|
698 |
|
699 // Send an email |
|
700 $page_title = $user->lang['SEND_EMAIL']; |
|
701 $template_html = 'memberlist_email.html'; |
|
702 |
|
703 add_form_key('memberlist_email'); |
|
704 |
|
705 if (!$config['email_enable']) |
|
706 { |
|
707 trigger_error('EMAIL_DISABLED'); |
|
708 } |
|
709 |
|
710 if (!$auth->acl_get('u_sendemail')) |
|
711 { |
|
712 trigger_error('NO_EMAIL'); |
|
713 } |
|
714 |
|
715 // Are we trying to abuse the facility? |
|
716 if (time() - $user->data['user_emailtime'] < $config['flood_interval']) |
|
717 { |
|
718 trigger_error('FLOOD_EMAIL_LIMIT'); |
|
719 } |
|
720 |
|
721 // Determine action... |
|
722 $user_id = request_var('u', 0); |
|
723 $topic_id = request_var('t', 0); |
|
724 |
|
725 // Send email to user... |
|
726 if ($user_id) |
|
727 { |
|
728 if ($user_id == ANONYMOUS || !$config['board_email_form']) |
|
729 { |
|
730 trigger_error('NO_EMAIL'); |
|
731 } |
|
732 |
|
733 // Get the appropriate username, etc. |
|
734 $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type |
|
735 FROM ' . USERS_TABLE . " |
|
736 WHERE user_id = $user_id |
|
737 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; |
|
738 $result = $db->sql_query($sql); |
|
739 $row = $db->sql_fetchrow($result); |
|
740 $db->sql_freeresult($result); |
|
741 |
|
742 if (!$row) |
|
743 { |
|
744 trigger_error('NO_USER'); |
|
745 } |
|
746 |
|
747 // Can we send email to this user? |
|
748 if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user')) |
|
749 { |
|
750 trigger_error('NO_EMAIL'); |
|
751 } |
|
752 } |
|
753 else if ($topic_id) |
|
754 { |
|
755 // Send topic heads-up to email address |
|
756 $sql = 'SELECT forum_id, topic_title |
|
757 FROM ' . TOPICS_TABLE . " |
|
758 WHERE topic_id = $topic_id"; |
|
759 $result = $db->sql_query($sql); |
|
760 $row = $db->sql_fetchrow($result); |
|
761 $db->sql_freeresult($result); |
|
762 |
|
763 if (!$row) |
|
764 { |
|
765 trigger_error('NO_TOPIC'); |
|
766 } |
|
767 |
|
768 if ($row['forum_id']) |
|
769 { |
|
770 if (!$auth->acl_get('f_read', $row['forum_id'])) |
|
771 { |
|
772 trigger_error('SORRY_AUTH_READ'); |
|
773 } |
|
774 |
|
775 if (!$auth->acl_get('f_email', $row['forum_id'])) |
|
776 { |
|
777 trigger_error('NO_EMAIL'); |
|
778 } |
|
779 } |
|
780 else |
|
781 { |
|
782 // If global announcement, we need to check if the user is able to at least read and email in one forum... |
|
783 if (!$auth->acl_getf_global('f_read')) |
|
784 { |
|
785 trigger_error('SORRY_AUTH_READ'); |
|
786 } |
|
787 |
|
788 if (!$auth->acl_getf_global('f_email')) |
|
789 { |
|
790 trigger_error('NO_EMAIL'); |
|
791 } |
|
792 } |
|
793 } |
|
794 else |
|
795 { |
|
796 trigger_error('NO_EMAIL'); |
|
797 } |
|
798 |
|
799 $error = array(); |
|
800 |
|
801 $name = utf8_normalize_nfc(request_var('name', '', true)); |
|
802 $email = request_var('email', ''); |
|
803 $email_lang = request_var('lang', $config['default_lang']); |
|
804 $subject = utf8_normalize_nfc(request_var('subject', '', true)); |
|
805 $message = utf8_normalize_nfc(request_var('message', '', true)); |
|
806 $cc = (isset($_POST['cc_email'])) ? true : false; |
|
807 $submit = (isset($_POST['submit'])) ? true : false; |
|
808 |
|
809 if ($submit) |
|
810 { |
|
811 if (!check_form_key('memberlist_email')) |
|
812 { |
|
813 $error[] = 'FORM_INVALID'; |
|
814 } |
|
815 if ($user_id) |
|
816 { |
|
817 if (!$subject) |
|
818 { |
|
819 $error[] = $user->lang['EMPTY_SUBJECT_EMAIL']; |
|
820 } |
|
821 |
|
822 if (!$message) |
|
823 { |
|
824 $error[] = $user->lang['EMPTY_MESSAGE_EMAIL']; |
|
825 } |
|
826 |
|
827 $name = $row['username']; |
|
828 $email_lang = $row['user_lang']; |
|
829 $email = $row['user_email']; |
|
830 } |
|
831 else |
|
832 { |
|
833 if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) |
|
834 { |
|
835 $error[] = $user->lang['EMPTY_ADDRESS_EMAIL']; |
|
836 } |
|
837 |
|
838 if (!$name) |
|
839 { |
|
840 $error[] = $user->lang['EMPTY_NAME_EMAIL']; |
|
841 } |
|
842 } |
|
843 |
|
844 if (!sizeof($error)) |
|
845 { |
|
846 $sql = 'UPDATE ' . USERS_TABLE . ' |
|
847 SET user_emailtime = ' . time() . ' |
|
848 WHERE user_id = ' . $user->data['user_id']; |
|
849 $result = $db->sql_query($sql); |
|
850 |
|
851 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
|
852 $messenger = new messenger(false); |
|
853 $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify'; |
|
854 |
|
855 $mail_to_users = array(); |
|
856 |
|
857 $mail_to_users[] = array( |
|
858 'email_lang' => $email_lang, |
|
859 'email' => $email, |
|
860 'name' => $name, |
|
861 'username' => ($user_id) ? $row['username'] : '', |
|
862 'to_name' => $name, |
|
863 'user_jabber' => ($user_id) ? $row['user_jabber'] : '', |
|
864 'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL, |
|
865 'topic_title' => (!$user_id) ? $row['topic_title'] : '', |
|
866 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, |
|
867 ); |
|
868 |
|
869 // Ok, now the same email if CC specified, but without exposing the users email address |
|
870 if ($cc) |
|
871 { |
|
872 $mail_to_users[] = array( |
|
873 'email_lang' => $user->data['user_lang'], |
|
874 'email' => $user->data['user_email'], |
|
875 'name' => $user->data['username'], |
|
876 'username' => $user->data['username'], |
|
877 'to_name' => $name, |
|
878 'user_jabber' => $user->data['user_jabber'], |
|
879 'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL, |
|
880 'topic_title' => (!$user_id) ? $row['topic_title'] : '', |
|
881 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, |
|
882 ); |
|
883 } |
|
884 |
|
885 foreach ($mail_to_users as $row) |
|
886 { |
|
887 $messenger->template($email_tpl, $row['email_lang']); |
|
888 $messenger->replyto($user->data['user_email']); |
|
889 $messenger->to($row['email'], $row['name']); |
|
890 |
|
891 if ($user_id) |
|
892 { |
|
893 $messenger->subject(htmlspecialchars_decode($subject)); |
|
894 $messenger->im($row['user_jabber'], $row['username']); |
|
895 $notify_type = $row['user_notify_type']; |
|
896 } |
|
897 else |
|
898 { |
|
899 $notify_type = NOTIFY_EMAIL; |
|
900 } |
|
901 |
|
902 $messenger->anti_abuse_headers($config, $user); |
|
903 |
|
904 $messenger->assign_vars(array( |
|
905 'BOARD_CONTACT' => $config['board_contact'], |
|
906 'TO_USERNAME' => htmlspecialchars_decode($row['to_name']), |
|
907 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), |
|
908 'MESSAGE' => htmlspecialchars_decode($message)) |
|
909 ); |
|
910 |
|
911 if ($topic_id) |
|
912 { |
|
913 $messenger->assign_vars(array( |
|
914 'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']), |
|
915 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id") |
|
916 ); |
|
917 } |
|
918 |
|
919 $messenger->send($notify_type); |
|
920 } |
|
921 |
|
922 meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); |
|
923 $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&t=$topic_id") . '">', '</a>'); |
|
924 trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message); |
|
925 } |
|
926 } |
|
927 |
|
928 if ($user_id) |
|
929 { |
|
930 $template->assign_vars(array( |
|
931 'S_SEND_USER' => true, |
|
932 'USERNAME' => $row['username'], |
|
933 |
|
934 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'], |
|
935 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id)) |
|
936 ); |
|
937 } |
|
938 else |
|
939 { |
|
940 $template->assign_vars(array( |
|
941 'EMAIL' => $email, |
|
942 'NAME' => $name, |
|
943 'S_LANG_OPTIONS' => language_select($email_lang), |
|
944 |
|
945 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'], |
|
946 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&t=' . $topic_id)) |
|
947 ); |
|
948 } |
|
949 |
|
950 $template->assign_vars(array( |
|
951 'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '', |
|
952 'SUBJECT' => $subject, |
|
953 'MESSAGE' => $message, |
|
954 ) |
|
955 ); |
|
956 |
|
957 break; |
|
958 |
|
959 case 'group': |
|
960 default: |
|
961 // The basic memberlist |
|
962 $page_title = $user->lang['MEMBERLIST']; |
|
963 $template_html = 'memberlist_body.html'; |
|
964 |
|
965 // Sorting |
|
966 $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); |
|
967 $sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber'); |
|
968 |
|
969 if ($auth->acl_get('a_user')) |
|
970 { |
|
971 $sort_key_text['e'] = $user->lang['SORT_EMAIL']; |
|
972 $sort_key_sql['e'] = 'u.user_email'; |
|
973 } |
|
974 |
|
975 if ($auth->acl_get('u_viewonline')) |
|
976 { |
|
977 $sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE']; |
|
978 $sort_key_sql['l'] = 'u.user_lastvisit'; |
|
979 } |
|
980 |
|
981 $sort_key_text['m'] = $user->lang['SORT_RANK']; |
|
982 $sort_key_sql['m'] = 'u.user_rank'; |
|
983 |
|
984 $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); |
|
985 |
|
986 $s_sort_key = ''; |
|
987 foreach ($sort_key_text as $key => $value) |
|
988 { |
|
989 $selected = ($sort_key == $key) ? ' selected="selected"' : ''; |
|
990 $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
|
991 } |
|
992 |
|
993 $s_sort_dir = ''; |
|
994 foreach ($sort_dir_text as $key => $value) |
|
995 { |
|
996 $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; |
|
997 $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
|
998 } |
|
999 |
|
1000 // Additional sorting options for user search ... if search is enabled, if not |
|
1001 // then only admins can make use of this (for ACP functionality) |
|
1002 $sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = ''; |
|
1003 |
|
1004 |
|
1005 $form = request_var('form', ''); |
|
1006 $field = request_var('field', ''); |
|
1007 $select_single = request_var('select_single', false); |
|
1008 |
|
1009 // Search URL parameters, if any of these are in the URL we do a search |
|
1010 $search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip'); |
|
1011 |
|
1012 // We validate form and field here, only id/class allowed |
|
1013 $form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form; |
|
1014 $field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field; |
|
1015 if (($mode == 'searchuser' || sizeof(array_intersect(array_keys($_GET), $search_params)) > 0) && ($config['load_search'] || $auth->acl_get('a_'))) |
|
1016 { |
|
1017 $username = request_var('username', '', true); |
|
1018 $email = strtolower(request_var('email', '')); |
|
1019 $icq = request_var('icq', ''); |
|
1020 $aim = request_var('aim', ''); |
|
1021 $yahoo = request_var('yahoo', ''); |
|
1022 $msn = request_var('msn', ''); |
|
1023 $jabber = request_var('jabber', ''); |
|
1024 $search_group_id = request_var('search_group_id', 0); |
|
1025 |
|
1026 // when using these, make sure that we actually have values defined in $find_key_match |
|
1027 $joined_select = request_var('joined_select', 'lt'); |
|
1028 $active_select = request_var('active_select', 'lt'); |
|
1029 $count_select = request_var('count_select', 'eq'); |
|
1030 |
|
1031 $joined = explode('-', request_var('joined', '')); |
|
1032 $active = explode('-', request_var('active', '')); |
|
1033 $count = (request_var('count', '') !== '') ? request_var('count', 0) : ''; |
|
1034 $ipdomain = request_var('ip', ''); |
|
1035 |
|
1036 $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); |
|
1037 |
|
1038 $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); |
|
1039 $s_find_count = ''; |
|
1040 foreach ($find_count as $key => $value) |
|
1041 { |
|
1042 $selected = ($count_select == $key) ? ' selected="selected"' : ''; |
|
1043 $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
|
1044 } |
|
1045 |
|
1046 $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); |
|
1047 $s_find_join_time = ''; |
|
1048 foreach ($find_time as $key => $value) |
|
1049 { |
|
1050 $selected = ($joined_select == $key) ? ' selected="selected"' : ''; |
|
1051 $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
|
1052 } |
|
1053 |
|
1054 $s_find_active_time = ''; |
|
1055 foreach ($find_time as $key => $value) |
|
1056 { |
|
1057 $selected = ($active_select == $key) ? ' selected="selected"' : ''; |
|
1058 $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
|
1059 } |
|
1060 |
|
1061 $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; |
|
1062 $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; |
|
1063 $sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : ''; |
|
1064 $sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : ''; |
|
1065 $sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : ''; |
|
1066 $sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : ''; |
|
1067 $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : ''; |
|
1068 $sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; |
|
1069 |
|
1070 if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3) |
|
1071 { |
|
1072 // Before PHP 5.1 an error value -1 can be returned instead of false. |
|
1073 // Theoretically gmmktime() can also legitimately return -1 as an actual timestamp. |
|
1074 // But since we do not pass the $second parameter to gmmktime(), |
|
1075 // an actual unix timestamp -1 cannot be returned in this case. |
|
1076 // Thus we can check whether it is -1 and treat -1 as an error. |
|
1077 $joined_time = gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]); |
|
1078 |
|
1079 if ($joined_time !== false && $joined_time !== -1) |
|
1080 { |
|
1081 $sql_where .= " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . $joined_time; |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 if (isset($find_key_match[$active_select]) && sizeof($active) == 3 && $auth->acl_get('u_viewonline')) |
|
1086 { |
|
1087 $active_time = gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]); |
|
1088 |
|
1089 if ($active_time !== false && $active_time !== -1) |
|
1090 { |
|
1091 $sql_where .= " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . $active_time; |
|
1092 } |
|
1093 } |
|
1094 |
|
1095 $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : ''; |
|
1096 |
|
1097 if ($search_group_id) |
|
1098 { |
|
1099 $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; |
|
1100 } |
|
1101 |
|
1102 if ($ipdomain && $auth->acl_getf_global('m_info')) |
|
1103 { |
|
1104 if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz')) |
|
1105 { |
|
1106 $hostnames = gethostbynamel($ipdomain); |
|
1107 |
|
1108 if ($hostnames !== false) |
|
1109 { |
|
1110 $ips = "'" . implode('\', \'', array_map(array($db, 'sql_escape'), preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "\\1", gethostbynamel($ipdomain)))) . "'"; |
|
1111 } |
|
1112 else |
|
1113 { |
|
1114 $ips = false; |
|
1115 } |
|
1116 } |
|
1117 else |
|
1118 { |
|
1119 $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'"; |
|
1120 } |
|
1121 |
|
1122 if ($ips === false) |
|
1123 { |
|
1124 // A minor fudge but it does the job :D |
|
1125 $sql_where .= " AND u.user_id = 0"; |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 $ip_forums = array_keys($auth->acl_getf('m_info', true)); |
|
1130 |
|
1131 $sql = 'SELECT DISTINCT poster_id |
|
1132 FROM ' . POSTS_TABLE . ' |
|
1133 WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips) |
|
1134 AND forum_id IN (0, " . implode(', ', $ip_forums) . ')'; |
|
1135 $result = $db->sql_query($sql); |
|
1136 |
|
1137 if ($row = $db->sql_fetchrow($result)) |
|
1138 { |
|
1139 $ip_sql = array(); |
|
1140 do |
|
1141 { |
|
1142 $ip_sql[] = $row['poster_id']; |
|
1143 } |
|
1144 while ($row = $db->sql_fetchrow($result)); |
|
1145 |
|
1146 $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql); |
|
1147 } |
|
1148 else |
|
1149 { |
|
1150 // A minor fudge but it does the job :D |
|
1151 $sql_where .= " AND u.user_id = 0"; |
|
1152 } |
|
1153 unset($ip_forums); |
|
1154 |
|
1155 $db->sql_freeresult($result); |
|
1156 } |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 $first_char = request_var('first_char', ''); |
|
1161 |
|
1162 if ($first_char == 'other') |
|
1163 { |
|
1164 for ($i = 97; $i < 123; $i++) |
|
1165 { |
|
1166 $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char); |
|
1167 } |
|
1168 } |
|
1169 else if ($first_char) |
|
1170 { |
|
1171 $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char); |
|
1172 } |
|
1173 |
|
1174 // Are we looking at a usergroup? If so, fetch additional info |
|
1175 // and further restrict the user info query |
|
1176 if ($mode == 'group') |
|
1177 { |
|
1178 // We JOIN here to save a query for determining membership for hidden groups. ;) |
|
1179 $sql = 'SELECT g.*, ug.user_id |
|
1180 FROM ' . GROUPS_TABLE . ' g |
|
1181 LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] . " AND ug.group_id = $group_id) |
|
1182 WHERE g.group_id = $group_id"; |
|
1183 $result = $db->sql_query($sql); |
|
1184 $group_row = $db->sql_fetchrow($result); |
|
1185 $db->sql_freeresult($result); |
|
1186 |
|
1187 if (!$group_row) |
|
1188 { |
|
1189 trigger_error('NO_GROUP'); |
|
1190 } |
|
1191 |
|
1192 switch ($group_row['group_type']) |
|
1193 { |
|
1194 case GROUP_OPEN: |
|
1195 $group_row['l_group_type'] = 'OPEN'; |
|
1196 break; |
|
1197 |
|
1198 case GROUP_CLOSED: |
|
1199 $group_row['l_group_type'] = 'CLOSED'; |
|
1200 break; |
|
1201 |
|
1202 case GROUP_HIDDEN: |
|
1203 $group_row['l_group_type'] = 'HIDDEN'; |
|
1204 |
|
1205 // Check for membership or special permissions |
|
1206 if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id']) |
|
1207 { |
|
1208 trigger_error('NO_GROUP'); |
|
1209 } |
|
1210 break; |
|
1211 |
|
1212 case GROUP_SPECIAL: |
|
1213 $group_row['l_group_type'] = 'SPECIAL'; |
|
1214 break; |
|
1215 |
|
1216 case GROUP_FREE: |
|
1217 $group_row['l_group_type'] = 'FREE'; |
|
1218 break; |
|
1219 } |
|
1220 |
|
1221 // Misusing the avatar function for displaying group avatars... |
|
1222 $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR'); |
|
1223 |
|
1224 $rank_title = $rank_img = $rank_img_src = ''; |
|
1225 if ($group_row['group_rank']) |
|
1226 { |
|
1227 if (isset($ranks['special'][$group_row['group_rank']])) |
|
1228 { |
|
1229 $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title']; |
|
1230 } |
|
1231 $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] . '" alt="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" title="' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '" /><br />' : ''; |
|
1232 $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : ''; |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 $rank_title = ''; |
|
1237 $rank_img = ''; |
|
1238 $rank_img_src = ''; |
|
1239 } |
|
1240 |
|
1241 $template->assign_vars(array( |
|
1242 'GROUP_DESC' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), |
|
1243 'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'], |
|
1244 'GROUP_COLOR' => $group_row['group_colour'], |
|
1245 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], |
|
1246 'GROUP_RANK' => $rank_title, |
|
1247 |
|
1248 'AVATAR_IMG' => $avatar_img, |
|
1249 'RANK_IMG' => $rank_img, |
|
1250 'RANK_IMG_SRC' => $rank_img_src, |
|
1251 |
|
1252 'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&g=' . $group_id) : '',) |
|
1253 ); |
|
1254 |
|
1255 $sql_select = ', ug.group_leader'; |
|
1256 $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; |
|
1257 $order_by = 'ug.group_leader DESC, '; |
|
1258 |
|
1259 $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id"; |
|
1260 $sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id"; |
|
1261 } |
|
1262 |
|
1263 // Sorting and order |
|
1264 if (!isset($sort_key_sql[$sort_key])) |
|
1265 { |
|
1266 $sort_key = $default_key; |
|
1267 } |
|
1268 |
|
1269 $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); |
|
1270 |
|
1271 // Unfortunately we must do this here for sorting by rank, else the sort order is applied wrongly |
|
1272 if ($sort_key == 'm') |
|
1273 { |
|
1274 $order_by .= ', u.user_posts DESC'; |
|
1275 } |
|
1276 |
|
1277 // Count the users ... |
|
1278 if ($sql_where) |
|
1279 { |
|
1280 $sql = 'SELECT COUNT(u.user_id) AS total_users |
|
1281 FROM ' . USERS_TABLE . " u$sql_from |
|
1282 WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ") |
|
1283 $sql_where"; |
|
1284 $result = $db->sql_query($sql); |
|
1285 $total_users = (int) $db->sql_fetchfield('total_users'); |
|
1286 $db->sql_freeresult($result); |
|
1287 } |
|
1288 else |
|
1289 { |
|
1290 $total_users = $config['num_users']; |
|
1291 } |
|
1292 |
|
1293 // Build a relevant pagination_url |
|
1294 $params = $sort_params = array(); |
|
1295 |
|
1296 // We do not use request_var() here directly to save some calls (not all variables are set) |
|
1297 $check_params = array( |
|
1298 'g' => array('g', 0), |
|
1299 'sk' => array('sk', $default_key), |
|
1300 'sd' => array('sd', 'a'), |
|
1301 'form' => array('form', ''), |
|
1302 'field' => array('field', ''), |
|
1303 'select_single' => array('select_single', $select_single), |
|
1304 'username' => array('username', '', true), |
|
1305 'email' => array('email', ''), |
|
1306 'icq' => array('icq', ''), |
|
1307 'aim' => array('aim', ''), |
|
1308 'yahoo' => array('yahoo', ''), |
|
1309 'msn' => array('msn', ''), |
|
1310 'jabber' => array('jabber', ''), |
|
1311 'search_group_id' => array('search_group_id', 0), |
|
1312 'joined_select' => array('joined_select', 'lt'), |
|
1313 'active_select' => array('active_select', 'lt'), |
|
1314 'count_select' => array('count_select', 'eq'), |
|
1315 'joined' => array('joined', ''), |
|
1316 'active' => array('active', ''), |
|
1317 'count' => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''), |
|
1318 'ip' => array('ip', ''), |
|
1319 'first_char' => array('first_char', ''), |
|
1320 ); |
|
1321 |
|
1322 $u_first_char_params = array(); |
|
1323 foreach ($check_params as $key => $call) |
|
1324 { |
|
1325 if (!isset($_REQUEST[$key])) |
|
1326 { |
|
1327 continue; |
|
1328 } |
|
1329 |
|
1330 $param = call_user_func_array('request_var', $call); |
|
1331 $param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : $param); |
|
1332 $params[] = $param; |
|
1333 |
|
1334 if ($key != 'first_char') |
|
1335 { |
|
1336 $u_first_char_params[] = $param; |
|
1337 } |
|
1338 if ($key != 'sk' && $key != 'sd') |
|
1339 { |
|
1340 $sort_params[] = $param; |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", "start=$start" . (!empty($params) ? '&' . implode('&', $params) : '')); |
|
1345 |
|
1346 if ($mode) |
|
1347 { |
|
1348 $params[] = "mode=$mode"; |
|
1349 } |
|
1350 $sort_params[] = "mode=$mode"; |
|
1351 |
|
1352 $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); |
|
1353 $sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params)); |
|
1354 |
|
1355 unset($search_params, $sort_params); |
|
1356 |
|
1357 $u_first_char_params = implode('&', $u_first_char_params); |
|
1358 $u_first_char_params .= ($u_first_char_params) ? '&' : ''; |
|
1359 |
|
1360 $first_characters = array(); |
|
1361 $first_characters[''] = $user->lang['ALL']; |
|
1362 for ($i = 97; $i < 123; $i++) |
|
1363 { |
|
1364 $first_characters[chr($i)] = chr($i - 32); |
|
1365 } |
|
1366 $first_characters['other'] = $user->lang['OTHER']; |
|
1367 |
|
1368 foreach ($first_characters as $char => $desc) |
|
1369 { |
|
1370 $template->assign_block_vars('first_char', array( |
|
1371 'DESC' => $desc, |
|
1372 'VALUE' => $char, |
|
1373 'S_SELECTED' => ($first_char == $char) ? true : false, |
|
1374 'U_SORT' => append_sid("{$phpbb_root_path}memberlist.$phpEx", $u_first_char_params . 'first_char=' . $char) . '#memberlist', |
|
1375 )); |
|
1376 } |
|
1377 |
|
1378 // Some search user specific data |
|
1379 if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_'))) |
|
1380 { |
|
1381 $group_selected = request_var('search_group_id', 0); |
|
1382 $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>'; |
|
1383 $group_ids = array(); |
|
1384 |
|
1385 /** |
|
1386 * @todo add this to a separate function (function is responsible for returning the groups the user is able to see based on the users group membership) |
|
1387 */ |
|
1388 |
|
1389 if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) |
|
1390 { |
|
1391 $sql = 'SELECT group_id, group_name, group_type |
|
1392 FROM ' . GROUPS_TABLE; |
|
1393 |
|
1394 if (!$config['coppa_enable']) |
|
1395 { |
|
1396 $sql .= " WHERE group_name <> 'REGISTERED_COPPA'"; |
|
1397 } |
|
1398 |
|
1399 $sql .= ' ORDER BY group_name ASC'; |
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 $sql = 'SELECT g.group_id, g.group_name, g.group_type |
|
1404 FROM ' . GROUPS_TABLE . ' g |
|
1405 LEFT JOIN ' . USER_GROUP_TABLE . ' ug |
|
1406 ON ( |
|
1407 g.group_id = ug.group_id |
|
1408 AND ug.user_id = ' . $user->data['user_id'] . ' |
|
1409 AND ug.user_pending = 0 |
|
1410 ) |
|
1411 WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')'; |
|
1412 |
|
1413 if (!$config['coppa_enable']) |
|
1414 { |
|
1415 $sql .= " AND g.group_name <> 'REGISTERED_COPPA'"; |
|
1416 } |
|
1417 |
|
1418 $sql .= ' ORDER BY g.group_name ASC'; |
|
1419 } |
|
1420 $result = $db->sql_query($sql); |
|
1421 |
|
1422 while ($row = $db->sql_fetchrow($result)) |
|
1423 { |
|
1424 $group_ids[] = $row['group_id']; |
|
1425 $s_group_select .= '<option value="' . $row['group_id'] . '"' . (($group_selected == $row['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; |
|
1426 } |
|
1427 $db->sql_freeresult($result); |
|
1428 |
|
1429 if ($group_selected !== 0 && !in_array($group_selected, $group_ids)) |
|
1430 { |
|
1431 trigger_error('NO_GROUP'); |
|
1432 } |
|
1433 |
|
1434 $template->assign_vars(array( |
|
1435 'USERNAME' => $username, |
|
1436 'EMAIL' => $email, |
|
1437 'ICQ' => $icq, |
|
1438 'AIM' => $aim, |
|
1439 'YAHOO' => $yahoo, |
|
1440 'MSNM' => $msn, |
|
1441 'JABBER' => $jabber, |
|
1442 'JOINED' => implode('-', $joined), |
|
1443 'ACTIVE' => implode('-', $active), |
|
1444 'COUNT' => $count, |
|
1445 'IP' => $ipdomain, |
|
1446 |
|
1447 'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false, |
|
1448 'S_EMAIL_SEARCH_ALLOWED'=> ($auth->acl_get('a_user')) ? true : false, |
|
1449 'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false, |
|
1450 'S_SEARCH_USER' => true, |
|
1451 'S_FORM_NAME' => $form, |
|
1452 'S_FIELD_NAME' => $field, |
|
1453 'S_SELECT_SINGLE' => $select_single, |
|
1454 'S_COUNT_OPTIONS' => $s_find_count, |
|
1455 'S_SORT_OPTIONS' => $s_sort_key, |
|
1456 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, |
|
1457 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, |
|
1458 'S_GROUP_SELECT' => $s_group_select, |
|
1459 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) |
|
1460 ); |
|
1461 } |
|
1462 |
|
1463 // Get us some users :D |
|
1464 $sql = "SELECT u.user_id |
|
1465 FROM " . USERS_TABLE . " u |
|
1466 $sql_from |
|
1467 WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ") |
|
1468 $sql_where |
|
1469 ORDER BY $order_by"; |
|
1470 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); |
|
1471 |
|
1472 $user_list = array(); |
|
1473 while ($row = $db->sql_fetchrow($result)) |
|
1474 { |
|
1475 $user_list[] = (int) $row['user_id']; |
|
1476 } |
|
1477 $db->sql_freeresult($result); |
|
1478 $leaders_set = false; |
|
1479 // So, did we get any users? |
|
1480 if (sizeof($user_list)) |
|
1481 { |
|
1482 // Session time?! Session time... |
|
1483 $sql = 'SELECT session_user_id, MAX(session_time) AS session_time |
|
1484 FROM ' . SESSIONS_TABLE . ' |
|
1485 WHERE session_time >= ' . (time() - $config['session_length']) . ' |
|
1486 AND ' . $db->sql_in_set('session_user_id', $user_list) . ' |
|
1487 GROUP BY session_user_id'; |
|
1488 $result = $db->sql_query($sql); |
|
1489 |
|
1490 $session_times = array(); |
|
1491 while ($row = $db->sql_fetchrow($result)) |
|
1492 { |
|
1493 $session_times[$row['session_user_id']] = $row['session_time']; |
|
1494 } |
|
1495 $db->sql_freeresult($result); |
|
1496 |
|
1497 // Do the SQL thang |
|
1498 if ($mode == 'group') |
|
1499 { |
|
1500 $sql = "SELECT u.* |
|
1501 $sql_select |
|
1502 FROM " . USERS_TABLE . " u |
|
1503 $sql_from |
|
1504 WHERE " . $db->sql_in_set('u.user_id', $user_list) . " |
|
1505 $sql_where_data"; |
|
1506 } |
|
1507 else |
|
1508 { |
|
1509 $sql = 'SELECT * |
|
1510 FROM ' . USERS_TABLE . ' |
|
1511 WHERE ' . $db->sql_in_set('user_id', $user_list); |
|
1512 } |
|
1513 $result = $db->sql_query($sql); |
|
1514 |
|
1515 $id_cache = array(); |
|
1516 while ($row = $db->sql_fetchrow($result)) |
|
1517 { |
|
1518 $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0; |
|
1519 $row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; |
|
1520 |
|
1521 $id_cache[$row['user_id']] = $row; |
|
1522 } |
|
1523 $db->sql_freeresult($result); |
|
1524 |
|
1525 // Load custom profile fields |
|
1526 if ($config['load_cpf_memberlist']) |
|
1527 { |
|
1528 include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); |
|
1529 $cp = new custom_profile(); |
|
1530 |
|
1531 // Grab all profile fields from users in id cache for later use - similar to the poster cache |
|
1532 $profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list); |
|
1533 } |
|
1534 |
|
1535 // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date... |
|
1536 if ($sort_key == 'l') |
|
1537 { |
|
1538 // uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));")); |
|
1539 usort($user_list, '_sort_last_active'); |
|
1540 } |
|
1541 |
|
1542 for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i) |
|
1543 { |
|
1544 $user_id = $user_list[$i]; |
|
1545 $row =& $id_cache[$user_id]; |
|
1546 $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false; |
|
1547 $leaders_set = ($leaders_set || $is_leader); |
|
1548 |
|
1549 $cp_row = array(); |
|
1550 if ($config['load_cpf_memberlist']) |
|
1551 { |
|
1552 $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array(); |
|
1553 } |
|
1554 |
|
1555 $memberrow = array_merge(show_profile($row), array( |
|
1556 'ROW_NUMBER' => $i + ($start + 1), |
|
1557 |
|
1558 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, |
|
1559 'S_GROUP_LEADER' => $is_leader, |
|
1560 |
|
1561 'U_VIEW_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id)) |
|
1562 ); |
|
1563 |
|
1564 if (isset($cp_row['row']) && sizeof($cp_row['row'])) |
|
1565 { |
|
1566 $memberrow = array_merge($memberrow, $cp_row['row']); |
|
1567 } |
|
1568 |
|
1569 $template->assign_block_vars('memberrow', $memberrow); |
|
1570 |
|
1571 if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) |
|
1572 { |
|
1573 foreach ($cp_row['blockrow'] as $field_data) |
|
1574 { |
|
1575 $template->assign_block_vars('memberrow.custom_fields', $field_data); |
|
1576 } |
|
1577 } |
|
1578 |
|
1579 unset($id_cache[$user_id]); |
|
1580 } |
|
1581 } |
|
1582 |
|
1583 // Generate page |
|
1584 $template->assign_vars(array( |
|
1585 'PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start), |
|
1586 'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start), |
|
1587 'TOTAL_USERS' => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users), |
|
1588 |
|
1589 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), |
|
1590 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), |
|
1591 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), |
|
1592 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), |
|
1593 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), |
|
1594 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), |
|
1595 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), |
|
1596 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), |
|
1597 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), |
|
1598 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), |
|
1599 |
|
1600 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', |
|
1601 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser') ? $u_hide_find_member : '', |
|
1602 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1603 'U_SORT_FROM' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1604 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1605 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1606 'U_SORT_EMAIL' => $sort_url . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1607 'U_SORT_WEBSITE' => $sort_url . '&sk=f&sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1608 'U_SORT_LOCATION' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1609 'U_SORT_ICQ' => $sort_url . '&sk=g&sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1610 'U_SORT_AIM' => $sort_url . '&sk=h&sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1611 'U_SORT_MSN' => $sort_url . '&sk=i&sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1612 'U_SORT_YIM' => $sort_url . '&sk=j&sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1613 'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '', |
|
1614 'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1615 'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'), |
|
1616 |
|
1617 'S_SHOW_GROUP' => ($mode == 'group') ? true : false, |
|
1618 'S_VIEWONLINE' => $auth->acl_get('u_viewonline'), |
|
1619 'S_LEADERS_SET' => $leaders_set, |
|
1620 'S_MODE_SELECT' => $s_sort_key, |
|
1621 'S_ORDER_SELECT' => $s_sort_dir, |
|
1622 'S_MODE_ACTION' => $pagination_url) |
|
1623 ); |
|
1624 } |
|
1625 |
|
1626 // Output the page |
|
1627 page_header($page_title, false); |
|
1628 |
|
1629 $template->set_filenames(array( |
|
1630 'body' => $template_html) |
|
1631 ); |
|
1632 make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); |
|
1633 |
|
1634 page_footer(); |
|
1635 |
|
1636 /** |
|
1637 * Prepare profile data |
|
1638 */ |
|
1639 function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false) |
|
1640 { |
|
1641 global $config, $auth, $template, $user, $phpEx, $phpbb_root_path; |
|
1642 |
|
1643 $username = $data['username']; |
|
1644 $user_id = $data['user_id']; |
|
1645 |
|
1646 $rank_title = $rank_img = $rank_img_src = ''; |
|
1647 get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src); |
|
1648 |
|
1649 if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user')) |
|
1650 { |
|
1651 $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']); |
|
1652 } |
|
1653 else |
|
1654 { |
|
1655 $email = ''; |
|
1656 } |
|
1657 |
|
1658 if ($config['load_onlinetrack']) |
|
1659 { |
|
1660 $update_time = $config['load_online_time'] * 60; |
|
1661 $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 $online = false; |
|
1666 } |
|
1667 |
|
1668 if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) |
|
1669 { |
|
1670 $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit']; |
|
1671 } |
|
1672 else |
|
1673 { |
|
1674 $last_visit = ''; |
|
1675 } |
|
1676 |
|
1677 $age = ''; |
|
1678 |
|
1679 if ($config['allow_birthdays'] && $data['user_birthday']) |
|
1680 { |
|
1681 list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday'])); |
|
1682 |
|
1683 if ($bday_year) |
|
1684 { |
|
1685 $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst); |
|
1686 |
|
1687 $diff = $now['mon'] - $bday_month; |
|
1688 if ($diff == 0) |
|
1689 { |
|
1690 $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; |
|
1691 } |
|
1692 else |
|
1693 { |
|
1694 $diff = ($diff < 0) ? 1 : 0; |
|
1695 } |
|
1696 |
|
1697 $age = max(0, (int) ($now['year'] - $bday_year - $diff)); |
|
1698 } |
|
1699 } |
|
1700 |
|
1701 // Dump it out to the template |
|
1702 return array( |
|
1703 'AGE' => $age, |
|
1704 'RANK_TITLE' => $rank_title, |
|
1705 'JOINED' => $user->format_date($data['user_regdate']), |
|
1706 'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit), |
|
1707 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, |
|
1708 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, |
|
1709 |
|
1710 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), |
|
1711 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), |
|
1712 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), |
|
1713 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), |
|
1714 |
|
1715 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), |
|
1716 |
|
1717 'AVATAR_IMG' => get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']), |
|
1718 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), |
|
1719 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, |
|
1720 'RANK_IMG' => $rank_img, |
|
1721 'RANK_IMG_SRC' => $rank_img_src, |
|
1722 'ICQ_STATUS_IMG' => (!empty($data['user_icq'])) ? '<img src="http://web.icq.com/whitepages/online?icq=' . $data['user_icq'] . '&img=5" width="18" height="18" />' : '', |
|
1723 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, |
|
1724 |
|
1725 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, |
|
1726 |
|
1727 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', |
|
1728 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '', |
|
1729 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', |
|
1730 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($data['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', |
|
1731 'U_EMAIL' => $email, |
|
1732 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', |
|
1733 'U_SHORT_WWW' => (!empty($data['user_website'])) ? ((strlen($data['user_website']) > 55) ? substr($data['user_website'], 0, 39) . ' ... ' . substr($data['user_website'], -10) : $data['user_website']) : '', |
|
1734 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '', |
|
1735 'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', |
|
1736 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '', |
|
1737 'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', |
|
1738 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', |
|
1739 'LOCATION' => ($data['user_from']) ? $data['user_from'] : '', |
|
1740 |
|
1741 'USER_ICQ' => $data['user_icq'], |
|
1742 'USER_AIM' => $data['user_aim'], |
|
1743 'USER_YIM' => $data['user_yim'], |
|
1744 'USER_MSN' => $data['user_msnm'], |
|
1745 'USER_JABBER' => $data['user_jabber'], |
|
1746 'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', |
|
1747 |
|
1748 'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username), |
|
1749 ); |
|
1750 } |
|
1751 |
|
1752 function _sort_last_active($first, $second) |
|
1753 { |
|
1754 global $id_cache, $sort_dir; |
|
1755 |
|
1756 $lesser_than = ($sort_dir === 'd') ? -1 : 1; |
|
1757 |
|
1758 if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader'])) |
|
1759 { |
|
1760 return -1; |
|
1761 } |
|
1762 else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader']) |
|
1763 { |
|
1764 return 1; |
|
1765 } |
|
1766 else |
|
1767 { |
|
1768 return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']); |
|
1769 } |
|
1770 } |
|
1771 |
|
1772 ?> |