5
* @version $Id: memberlist.php,v 1.254 2007/10/05 14:30:06 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
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);
20
// Start session management
21
$user->session_begin();
22
$auth->acl($user->data);
23
$user->setup(array('memberlist', 'groups'));
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);
34
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
36
trigger_error('NO_MODE');
45
// Can this user view profiles/memberlist?
46
if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
48
if ($user->data['user_id'] != ANONYMOUS)
50
trigger_error('NO_VIEW_USERS');
53
login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST']));
58
$start = request_var('start', 0);
59
$submit = (isset($_POST['submit'])) ? true : false;
62
$sort_key = request_var('sk', $default_key);
63
$sort_dir = request_var('sd', 'a');
66
// Grab rank information for later
67
$ranks = $cache->obtain_ranks();
70
// What do you want to do today? ... oops, I think that line is taken ...
74
// Display a listing of board admins, moderators
75
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
77
$page_title = $user->lang['THE_TEAM'];
78
$template_html = 'memberlist_leaders.html';
80
$user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false);
82
$admin_id_ary = $global_mod_id_ary = $mod_id_ary = $forum_id_ary = array();
83
foreach ($user_ary as $forum_id => $forum_ary)
85
foreach ($forum_ary as $auth_option => $id_ary)
89
if ($auth_option == 'a_')
91
$admin_id_ary = array_merge($admin_id_ary, $id_ary);
95
$global_mod_id_ary = array_merge($global_mod_id_ary, $id_ary);
101
$mod_id_ary = array_merge($mod_id_ary, $id_ary);
106
foreach ($id_ary as $id)
108
$forum_id_ary[$id][] = $forum_id;
114
$admin_id_ary = array_unique($admin_id_ary);
115
$global_mod_id_ary = array_unique($global_mod_id_ary);
117
$mod_id_ary = array_merge($mod_id_ary, $global_mod_id_ary);
118
$mod_id_ary = array_unique($mod_id_ary);
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);
128
// Get group memberships for the admin id ary...
129
$admin_memberships = group_memberships($admin_group_id, $admin_id_ary);
131
$admin_user_ids = array();
133
if (!empty($admin_memberships))
135
// ok, we only need the user ids...
136
foreach ($admin_memberships as $row)
138
$admin_user_ids[$row['user_id']] = true;
141
unset($admin_memberships);
143
$sql = 'SELECT forum_id, forum_name
144
FROM ' . FORUMS_TABLE . '
145
WHERE forum_type = ' . FORUM_POST;
146
$result = $db->sql_query($sql);
149
while ($row = $db->sql_fetchrow($result))
151
$forums[$row['forum_id']] = $row['forum_name'];
153
$db->sql_freeresult($result);
155
$sql = $db->sql_build_query('SELECT', array(
156
'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',
163
'LEFT_JOIN' => array(
165
'FROM' => array(USER_GROUP_TABLE => 'ug'),
166
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id']
170
'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary)), false, true) . '
171
AND u.group_id = g.group_id',
173
'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
175
$result = $db->sql_query($sql);
177
while ($row = $db->sql_fetchrow($result))
179
$which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod';
181
// We sort out admins not within the 'Administrators' group.
182
// Else, we will list those as admin only having the permission to view logs for example.
183
if ($which_row == 'admin' && empty($admin_user_ids[$row['user_id']]))
185
// Remove from admin_id_ary, because the user may be a mod instead
186
unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]);
188
if (!in_array($row['user_id'], $mod_id_ary) && !in_array($row['user_id'], $global_mod_id_ary))
198
$s_forum_select = '';
199
$undisclosed_forum = false;
201
if (isset($forum_id_ary[$row['user_id']]) && !in_array($row['user_id'], $global_mod_id_ary))
203
if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']])))
205
foreach ($forum_id_ary[$row['user_id']] as $forum_id)
207
if (isset($forums[$forum_id]))
209
if ($auth->acl_get('f_list', $forum_id))
211
$s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>';
215
$undisclosed_forum = true;
222
// If the mod is only moderating non-viewable forums we skip the user. There is no gain in displaying the person then...
223
if (!$s_forum_select && $undisclosed_forum)
225
// $s_forum_select = '<option value="">' . $user->lang['FORUM_UNDISCLOSED'] . '</option>';
229
// The person is moderating several "public" forums, therefore the person should be listed, but not giving the real group name if hidden.
230
if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id'])
232
$group_name = $user->lang['GROUP_UNDISCLOSED'];
237
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
238
$u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']);
241
$rank_title = $rank_img = '';
242
get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
244
$template->assign_block_vars($which_row, array(
245
'USER_ID' => $row['user_id'],
246
'FORUMS' => $s_forum_select,
247
'RANK_TITLE' => $rank_title,
248
'GROUP_NAME' => $group_name,
249
'GROUP_COLOR' => $row['group_colour'],
251
'RANK_IMG' => $rank_img,
252
'RANK_IMG_SRC' => $rank_img_src,
254
'U_GROUP' => $u_group,
255
'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']) : '',
257
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
258
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
259
'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
260
'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
263
$db->sql_freeresult($result);
265
$template->assign_vars(array(
266
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']))
272
$page_title = $user->lang['IM_USER'];
273
$template_html = 'memberlist_im.html';
275
if (!$auth->acl_get('u_sendim'))
277
trigger_error('NOT_AUTHORISED');
285
$sql_field = 'user_aim';
286
$s_select = 'S_SEND_AIM';
292
$sql_field = 'user_msnm';
293
$s_select = 'S_SEND_MSNM';
299
$sql_field = 'user_jabber';
300
$s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER';
301
$s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id");
305
trigger_error('NO_MODE', E_USER_ERROR);
309
// Grab relevant data
310
$sql = "SELECT user_id, username, user_email, user_lang, $sql_field
311
FROM " . USERS_TABLE . "
312
WHERE user_id = $user_id
313
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
314
$result = $db->sql_query($sql);
315
$row = $db->sql_fetchrow($result);
316
$db->sql_freeresult($result);
320
trigger_error('NO_USER');
322
else if (empty($row[$sql_field]))
324
trigger_error('IM_NO_DATA');
327
// Post data grab actions
331
add_form_key('memberlist_messaging');
333
if ($submit && @extension_loaded('xml') && $config['jab_enable'])
335
if (check_form_key('memberlist_messaging'))
338
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
340
$subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']);
341
$message = utf8_normalize_nfc(request_var('message', '', true));
345
trigger_error('EMPTY_MESSAGE_IM');
348
$messenger = new messenger(false);
350
$messenger->template('profile_send_im', $row['user_lang']);
351
$messenger->subject(htmlspecialchars_decode($subject));
353
$messenger->replyto($user->data['user_email']);
354
$messenger->im($row['user_jabber'], $row['username']);
356
$messenger->assign_vars(array(
357
'BOARD_CONTACT' => $config['board_contact'],
358
'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']),
359
'TO_USERNAME' => htmlspecialchars_decode($row['username']),
360
'MESSAGE' => htmlspecialchars_decode($message))
363
$messenger->send(NOTIFY_IM);
365
$s_select = 'S_SENT_JABBER';
369
trigger_error('FORM_INVALID');
375
// Send vars to the template
376
$template->assign_vars(array(
377
'IM_CONTACT' => $row[$sql_field],
378
'A_IM_CONTACT' => addslashes($row[$sql_field]),
380
'U_AIM_CONTACT' => ($action == 'aim') ? 'aim:addbuddy?screenname=' . urlencode($row[$sql_field]) : '',
381
'U_AIM_MESSAGE' => ($action == 'aim') ? 'aim:goim?screenname=' . urlencode($row[$sql_field]) . '&message=' . urlencode($config['sitename']) : '',
383
'USERNAME' => $row['username'],
384
'CONTACT_NAME' => $row[$sql_field],
385
'SITENAME' => $config['sitename'],
387
'PRESENCE_IMG' => $presence_img,
389
'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang],
390
'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']),
393
'S_IM_ACTION' => $s_action)
400
if ($user_id == ANONYMOUS && !$username)
402
trigger_error('NO_USER');
407
FROM ' . USERS_TABLE . '
408
WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
409
$result = $db->sql_query($sql);
410
$member = $db->sql_fetchrow($result);
411
$db->sql_freeresult($result);
415
trigger_error('NO_USER');
418
// a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
419
// Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
420
if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
422
if ($member['user_type'] == USER_IGNORE)
424
trigger_error('NO_USER');
426
else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
428
trigger_error('NO_USER');
432
$user_id = (int) $member['user_id'];
435
$sql = 'SELECT g.group_id, g.group_name, g.group_type
436
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
437
WHERE ug.user_id = $user_id
438
AND g.group_id = ug.group_id" . ((!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . '
439
AND ug.user_pending = 0
440
ORDER BY g.group_type, g.group_name';
441
$result = $db->sql_query($sql);
444
while ($row = $db->sql_fetchrow($result))
446
$group_options .= '<option value="' . $row['group_id'] . '"' . (($row['group_id'] == $member['group_id']) ? ' selected="selected"' : '') . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
448
$db->sql_freeresult($result);
450
// What colour is the zebra
451
$sql = 'SELECT friend, foe
452
FROM ' . ZEBRA_TABLE . "
453
WHERE zebra_id = $user_id
454
AND user_id = {$user->data['user_id']}";
456
$result = $db->sql_query($sql);
457
$row = $db->sql_fetchrow($result);
458
$foe = ($row['foe']) ? true : false;
459
$friend = ($row['friend']) ? true : false;
460
$db->sql_freeresult($result);
462
if ($config['load_onlinetrack'])
464
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
465
FROM ' . SESSIONS_TABLE . "
466
WHERE session_user_id = $user_id";
467
$result = $db->sql_query($sql);
468
$row = $db->sql_fetchrow($result);
469
$db->sql_freeresult($result);
471
$member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
472
$member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
476
if ($config['load_user_activity'])
478
display_user_activity($member);
481
// Do the relevant calculations
482
$memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
483
$posts_per_day = $member['user_posts'] / $memberdays;
484
$percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
487
if ($member['user_sig'])
489
$member['user_sig'] = censor_text($member['user_sig']);
491
if ($member['user_sig_bbcode_bitfield'])
493
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
494
$bbcode = new bbcode();
495
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
498
$member['user_sig'] = bbcode_nl2br($member['user_sig']);
499
$member['user_sig'] = smiley_text($member['user_sig']);
502
$poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
504
$template->assign_vars(show_profile($member));
506
// Custom Profile Fields
507
$profile_fields = array();
508
if ($config['load_cpf_viewprofile'])
510
include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
511
$cp = new custom_profile();
512
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
513
$profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
516
// We need to check if the module 'zebra' is accessible
517
$zebra_enabled = false;
519
if ($user->data['user_id'] != $user_id && $user->data['is_registered'])
521
include_once($phpbb_root_path . 'includes/functions_module.' . $phpEx);
522
$module = new p_master();
523
$module->list_modules('ucp');
524
$module->set_active('zebra');
526
$zebra_enabled = ($module->active_module === false) ? false : true;
531
$template->assign_vars(array(
532
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
533
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
535
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
536
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
537
'SIGNATURE' => $member['user_sig'],
539
'AVATAR_IMG' => $poster_avatar,
540
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
541
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
542
'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']),
543
'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']),
544
'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']),
545
'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']),
546
'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']),
547
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
548
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
550
'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'),
551
'S_GROUP_OPTIONS' => $group_options,
552
'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
554
'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) : '',
555
'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}") : '',
557
'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false,
558
'U_ADD_FRIEND' => (!$friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
559
'U_ADD_FOE' => (!$foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode(htmlspecialchars_decode($member['username']))) : '',
560
'U_REMOVE_FRIEND' => ($friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '',
561
'U_REMOVE_FOE' => ($foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&mode=foes&usernames[]=' . $user_id) : '',
564
if (!empty($profile_fields['row']))
566
$template->assign_vars($profile_fields['row']);
569
if (!empty($profile_fields['blockrow']))
571
foreach ($profile_fields['blockrow'] as $field_data)
573
$template->assign_block_vars('custom_fields', $field_data);
577
// Inactive reason/account?
578
if ($member['user_type'] == USER_INACTIVE)
580
$user->add_lang('acp/common');
582
$inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
584
switch ($member['user_inactive_reason'])
586
case INACTIVE_REGISTER:
587
$inactive_reason = $user->lang['INACTIVE_REASON_REGISTER'];
590
case INACTIVE_PROFILE:
591
$inactive_reason = $user->lang['INACTIVE_REASON_PROFILE'];
594
case INACTIVE_MANUAL:
595
$inactive_reason = $user->lang['INACTIVE_REASON_MANUAL'];
598
case INACTIVE_REMIND:
599
$inactive_reason = $user->lang['INACTIVE_REASON_REMIND'];
603
$template->assign_vars(array(
604
'S_USER_INACTIVE' => true,
605
'USER_INACTIVE_REASON' => $inactive_reason)
609
// Now generate page title
610
$page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']);
611
$template_html = 'memberlist_view.html';
618
$page_title = $user->lang['SEND_EMAIL'];
619
$template_html = 'memberlist_email.html';
621
add_form_key('memberlist_email');
623
if (!$config['email_enable'])
625
trigger_error('EMAIL_DISABLED');
628
if (!$auth->acl_get('u_sendemail'))
630
trigger_error('NO_EMAIL');
633
// Are we trying to abuse the facility?
634
if (time() - $user->data['user_emailtime'] < $config['flood_interval'])
636
trigger_error('FLOOD_EMAIL_LIMIT');
639
// Determine action...
640
$user_id = request_var('u', 0);
641
$topic_id = request_var('t', 0);
643
// Send email to user...
646
if ($user_id == ANONYMOUS || !$config['board_email_form'])
648
trigger_error('NO_EMAIL');
651
// Get the appropriate username, etc.
652
$sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
653
FROM ' . USERS_TABLE . "
654
WHERE user_id = $user_id
655
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
656
$result = $db->sql_query($sql);
657
$row = $db->sql_fetchrow($result);
658
$db->sql_freeresult($result);
662
trigger_error('NO_USER');
665
// Can we send email to this user?
666
if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user'))
668
trigger_error('NO_EMAIL');
673
// Send topic heads-up to email address
674
$sql = 'SELECT forum_id, topic_title
675
FROM ' . TOPICS_TABLE . "
676
WHERE topic_id = $topic_id";
677
$result = $db->sql_query($sql);
678
$row = $db->sql_fetchrow($result);
679
$db->sql_freeresult($result);
683
trigger_error('NO_TOPIC');
686
if ($row['forum_id'])
688
if (!$auth->acl_get('f_read', $row['forum_id']))
690
trigger_error('SORRY_AUTH_READ');
693
if (!$auth->acl_get('f_email', $row['forum_id']))
695
trigger_error('NO_EMAIL');
700
// If global announcement, we need to check if the user is able to at least read and email in one forum...
701
if (!$auth->acl_getf_global('f_read'))
703
trigger_error('SORRY_AUTH_READ');
706
if (!$auth->acl_getf_global('f_email'))
708
trigger_error('NO_EMAIL');
714
trigger_error('NO_EMAIL');
719
$name = utf8_normalize_nfc(request_var('name', '', true));
720
$email = request_var('email', '');
721
$email_lang = request_var('lang', $config['default_lang']);
722
$subject = utf8_normalize_nfc(request_var('subject', '', true));
723
$message = utf8_normalize_nfc(request_var('message', '', true));
724
$cc = (isset($_POST['cc_email'])) ? true : false;
725
$submit = (isset($_POST['submit'])) ? true : false;
729
if (!check_form_key('memberlist_email'))
731
$error[] = 'FORM_INVALID';
737
$error[] = $user->lang['EMPTY_SUBJECT_EMAIL'];
742
$error[] = $user->lang['EMPTY_MESSAGE_EMAIL'];
745
$name = $row['username'];
746
$email_lang = $row['user_lang'];
747
$email = $row['user_email'];
751
if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email))
753
$error[] = $user->lang['EMPTY_ADDRESS_EMAIL'];
758
$error[] = $user->lang['EMPTY_NAME_EMAIL'];
764
$sql = 'UPDATE ' . USERS_TABLE . '
765
SET user_emailtime = ' . time() . '
766
WHERE user_id = ' . $user->data['user_id'];
767
$result = $db->sql_query($sql);
769
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
770
$messenger = new messenger(false);
771
$email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify';
773
$mail_to_users = array();
775
$mail_to_users[] = array(
776
'email_lang' => $email_lang,
779
'username' => ($user_id) ? $row['username'] : '',
781
'user_jabber' => ($user_id) ? $row['user_jabber'] : '',
782
'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL,
783
'topic_title' => (!$user_id) ? $row['topic_title'] : '',
784
'forum_id' => (!$user_id) ? $row['forum_id'] : 0,
787
// Ok, now the same email if CC specified, but without exposing the users email address
790
$mail_to_users[] = array(
791
'email_lang' => $user->data['user_lang'],
792
'email' => $user->data['user_email'],
793
'name' => $user->data['username'],
794
'username' => $user->data['username'],
796
'user_jabber' => $user->data['user_jabber'],
797
'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL,
798
'topic_title' => (!$user_id) ? $row['topic_title'] : '',
799
'forum_id' => (!$user_id) ? $row['forum_id'] : 0,
803
foreach ($mail_to_users as $row)
805
$messenger->template($email_tpl, $row['email_lang']);
806
$messenger->replyto($user->data['user_email']);
807
$messenger->to($row['email'], $row['name']);
811
$messenger->subject(htmlspecialchars_decode($subject));
812
$messenger->im($row['user_jabber'], $row['username']);
813
$notify_type = $row['user_notify_type'];
817
$notify_type = NOTIFY_EMAIL;
820
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
821
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
822
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
823
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
825
$messenger->assign_vars(array(
826
'BOARD_CONTACT' => $config['board_contact'],
827
'TO_USERNAME' => htmlspecialchars_decode($row['to_name']),
828
'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']),
829
'MESSAGE' => htmlspecialchars_decode($message))
834
$messenger->assign_vars(array(
835
'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']),
836
'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id")
840
$messenger->send($notify_type);
843
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
844
$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>');
845
trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message);
851
$template->assign_vars(array(
852
'S_SEND_USER' => true,
853
'USERNAME' => $row['username'],
855
'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'],
856
'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id))
861
$template->assign_vars(array(
864
'S_LANG_OPTIONS' => language_select($email_lang),
866
'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'],
867
'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&t=' . $topic_id))
871
$template->assign_vars(array(
872
'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '')
879
// The basic memberlist
880
$page_title = $user->lang['MEMBERLIST'];
881
$template_html = 'memberlist_body.html';
884
$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'], 'e' => $user->lang['SORT_EMAIL'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
886
if ($auth->acl_get('u_viewonline'))
888
$sort_key_text['l'] = $user->lang['SORT_LAST_ACTIVE'];
890
$sort_key_text['m'] = $user->lang['SORT_RANK'];
892
$sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'e' => 'u.user_email', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');
894
if ($auth->acl_get('u_viewonline'))
896
$sort_key_sql['l'] = 'u.user_lastvisit';
898
$sort_key_sql['m'] = 'u.user_rank DESC, u.user_posts';
900
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
903
foreach ($sort_key_text as $key => $value)
905
$selected = ($sort_key == $key) ? ' selected="selected"' : '';
906
$s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
910
foreach ($sort_dir_text as $key => $value)
912
$selected = ($sort_dir == $key) ? ' selected="selected"' : '';
913
$s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
916
// Additional sorting options for user search ... if search is enabled, if not
917
// then only admins can make use of this (for ACP functionality)
918
$sql_select = $sql_where_data = $sql_from = $sql_where = $order_by = '';
921
$form = request_var('form', '');
922
$field = request_var('field', '');
923
$select_single = request_var('select_single', false);
925
// We validate form and field here, only id/class allowed
926
$form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
927
$field = (!preg_match('/^[a-z0-9_-]+$/i', $field)) ? '' : $field;
928
if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
930
$username = request_var('username', '', true);
931
$email = strtolower(request_var('email', ''));
932
$icq = request_var('icq', '');
933
$aim = request_var('aim', '');
934
$yahoo = request_var('yahoo', '');
935
$msn = request_var('msn', '');
936
$jabber = request_var('jabber', '');
937
$search_group_id = request_var('search_group_id', 0);
939
$joined_select = request_var('joined_select', 'lt');
940
$active_select = request_var('active_select', 'lt');
941
$count_select = request_var('count_select', 'eq');
942
$joined = explode('-', request_var('joined', ''));
943
$active = explode('-', request_var('active', ''));
944
$count = (request_var('count', '') !== '') ? request_var('count', 0) : '';
945
$ipdomain = request_var('ip', '');
947
$find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
949
$find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
951
foreach ($find_count as $key => $value)
953
$selected = ($count_select == $key) ? ' selected="selected"' : '';
954
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
957
$find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
958
$s_find_join_time = '';
959
foreach ($find_time as $key => $value)
961
$selected = ($joined_select == $key) ? ' selected="selected"' : '';
962
$s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
965
$s_find_active_time = '';
966
foreach ($find_time as $key => $value)
968
$selected = ($active_select == $key) ? ' selected="selected"' : '';
969
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
972
$sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
973
$sql_where .= ($email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
974
$sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : '';
975
$sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : '';
976
$sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : '';
977
$sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
978
$sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
979
$sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
980
$sql_where .= (sizeof($joined) > 1) ? " AND u.user_regdate " . $find_key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
981
$sql_where .= ($auth->acl_get('u_viewonline') && sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
982
$sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id AND ug.user_pending = 0 " : '';
984
if ($search_group_id)
986
$sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
989
if ($ipdomain && $auth->acl_getf_global('m_info'))
991
if (strspn($ipdomain, 'abcdefghijklmnopqrstuvwxyz'))
993
$hostnames = gethostbynamel($ipdomain);
995
if ($hostnames !== false)
997
$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)))) . "'";
1006
$ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'";
1011
// A minor fudge but it does the job :D
1012
$sql_where .= " AND u.user_id = 0";
1016
$ip_forums = array_keys($auth->acl_getf('m_info', true));
1018
$sql = 'SELECT DISTINCT poster_id
1019
FROM ' . POSTS_TABLE . '
1020
WHERE poster_ip ' . ((strpos($ips, '%') !== false) ? 'LIKE' : 'IN') . " ($ips)
1021
AND forum_id IN (0, " . implode(', ', $ip_forums) . ')';
1022
$result = $db->sql_query($sql);
1024
if ($row = $db->sql_fetchrow($result))
1029
$ip_sql[] = $row['poster_id'];
1031
while ($row = $db->sql_fetchrow($result));
1033
$sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql);
1037
// A minor fudge but it does the job :D
1038
$sql_where .= " AND u.user_id = 0";
1042
$db->sql_freeresult($result);
1047
$first_char = request_var('first_char', '');
1049
if ($first_char == 'other')
1051
for ($i = 97; $i < 123; $i++)
1053
$sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
1056
else if ($first_char)
1058
$sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
1061
// Are we looking at a usergroup? If so, fetch additional info
1062
// and further restrict the user info query
1063
if ($mode == 'group')
1065
// We JOIN here to save a query for determining membership for hidden groups. ;)
1066
$sql = 'SELECT g.*, ug.user_id
1067
FROM ' . GROUPS_TABLE . ' g
1068
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)
1069
WHERE g.group_id = $group_id";
1070
$result = $db->sql_query($sql);
1071
$group_row = $db->sql_fetchrow($result);
1072
$db->sql_freeresult($result);
1076
trigger_error('NO_GROUP');
1079
switch ($group_row['group_type'])
1082
$group_row['l_group_type'] = 'OPEN';
1086
$group_row['l_group_type'] = 'CLOSED';
1090
$group_row['l_group_type'] = 'HIDDEN';
1092
// Check for membership or special permissions
1093
if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id'])
1095
trigger_error('NO_GROUP');
1100
$group_row['l_group_type'] = 'SPECIAL';
1104
$group_row['l_group_type'] = 'FREE';
1108
// Misusing the avatar function for displaying group avatars...
1109
$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');
1111
$rank_title = $rank_img = $rank_img_src = '';
1112
if ($group_row['group_rank'])
1114
if (isset($ranks['special'][$group_row['group_rank']]))
1116
$rank_title = $ranks['special'][$group_row['group_rank']]['rank_title'];
1118
$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 />' : '';
1119
$rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : '';
1128
$template->assign_vars(array(
1129
'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']),
1130
'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
1131
'GROUP_COLOR' => $group_row['group_colour'],
1132
'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
1133
'GROUP_RANK' => $rank_title,
1135
'AVATAR_IMG' => $avatar_img,
1136
'RANK_IMG' => $rank_img,
1137
'RANK_IMG_SRC' => $rank_img_src,
1139
'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm') && $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) : '',)
1142
$sql_select = ', ug.group_leader';
1143
$sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
1144
$order_by = 'ug.group_leader DESC, ';
1146
$sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1147
$sql_where_data = " AND u.user_id = ug.user_id AND ug.group_id = $group_id";
1150
// Sorting and order
1151
if (!isset($sort_key_sql[$sort_key]))
1153
$sort_key = $default_key;
1156
$order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
1158
// Count the users ...
1161
$sql = 'SELECT COUNT(u.user_id) AS total_users
1162
FROM ' . USERS_TABLE . " u$sql_from
1163
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
1165
$result = $db->sql_query($sql);
1166
$total_users = (int) $db->sql_fetchfield('total_users');
1167
$db->sql_freeresult($result);
1171
$total_users = $config['num_users'];
1174
$s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '> </option>';
1175
for ($i = 97; $i < 123; $i++)
1177
$s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i-32) . '</option>';
1179
$s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>' . $user->lang['OTHER'] . '</option>';
1181
// Build a relevant pagination_url
1182
$params = $sort_params = array();
1184
// We do not use request_var() here directly to save some calls (not all variables are set)
1185
$check_params = array(
1186
'g' => array('g', 0),
1187
'sk' => array('sk', $default_key),
1188
'sd' => array('sd', 'a'),
1189
'form' => array('form', ''),
1190
'field' => array('field', ''),
1191
'select_single' => array('select_single', 0),
1192
'username' => array('username', '', true),
1193
'email' => array('email', ''),
1194
'icq' => array('icq', ''),
1195
'aim' => array('aim', ''),
1196
'yahoo' => array('yahoo', ''),
1197
'msn' => array('msn', ''),
1198
'jabber' => array('jabber', ''),
1199
'search_group_id' => array('search_group_id', 0),
1200
'joined_select' => array('joined_select', 'lt'),
1201
'active_select' => array('active_select', 'lt'),
1202
'count_select' => array('count_select', 'eq'),
1203
'joined' => array('joined', ''),
1204
'active' => array('active', ''),
1205
'count' => (request_var('count', '') !== '') ? array('count', 0) : array('count', ''),
1206
'ipdomain' => array('ip', ''),
1207
'first_char' => array('first_char', ''),
1210
foreach ($check_params as $key => $call)
1212
if (!isset($_REQUEST[$key]))
1217
$param = call_user_func_array('request_var', $call);
1218
$param = urlencode($key) . '=' . ((is_string($param)) ? urlencode($param) : $param);
1221
if ($key != 'sk' && $key != 'sd')
1223
$sort_params[] = $param;
1227
$u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params));
1229
$params[] = "mode=$mode";
1230
$sort_params[] = "mode=$mode";
1231
$pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params));
1232
$sort_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $sort_params));
1234
unset($params, $sort_params);
1236
// Some search user specific data
1237
if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_')))
1239
$group_selected = request_var('search_group_id', 0);
1240
$s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>';
1242
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
1244
$sql = 'SELECT group_id, group_name, group_type
1245
FROM ' . GROUPS_TABLE . '
1246
ORDER BY group_name ASC';
1250
$sql = 'SELECT g.group_id, g.group_name, g.group_type
1251
FROM ' . GROUPS_TABLE . ' g
1252
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
1254
g.group_id = ug.group_id
1255
AND ug.user_id = ' . $user->data['user_id'] . '
1256
AND ug.user_pending = 0
1258
WHERE (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
1259
ORDER BY g.group_name ASC';
1261
$result = $db->sql_query($sql);
1263
while ($row = $db->sql_fetchrow($result))
1265
$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>';
1267
$db->sql_freeresult($result);
1269
$template->assign_vars(array(
1270
'USERNAME' => $username,
1276
'JABBER' => $jabber,
1277
'JOINED' => implode('-', $joined),
1278
'ACTIVE' => implode('-', $active),
1282
'S_IP_SEARCH_ALLOWED' => ($auth->acl_getf_global('m_info')) ? true : false,
1283
'S_IN_SEARCH_POPUP' => ($form && $field) ? true : false,
1284
'S_SEARCH_USER' => true,
1285
'S_FORM_NAME' => $form,
1286
'S_FIELD_NAME' => $field,
1287
'S_SELECT_SINGLE' => $select_single,
1288
'S_COUNT_OPTIONS' => $s_find_count,
1289
'S_SORT_OPTIONS' => $s_sort_key,
1290
'S_JOINED_TIME_OPTIONS' => $s_find_join_time,
1291
'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time,
1292
'S_GROUP_SELECT' => $s_group_select,
1293
'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field"))
1297
// Get us some users :D
1298
$sql = "SELECT u.user_id
1299
FROM " . USERS_TABLE . " u
1301
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
1303
ORDER BY $order_by";
1304
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
1306
$user_list = array();
1307
while ($row = $db->sql_fetchrow($result))
1309
$user_list[] = (int) $row['user_id'];
1311
$db->sql_freeresult($result);
1313
// So, did we get any users?
1314
if (sizeof($user_list))
1316
// Session time?! Session time...
1317
$sql = 'SELECT session_user_id, MAX(session_time) AS session_time
1318
FROM ' . SESSIONS_TABLE . '
1319
WHERE session_time >= ' . (time() - $config['session_length']) . '
1320
AND ' . $db->sql_in_set('session_user_id', $user_list) . '
1321
GROUP BY session_user_id';
1322
$result = $db->sql_query($sql);
1324
$session_times = array();
1325
while ($row = $db->sql_fetchrow($result))
1327
$session_times[$row['session_user_id']] = $row['session_time'];
1329
$db->sql_freeresult($result);
1332
if ($mode == 'group')
1336
FROM " . USERS_TABLE . " u
1338
WHERE " . $db->sql_in_set('u.user_id', $user_list) . "
1344
FROM ' . USERS_TABLE . '
1345
WHERE ' . $db->sql_in_set('user_id', $user_list);
1347
$result = $db->sql_query($sql);
1349
$id_cache = array();
1350
while ($row = $db->sql_fetchrow($result))
1352
$row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : 0;
1353
$row['last_visit'] = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'];
1355
$id_cache[$row['user_id']] = $row;
1357
$db->sql_freeresult($result);
1359
// Load custom profile fields
1360
if ($config['load_cpf_memberlist'])
1362
include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
1363
$cp = new custom_profile();
1365
// Grab all profile fields from users in id cache for later use - similar to the poster cache
1366
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $user_list);
1369
// If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
1370
if ($sort_key == 'l')
1372
$lesser_than = ($sort_dir == 'a') ? -1 : 1;
1373
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));"));
1376
for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i)
1378
$user_id = $user_list[$i];
1379
$row =& $id_cache[$user_id];
1382
if ($config['load_cpf_memberlist'])
1384
$cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
1387
$memberrow = array_merge(show_profile($row), array(
1388
'ROW_NUMBER' => $i + ($start + 1),
1390
'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
1391
'S_GROUP_LEADER' => (isset($row['group_leader']) && $row['group_leader']) ? true : false,
1393
'U_VIEW_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id))
1396
if (isset($cp_row['row']) && sizeof($cp_row['row']))
1398
$memberrow = array_merge($memberrow, $cp_row['row']);
1401
$template->assign_block_vars('memberrow', $memberrow);
1403
if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow']))
1405
foreach ($cp_row['blockrow'] as $field_data)
1407
$template->assign_block_vars('memberrow.custom_fields', $field_data);
1411
unset($id_cache[$user_id]);
1416
$template->assign_vars(array(
1417
'PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
1418
'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start),
1419
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users),
1421
'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']),
1422
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
1423
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
1424
'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']),
1425
'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']),
1426
'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']),
1427
'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']),
1428
'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']),
1429
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
1430
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
1432
'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser') : '',
1433
'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser') ? $u_hide_find_member : '',
1434
'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
1435
'U_SORT_FROM' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
1436
'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
1437
'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
1438
'U_SORT_EMAIL' => $sort_url . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
1439
'U_SORT_WEBSITE' => $sort_url . '&sk=f&sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
1440
'U_SORT_LOCATION' => $sort_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
1441
'U_SORT_ICQ' => $sort_url . '&sk=g&sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
1442
'U_SORT_AIM' => $sort_url . '&sk=h&sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
1443
'U_SORT_MSN' => $sort_url . '&sk=i&sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
1444
'U_SORT_YIM' => $sort_url . '&sk=j&sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
1445
'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&sk=l&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '',
1446
'U_SORT_RANK' => $sort_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'),
1447
'U_LIST_CHAR' => $sort_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'),
1449
'S_SHOW_GROUP' => ($mode == 'group') ? true : false,
1450
'S_VIEWONLINE' => $auth->acl_get('u_viewonline'),
1451
'S_MODE_SELECT' => $s_sort_key,
1452
'S_ORDER_SELECT' => $s_sort_dir,
1453
'S_CHAR_OPTIONS' => $s_char_options,
1454
'S_MODE_ACTION' => $pagination_url)
1459
page_header($page_title);
1461
$template->set_filenames(array(
1462
'body' => $template_html)
1464
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
1469
* Prepare profile data
1471
function show_profile($data)
1473
global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;
1475
$username = $data['username'];
1476
$user_id = $data['user_id'];
1478
$rank_title = $rank_img = $rank_img_src = '';
1479
get_user_rank($data['user_rank'], $data['user_posts'], $rank_title, $rank_img, $rank_img_src);
1481
if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_email'))
1483
$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_email')) ? '' : 'mailto:' . $data['user_email']);
1490
if ($config['load_onlinetrack'])
1492
$update_time = $config['load_online_time'] * 60;
1493
$online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
1500
if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
1502
$last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
1511
if ($config['allow_birthdays'] && $data['user_birthday'])
1513
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
1517
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
1519
$diff = $now['mon'] - $bday_month;
1522
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
1526
$diff = ($diff < 0) ? 1 : 0;
1529
$age = (int) ($now['year'] - $bday_year - $diff);
1533
// Dump it out to the template
1536
'RANK_TITLE' => $rank_title,
1537
'JOINED' => $user->format_date($data['user_regdate']),
1538
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
1539
'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
1540
'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
1542
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
1543
'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
1544
'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
1545
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
1547
'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
1549
'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
1550
'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
1551
'RANK_IMG' => $rank_img,
1552
'RANK_IMG_SRC' => $rank_img_src,
1553
'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" />' : '',
1554
'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
1556
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
1557
'U_NOTES' => $auth->acl_getf_global('m_') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
1558
'U_WARN' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
1559
'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) : '',
1560
'U_EMAIL' => $email,
1561
'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '',
1562
'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($data['user_icq']) : '',
1563
'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '',
1564
'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&.src=pg' : '',
1565
'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '',
1566
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
1567
'LOCATION' => ($data['user_from']) ? $data['user_from'] : '',
1569
'USER_ICQ' => $data['user_icq'],
1570
'USER_AIM' => $data['user_aim'],
1571
'USER_YIM' => $data['user_yim'],
1572
'USER_MSN' => $data['user_msnm'],
1573
'USER_JABBER' => $data['user_jabber'],
1574
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
1576
'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username),
b'\\ No newline at end of file'