[ Index ] |
PHP Cross Reference of phpBB 3.0 Beta 3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package phpBB3 5 * @version $Id: memberlist.php,v 1.188 2006/11/12 15:35:42 acydburn Exp $ 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 = './'; 16 $phpEx = substr(strrchr(__FILE__, '.'), 1); 17 include($phpbb_root_path . 'common.' . $phpEx); 18 19 // Start session management 20 $user->session_begin(); 21 $auth->acl($user->data); 22 $user->setup(array('memberlist', 'groups')); 23 24 // Grab data 25 $mode = request_var('mode', ''); 26 $action = request_var('action', ''); 27 $user_id = request_var('u', ANONYMOUS); 28 $username = request_var('un', '', true); 29 $group_id = request_var('g', 0); 30 $topic_id = request_var('t', 0); 31 32 switch ($mode) 33 { 34 case 'email': 35 break; 36 37 default: 38 // Can this user view profiles/memberlist? 39 if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) 40 { 41 if ($user->data['user_id'] != ANONYMOUS) 42 { 43 trigger_error('NO_VIEW_USERS'); 44 } 45 46 login_box('', ((isset($user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)])) ? $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)] : $user->lang['LOGIN_EXPLAIN_MEMBERLIST'])); 47 } 48 break; 49 } 50 51 52 $start = request_var('start', 0); 53 $submit = (isset($_POST['submit'])) ? true : false; 54 55 $default_key = 'c'; 56 $sort_key = request_var('sk', $default_key); 57 $sort_dir = request_var('sd', 'a'); 58 59 60 // Grab rank information for later 61 $ranks = $cache->obtain_ranks(); 62 63 64 // What do you want to do today? ... oops, I think that line is taken ... 65 switch ($mode) 66 { 67 case 'leaders': 68 // Display a listing of board admins, moderators 69 $user->add_lang('groups'); 70 71 $page_title = $user->lang['THE_TEAM']; 72 $template_html = 'memberlist_leaders.html'; 73 74 $user_ary = $auth->acl_get_list(false, array('a_', 'm_'), false); 75 76 $admin_id_ary = $mod_id_ary = $forum_id_ary = array(); 77 foreach ($user_ary as $forum_id => $forum_ary) 78 { 79 foreach ($forum_ary as $auth_option => $id_ary) 80 { 81 if (!$forum_id && $auth_option == 'a_') 82 { 83 $admin_id_ary = array_merge($admin_id_ary, $id_ary); 84 continue; 85 } 86 else 87 { 88 $mod_id_ary = array_merge($mod_id_ary, $id_ary); 89 } 90 91 if ($forum_id) 92 { 93 foreach ($id_ary as $id) 94 { 95 $forum_id_ary[$id][] = $forum_id; 96 } 97 } 98 } 99 } 100 101 $admin_id_ary = array_unique($admin_id_ary); 102 $mod_id_ary = array_unique($mod_id_ary); 103 104 // Admin group id... 105 $sql = 'SELECT group_id 106 FROM ' . GROUPS_TABLE . " 107 WHERE group_name = 'ADMINISTRATORS'"; 108 $result = $db->sql_query($sql); 109 $admin_group_id = (int) $db->sql_fetchfield('group_id'); 110 $db->sql_freeresult($result); 111 112 $sql = 'SELECT forum_id, forum_name 113 FROM ' . FORUMS_TABLE . ' 114 WHERE forum_type = ' . FORUM_POST; 115 $result = $db->sql_query($sql); 116 117 $forums = array(); 118 while ($row = $db->sql_fetchrow($result)) 119 { 120 $forums[$row['forum_id']] = $row['forum_name']; 121 } 122 $db->sql_freeresult($result); 123 124 $sql = $db->sql_build_query('SELECT', array( 125 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.user_colour, u.user_rank, u.user_posts, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', 126 127 'FROM' => array( 128 USERS_TABLE => 'u', 129 GROUPS_TABLE => 'g' 130 ), 131 132 'LEFT_JOIN' => array( 133 array( 134 'FROM' => array(USER_GROUP_TABLE => 'ug'), 135 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] 136 ) 137 ), 138 139 'WHERE' => $db->sql_in_set('u.user_id', array_unique(array_merge($admin_id_ary, $mod_id_ary))) . ' 140 AND u.group_id = g.group_id', 141 142 'ORDER_BY' => 'g.group_name ASC, u.username ASC' 143 )); 144 145 $result = $db->sql_query($sql); 146 147 while ($row = $db->sql_fetchrow($result)) 148 { 149 $which_row = (in_array($row['user_id'], $admin_id_ary)) ? 'admin' : 'mod'; 150 151 // We sort out admins not having the admin group as default 152 // The drawback is that only those admins are displayed which are within 153 // the special group 'Administrators' and also having it assigned as their default group. 154 // - might change 155 if ($which_row == 'admin' && $row['default_group'] != $admin_group_id) 156 { 157 // Remove from admin_id_ary, because the user may be a mod instead 158 unset($admin_id_ary[array_search($row['user_id'], $admin_id_ary)]); 159 160 if (!in_array($row['user_id'], $mod_id_ary)) 161 { 162 continue; 163 } 164 else 165 { 166 $which_row = 'mod'; 167 } 168 } 169 170 $s_forum_select = ''; 171 $undisclosed_forum = false; 172 173 if (isset($forum_id_ary[$row['user_id']])) 174 { 175 if ($which_row == 'mod' && sizeof(array_diff(array_keys($forums), $forum_id_ary[$row['user_id']]))) 176 { 177 foreach ($forum_id_ary[$row['user_id']] as $forum_id) 178 { 179 if (isset($forums[$forum_id])) 180 { 181 if ($auth->acl_get('f_list', $forum_id)) 182 { 183 $s_forum_select .= '<option value="">' . $forums[$forum_id] . '</option>'; 184 } 185 else 186 { 187 $undisclosed_forum = true; 188 } 189 } 190 } 191 } 192 } 193 194 // If the mod is only moderating non-viewable forums let us display this circumstance 195 // instead of saying they are moderating all forums 196 if (!$s_forum_select && $undisclosed_forum) 197 { 198 $s_forum_select = $user->lang['FORUM_UNDISCLOSED']; 199 } 200 201 if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) 202 { 203 $group_name = $user->lang['GROUP_UNDISCLOSED']; 204 $u_group = ''; 205 } 206 else 207 { 208 $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; 209 $u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']); 210 } 211 212 $rank_title = $rank_img = ''; 213 get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src); 214 215 $template->assign_block_vars($which_row, array( 216 'USER_ID' => $row['user_id'], 217 'FORUMS' => $s_forum_select, 218 'USERNAME' => $row['username'], 219 'USER_COLOR' => $row['user_colour'], 220 'RANK_TITLE' => $rank_title, 221 'GROUP_NAME' => $group_name, 222 'GROUP_COLOR' => $row['group_colour'], 223 224 'RANK_IMG' => $rank_img, 225 'RANK_IMG_SRC' => $rank_img_src, 226 227 'U_GROUP' => $u_group, 228 'U_VIEWPROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']), 229 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '') 230 ); 231 } 232 $db->sql_freeresult($result); 233 234 $template->assign_vars(array( 235 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) 236 ); 237 break; 238 239 case 'contact': 240 $page_title = $user->lang['IM_USER']; 241 $template_html = 'memberlist_im.html'; 242 243 $presence_img = ''; 244 switch ($action) 245 { 246 case 'aim': 247 $lang = 'AIM'; 248 $sql_field = 'user_aim'; 249 $s_select = 'S_SEND_AIM'; 250 $s_action = ''; 251 break; 252 253 case 'msnm': 254 $lang = 'MSNM'; 255 $sql_field = 'user_msnm'; 256 $s_select = 'S_SEND_MSNM'; 257 $s_action = ''; 258 break; 259 260 case 'jabber': 261 $lang = 'JABBER'; 262 $sql_field = 'user_jabber'; 263 $s_select = (@extension_loaded('xml') && $config['jab_enable']) ? 'S_SEND_JABBER' : 'S_NO_SEND_JABBER'; 264 $s_action = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=$action&u=$user_id"); 265 break; 266 267 default: 268 trigger_error('This contact option is not supported', E_USER_ERROR); 269 break; 270 } 271 272 // Grab relevant data 273 $sql = "SELECT user_id, username, user_email, user_lang, $sql_field 274 FROM " . USERS_TABLE . " 275 WHERE user_id = $user_id 276 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 277 $result = $db->sql_query($sql); 278 $row = $db->sql_fetchrow($result); 279 $db->sql_freeresult($result); 280 281 if (!$row) 282 { 283 trigger_error('NO_USER_DATA'); 284 } 285 286 // Post data grab actions 287 switch ($action) 288 { 289 case 'jabber': 290 if ($submit && @extension_loaded('xml') && $config['jab_enable']) 291 { 292 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 293 294 $subject = sprintf($user->lang['IM_JABBER_SUBJECT'], $user->data['username'], $config['server_name']); 295 $message = request_var('message', '', true); 296 297 $messenger = new messenger(false); 298 299 $messenger->template('profile_send_im', $row['user_lang']); 300 $messenger->subject(htmlspecialchars_decode($subject)); 301 302 $messenger->replyto($user->data['user_email']); 303 $messenger->im($row['user_jabber'], $row['username']); 304 305 $messenger->assign_vars(array( 306 'BOARD_EMAIL' => $config['board_contact'], 307 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 308 'TO_USERNAME' => htmlspecialchars_decode($row['username']), 309 'MESSAGE' => htmlspecialchars_decode($message)) 310 ); 311 312 $messenger->send(NOTIFY_IM); 313 314 $s_select = 'S_SENT_JABBER'; 315 } 316 break; 317 } 318 319 // Send vars to the template 320 $template->assign_vars(array( 321 'IM_CONTACT' => $row[$sql_field], 322 'USERNAME' => $row['username'], 323 'CONTACT_NAME' => $row[$sql_field], 324 'SITENAME' => $config['sitename'], 325 326 'PRESENCE_IMG' => $presence_img, 327 328 'L_SEND_IM_EXPLAIN' => $user->lang['IM_' . $lang], 329 'L_IM_SENT_JABBER' => sprintf($user->lang['IM_SENT_JABBER'], $row['username']), 330 331 $s_select => true, 332 'S_IM_ACTION' => $s_action) 333 ); 334 335 break; 336 337 case 'viewprofile': 338 // Display a profile 339 if ($user_id == ANONYMOUS && !$username) 340 { 341 trigger_error('NO_USER'); 342 } 343 344 // Get user... 345 if ($username) 346 { 347 $sql = 'SELECT * 348 FROM ' . USERS_TABLE . " 349 WHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "' 350 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 351 } 352 else 353 { 354 $sql = 'SELECT * 355 FROM ' . USERS_TABLE . " 356 WHERE user_id = $user_id 357 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 358 } 359 360 $result = $db->sql_query($sql); 361 $member = $db->sql_fetchrow($result); 362 $db->sql_freeresult($result); 363 364 if (!$member) 365 { 366 trigger_error('NO_USER'); 367 } 368 369 $user_id = (int) $member['user_id']; 370 371 // Do the SQL thang 372 $sql = 'SELECT g.group_id, g.group_name, g.group_type 373 FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug 374 WHERE ug.user_id = $user_id 375 AND g.group_id = ug.group_id" . ((!$auth->acl_get('a_group')) ? ' AND group_type <> ' . GROUP_HIDDEN : '') . ' 376 ORDER BY group_type, group_name'; 377 $result = $db->sql_query($sql); 378 379 $group_options = ''; 380 while ($row = $db->sql_fetchrow($result)) 381 { 382 $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>'; 383 } 384 $db->sql_freeresult($result); 385 386 // What colour is the zebra 387 $sql = 'SELECT friend, foe 388 FROM ' . ZEBRA_TABLE . " 389 WHERE zebra_id = $user_id 390 AND user_id = {$user->data['user_id']}"; 391 392 $result = $db->sql_query($sql); 393 $row = $db->sql_fetchrow($result); 394 $foe = ($row['foe']) ? true : false; 395 $friend = ($row['friend']) ? true : false; 396 $db->sql_freeresult($result); 397 398 if ($config['load_onlinetrack']) 399 { 400 $sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline 401 FROM ' . SESSIONS_TABLE . " 402 WHERE session_user_id = $user_id"; 403 $result = $db->sql_query($sql); 404 $row = $db->sql_fetchrow($result); 405 $db->sql_freeresult($result); 406 407 $member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0; 408 $member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0; 409 unset($row); 410 } 411 412 if ($config['load_user_activity']) 413 { 414 if (!function_exists('display_user_activity')) 415 { 416 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); 417 } 418 display_user_activity($member); 419 } 420 421 // Do the relevant calculations 422 $memberdays = max(1, round((time() - $member['user_regdate']) / 86400)); 423 $posts_per_day = $member['user_posts'] / $memberdays; 424 $percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0; 425 426 427 if ($member['user_sig']) 428 { 429 $member['user_sig'] = censor_text($member['user_sig']); 430 $member['user_sig'] = str_replace("\n", '<br />', $member['user_sig']); 431 432 if ($member['user_sig_bbcode_bitfield']) 433 { 434 include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); 435 $bbcode = new bbcode(); 436 $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']); 437 } 438 439 $member['user_sig'] = smiley_text($member['user_sig']); 440 } 441 442 $poster_avatar = ''; 443 if (!empty($member['user_avatar'])) 444 { 445 switch ($member['user_avatar_type']) 446 { 447 case AVATAR_UPLOAD: 448 $poster_avatar = $config['avatar_path'] . '/'; 449 break; 450 451 case AVATAR_GALLERY: 452 $poster_avatar = $config['avatar_gallery_path'] . '/'; 453 break; 454 } 455 $poster_avatar .= $member['user_avatar']; 456 457 $poster_avatar = '<img src="' . $poster_avatar . '" width="' . $member['user_avatar_width'] . '" height="' . $member['user_avatar_height'] . '" alt="" />'; 458 } 459 460 $template->assign_vars(show_profile($member)); 461 462 // Custom Profile Fields 463 $profile_fields = array(); 464 if ($config['load_cpf_viewprofile']) 465 { 466 include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); 467 $cp = new custom_profile(); 468 $profile_fields = $cp->generate_profile_fields_template('grab', $user_id); 469 $profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array(); 470 } 471 472 // We need to check if the module 'zebra' is accessible 473 $zebra_enabled = false; 474 475 if ($user->data['user_id'] != $user_id && $user->data['is_registered']) 476 { 477 include_once($phpbb_root_path . 'includes/functions_module.' . $phpEx); 478 $module = new p_master(); 479 $module->list_modules('ucp'); 480 $module->set_active('zebra'); 481 482 $zebra_enabled = ($module->active_module === false) ? false : true; 483 484 unset($module); 485 } 486 487 $template->assign_vars(array( 488 'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day), 489 'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage), 490 491 'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '', 492 'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '', 493 'SIGNATURE' => $member['user_sig'], 494 495 'AVATAR_IMG' => $poster_avatar, 496 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 497 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 498 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 499 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 500 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 501 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 502 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 503 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 504 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 505 506 'S_PROFILE_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group'), 507 'S_GROUP_OPTIONS' => $group_options, 508 'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false, 509 510 '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) : '', 511 '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}") : '', 512 513 'S_ZEBRA' => ($user->data['user_id'] != $user_id && $user->data['is_registered'] && $zebra_enabled) ? true : false, 514 'U_ADD_FRIEND' => (!$friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&add=' . urlencode($member['username'])) : '', 515 'U_ADD_FOE' => (!$foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&mode=foes&add=' . urlencode($member['username'])) : '', 516 'U_REMOVE_FRIEND' => ($friend) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', 517 'U_REMOVE_FOE' => ($foe) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=zebra&remove=1&usernames[]=' . $user_id) : '', 518 )); 519 520 if (!empty($profile_fields['row'])) 521 { 522 $template->assign_vars($profile_fields['row']); 523 } 524 525 if (!empty($profile_fields['blockrow'])) 526 { 527 foreach ($profile_fields['blockrow'] as $field_data) 528 { 529 $template->assign_block_vars('custom_fields', $field_data); 530 } 531 } 532 533 // Now generate page tilte 534 $page_title = sprintf($user->lang['VIEWING_PROFILE'], $member['username']); 535 $template_html = 'memberlist_view.html'; 536 537 break; 538 539 case 'email': 540 541 // Send an email 542 $page_title = $user->lang['SEND_EMAIL']; 543 $template_html = 'memberlist_email.html'; 544 545 if (!$config['email_enable']) 546 { 547 trigger_error('EMAIL_DISABLED'); 548 } 549 550 if (!$auth->acl_get('u_sendemail')) 551 { 552 trigger_error('NO_EMAIL'); 553 } 554 555 // Are we trying to abuse the facility? 556 if (time() - $user->data['user_emailtime'] < $config['flood_interval']) 557 { 558 trigger_error('FLOOD_EMAIL_LIMIT'); 559 } 560 561 // Determine action... 562 $user_id = request_var('u', 0); 563 $topic_id = request_var('t', 0); 564 565 // Send email to user... 566 if ($user_id) 567 { 568 if ($user_id == ANONYMOUS || !$config['board_email_form']) 569 { 570 trigger_error('NO_EMAIL'); 571 } 572 573 // Get the appropriate username, etc. 574 $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type 575 FROM ' . USERS_TABLE . " 576 WHERE user_id = $user_id 577 AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; 578 $result = $db->sql_query($sql); 579 $row = $db->sql_fetchrow($result); 580 $db->sql_freeresult($result); 581 582 if (!$row) 583 { 584 trigger_error('NO_USER'); 585 } 586 587 // Can we send email to this user? 588 if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user')) 589 { 590 trigger_error('NO_EMAIL'); 591 } 592 } 593 else if ($topic_id) 594 { 595 // Send topic heads-up to email address 596 $sql = 'SELECT forum_id, topic_title 597 FROM ' . TOPICS_TABLE . " 598 WHERE topic_id = $topic_id"; 599 $result = $db->sql_query($sql); 600 $row = $db->sql_fetchrow($result); 601 $db->sql_freeresult($result); 602 603 if (!$row) 604 { 605 trigger_error('NO_TOPIC'); 606 } 607 608 if ($row['forum_id']) 609 { 610 if (!$auth->acl_get('f_read', $row['forum_id'])) 611 { 612 trigger_error($user->lang['SORRY_AUTH_READ']); 613 } 614 615 if (!$auth->acl_get('f_email', $row['forum_id'])) 616 { 617 trigger_error('NO_EMAIL'); 618 } 619 } 620 else 621 { 622 // If global announcement, we need to check if the user is able to at least read and email in one forum... 623 if (!$auth->acl_getf_global('f_read')) 624 { 625 trigger_error($user->lang['SORRY_AUTH_READ']); 626 } 627 628 if (!$auth->acl_getf_global('f_email')) 629 { 630 trigger_error('NO_EMAIL'); 631 } 632 } 633 } 634 else 635 { 636 trigger_error('NO_EMAIL'); 637 } 638 639 $error = array(); 640 641 $name = request_var('name', '', true); 642 $email = request_var('email', ''); 643 $email_lang = request_var('lang', $config['default_lang']); 644 $subject = request_var('subject', '', true); 645 $message = request_var('message', '', true); 646 $cc = (isset($_POST['cc_email'])) ? true : false; 647 $submit = (isset($_POST['submit'])) ? true : false; 648 649 if ($submit) 650 { 651 if ($user_id) 652 { 653 if (!$subject) 654 { 655 $error[] = $user->lang['EMPTY_SUBJECT_EMAIL']; 656 } 657 658 if (!$message) 659 { 660 $error[] = $user->lang['EMPTY_MESSAGE_EMAIL']; 661 } 662 663 $name = $row['username']; 664 $email_lang = $row['user_lang']; 665 $email = $row['user_email']; 666 } 667 else 668 { 669 if (!$email || !preg_match('#^.*?@(.*?\.)?[a-z0-9\-]+\.[a-z]{2,4}$#i', $email)) 670 { 671 $error[] = $user->lang['EMPTY_ADDRESS_EMAIL']; 672 } 673 674 if (!$name) 675 { 676 $error[] = $user->lang['EMPTY_NAME_EMAIL']; 677 } 678 } 679 680 if (!sizeof($error)) 681 { 682 $sql = 'UPDATE ' . USERS_TABLE . ' 683 SET user_emailtime = ' . time() . ' 684 WHERE user_id = ' . $user->data['user_id']; 685 $result = $db->sql_query($sql); 686 687 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 688 $messenger = new messenger(false); 689 $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify'; 690 691 $mail_to_users = array(); 692 693 $mail_to_users[] = array( 694 'email_lang' => $email_lang, 695 'email' => $email, 696 'name' => $name, 697 'username' => ($user_id) ? $row['username'] : '', 698 'to_name' => $name, 699 'user_jabber' => ($user_id) ? $row['user_jabber'] : '', 700 'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL, 701 'topic_title' => (!$user_id) ? $row['topic_title'] : '', 702 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, 703 ); 704 705 // Ok, now the same email if CC specified, but without exposing the users email address 706 if ($cc) 707 { 708 $mail_to_users[] = array( 709 'email_lang' => $user->data['user_lang'], 710 'email' => $user->data['user_email'], 711 'name' => $user->data['username'], 712 'username' => $user->data['username'], 713 'to_name' => $name, 714 'user_jabber' => $user->data['user_jabber'], 715 'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL, 716 'topic_title' => (!$user_id) ? $row['topic_title'] : '', 717 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, 718 ); 719 } 720 721 foreach ($mail_to_users as $row) 722 { 723 $messenger->template($email_tpl, $row['email_lang']); 724 $messenger->replyto($user->data['user_email']); 725 $messenger->to($row['email'], $row['name']); 726 727 if ($user_id) 728 { 729 $messenger->subject(htmlspecialchars_decode($subject)); 730 $messenger->im($row['user_jabber'], $row['username']); 731 $notify_type = $row['user_notify_type']; 732 } 733 else 734 { 735 $notify_type = NOTIFY_EMAIL; 736 } 737 738 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); 739 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 740 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 741 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 742 743 $messenger->assign_vars(array( 744 'BOARD_EMAIL' => $config['board_contact'], 745 'TO_USERNAME' => htmlspecialchars_decode($row['to_name']), 746 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 747 'MESSAGE' => htmlspecialchars_decode($message)) 748 ); 749 750 if ($topic_id) 751 { 752 $messenger->assign_vars(array( 753 'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']), 754 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id") 755 ); 756 } 757 758 $messenger->send($notify_type); 759 } 760 761 meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); 762 $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>'); 763 trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message); 764 } 765 } 766 767 if ($user_id) 768 { 769 $template->assign_vars(array( 770 'S_SEND_USER' => true, 771 'USERNAME' => $row['username'], 772 773 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'], 774 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id)) 775 ); 776 } 777 else 778 { 779 $template->assign_vars(array( 780 'EMAIL' => $email, 781 'NAME' => $name, 782 'S_LANG_OPTIONS' => language_select($email_lang), 783 784 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'], 785 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&t=' . $topic_id)) 786 ); 787 } 788 789 $template->assign_vars(array( 790 'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '') 791 ); 792 793 break; 794 795 case 'group': 796 default: 797 // The basic memberlist 798 $page_title = $user->lang['MEMBERLIST']; 799 $template_html = 'memberlist_body.html'; 800 801 // Sorting 802 $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'], 'l' => $user->lang['SORT_LAST_ACTIVE'], 'm' => $user->lang['SORT_RANK'] ); 803 $sort_key_sql = array('a' => 'u.username', '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', 'l' => 'u.user_lastvisit', 'm' => 'u.user_rank DESC, u.user_posts'); 804 805 $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); 806 807 $s_sort_key = ''; 808 foreach ($sort_key_text as $key => $value) 809 { 810 $selected = ($sort_key == $key) ? ' selected="selected"' : ''; 811 $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 812 } 813 814 $s_sort_dir = ''; 815 foreach ($sort_dir_text as $key => $value) 816 { 817 $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; 818 $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 819 } 820 821 // Additional sorting options for user search ... if search is enabled, if not 822 // then only admins can make use of this (for ACP functionality) 823 $sql_select = $sql_from = $sql_where = $order_by = ''; 824 825 $form = request_var('form', ''); 826 $field = request_var('field', ''); 827 828 if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_'))) 829 { 830 $username = request_var('username', '', true); 831 $email = request_var('email', ''); 832 $icq = request_var('icq', ''); 833 $aim = request_var('aim', ''); 834 $yahoo = request_var('yahoo', ''); 835 $msn = request_var('msn', ''); 836 $jabber = request_var('jabber', ''); 837 $search_group_id = request_var('search_group_id', 0); 838 839 $joined_select = request_var('joined_select', 'lt'); 840 $active_select = request_var('active_select', 'lt'); 841 $count_select = request_var('count_select', 'eq'); 842 $joined = explode('-', request_var('joined', '')); 843 $active = explode('-', request_var('active', '')); 844 $count = (request_var('count', '') !== '') ? request_var('count', 0) : ''; 845 $ipdomain = request_var('ip', ''); 846 847 $find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); 848 849 $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); 850 $s_find_count = ''; 851 foreach ($find_count as $key => $value) 852 { 853 $selected = ($count_select == $key) ? ' selected="selected"' : ''; 854 $s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 855 } 856 857 $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); 858 $s_find_join_time = ''; 859 foreach ($find_time as $key => $value) 860 { 861 $selected = ($joined_select == $key) ? ' selected="selected"' : ''; 862 $s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 863 } 864 865 $s_find_active_time = ''; 866 foreach ($find_time as $key => $value) 867 { 868 $selected = ($active_select == $key) ? ' selected="selected"' : ''; 869 $s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 870 } 871 872 $sql_where .= ($username) ? " AND u.username_clean LIKE '" . str_replace('*', '%', $db->sql_escape(utf8_clean_string($username))) . "'" : ''; 873 $sql_where .= ($email) ? " AND u.user_email LIKE '" . str_replace('*', '%', $db->sql_escape($email)) . "' " : ''; 874 $sql_where .= ($icq) ? " AND u.user_icq LIKE '" . str_replace('*', '%', $db->sql_escape($icq)) . "' " : ''; 875 $sql_where .= ($aim) ? " AND u.user_aim LIKE '" . str_replace('*', '%', $db->sql_escape($aim)) . "' " : ''; 876 $sql_where .= ($yahoo) ? " AND u.user_yim LIKE '" . str_replace('*', '%', $db->sql_escape($yahoo)) . "' " : ''; 877 $sql_where .= ($msn) ? " AND u.user_msnm LIKE '" . str_replace('*', '%', $db->sql_escape($msn)) . "' " : ''; 878 $sql_where .= ($jabber) ? " AND u.user_jabber LIKE '" . str_replace('*', '%', $db->sql_escape($jabber)) . "' " : ''; 879 $sql_where .= (is_numeric($count)) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : ''; 880 $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])) : ''; 881 $sql_where .= (sizeof($active) > 1) ? " AND u.user_lastvisit " . $find_key_match[$active_select] . ' ' . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; 882 $sql_where .= ($search_group_id) ? " AND u.user_id = ug.user_id AND ug.group_id = $search_group_id " : ''; 883 884 if ($search_group_id) 885 { 886 $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; 887 } 888 889 if ($ipdomain && $auth->acl_getf_global('m_info')) 890 { 891 if (preg_match('#[a-z]#', $ipdomain)) 892 { 893 $hostnames = gethostbynamel($ipdomain); 894 895 if ($hostnames !== false) 896 { 897 $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)))) . "'"; 898 } 899 else 900 { 901 $ips = false; 902 } 903 } 904 else 905 { 906 $ips = "'" . str_replace('*', '%', $db->sql_escape($ipdomain)) . "'"; 907 } 908 909 if ($ips === false) 910 { 911 // A minor fudge but it does the job :D 912 $sql_where .= " AND u.user_id = 0"; 913 } 914 else 915 { 916 $ip_forums = array_keys($auth->acl_getf('m_info', true)); 917 918 $sql = 'SELECT DISTINCT poster_id 919 FROM ' . POSTS_TABLE . ' 920 WHERE poster_ip ' . ((preg_match('#%#', $ips)) ? 'LIKE' : 'IN') . " ($ips) 921 AND forum_id IN (0, " . implode(', ', $ip_forums) . ')'; 922 $result = $db->sql_query($sql); 923 924 if ($row = $db->sql_fetchrow($result)) 925 { 926 $ip_sql = array(); 927 do 928 { 929 $ip_sql[] = $row['poster_id']; 930 } 931 while ($row = $db->sql_fetchrow($result)); 932 933 $sql_where .= ' AND ' . $db->sql_in_set('u.user_id', $ip_sql); 934 } 935 else 936 { 937 // A minor fudge but it does the job :D 938 $sql_where .= " AND u.user_id = 0"; 939 } 940 unset($ip_forums); 941 942 $db->sql_freeresult($result); 943 } 944 } 945 } 946 947 $first_char = request_var('first_char', ''); 948 949 if ($first_char == 'other') 950 { 951 for ($i = 97; $i < 123; $i++) 952 { 953 $sql_where .= " AND u.username_clean NOT LIKE '" . chr($i) . "%'"; 954 } 955 } 956 else if ($first_char) 957 { 958 $sql_where .= " AND u.username_clean LIKE '" . $db->sql_escape(substr($first_char, 0, 1)) . "%'"; 959 } 960 961 // Are we looking at a usergroup? If so, fetch additional info 962 // and further restrict the user info query 963 if ($mode == 'group') 964 { 965 // We JOIN here to save a query for determining membership for hidden groups. ;) 966 $sql = 'SELECT g.*, ug.user_id 967 FROM ' . GROUPS_TABLE . ' g 968 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) 969 WHERE g.group_id = $group_id"; 970 $result = $db->sql_query($sql); 971 $group_row = $db->sql_fetchrow($result); 972 $db->sql_freeresult($result); 973 974 if (!$group_row) 975 { 976 trigger_error('NO_GROUP'); 977 } 978 979 switch ($group_row['group_type']) 980 { 981 case GROUP_OPEN: 982 $group_row['l_group_type'] = 'OPEN'; 983 break; 984 985 case GROUP_CLOSED: 986 $group_row['l_group_type'] = 'CLOSED'; 987 break; 988 989 case GROUP_HIDDEN: 990 $group_row['l_group_type'] = 'HIDDEN'; 991 992 // Check for membership or special permissions 993 if (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $group_row['user_id'] != $user->data['user_id']) 994 { 995 trigger_error('NO_GROUP'); 996 } 997 break; 998 999 case GROUP_SPECIAL: 1000 $group_row['l_group_type'] = 'SPECIAL'; 1001 break; 1002 1003 case GROUP_FREE: 1004 $group_row['l_group_type'] = 'FREE'; 1005 break; 1006 } 1007 1008 $avatar_img = ''; 1009 if ($group_row['group_avatar']) 1010 { 1011 switch ($group_row['group_avatar_type']) 1012 { 1013 case AVATAR_UPLOAD: 1014 $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; 1015 break; 1016 1017 case AVATAR_GALLERY: 1018 $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; 1019 break; 1020 } 1021 $avatar_img .= $group_row['group_avatar']; 1022 1023 $avatar_img = '<img src="' . $avatar_img . '" width="' . $group_row['group_avatar_width'] . '" height="' . $group_row['group_avatar_height'] . '" alt="" />'; 1024 } 1025 1026 $rank_title = $rank_img = $rank_img_src = ''; 1027 if ($group_row['group_rank']) 1028 { 1029 if (isset($ranks['special'][$group_row['group_rank']])) 1030 { 1031 $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title']; 1032 } 1033 $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 />' : ''; 1034 $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : ''; 1035 } 1036 else 1037 { 1038 $rank_title = ''; 1039 $rank_img = ''; 1040 $rank_img_src = ''; 1041 } 1042 1043 $template->assign_vars(array( 1044 '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']), 1045 'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'], 1046 'GROUP_COLOR' => $group_row['group_colour'], 1047 'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']], 1048 'GROUP_RANK' => $rank_title, 1049 1050 'AVATAR_IMG' => $avatar_img, 1051 'RANK_IMG' => $rank_img, 1052 'RANK_IMG_SRC' => $rank_img_src, 1053 1054 '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) : '',) 1055 ); 1056 1057 $sql_select = ', ug.group_leader'; 1058 $sql_from = ', ' . USER_GROUP_TABLE . ' ug '; 1059 $order_by = 'ug.group_leader DESC, '; 1060 1061 $sql_where .= " AND ug.user_pending = 0 AND u.user_id = ug.user_id AND ug.group_id = $group_id"; 1062 } 1063 1064 // Sorting and order 1065 if (!isset($sort_key_sql[$sort_key])) 1066 { 1067 $sort_key = $default_key; 1068 } 1069 1070 $order_by .= $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); 1071 1072 // Count the users ... 1073 if ($sql_where) 1074 { 1075 $sql = 'SELECT COUNT(u.user_id) AS total_users 1076 FROM ' . USERS_TABLE . " u$sql_from 1077 WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ") 1078 $sql_where"; 1079 $result = $db->sql_query($sql); 1080 $total_users = (int) $db->sql_fetchfield('total_users'); 1081 $db->sql_freeresult($result); 1082 } 1083 else 1084 { 1085 $total_users = $config['num_users']; 1086 } 1087 1088 $s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '> </option>'; 1089 for ($i = 97; $i < 123; $i++) 1090 { 1091 $s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i-32) . '</option>'; 1092 } 1093 $s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>' . $user->lang['OTHER'] . '</option>'; 1094 1095 // Build a relevant pagination_url 1096 $params = array(); 1097 foreach (array('_POST', '_GET') as $global_var) 1098 { 1099 foreach ($$global_var as $key => $var) 1100 { 1101 if ($global_var == '_POST') 1102 { 1103 unset($_GET[$key]); 1104 } 1105 1106 if (in_array($key, array('submit', 'start', 'mode', 'char')) || empty($var)) 1107 { 1108 continue; 1109 } 1110 1111 $params[] = urlencode($key) . '=' . urlencode(htmlspecialchars($var)); 1112 } 1113 } 1114 1115 $u_hide_find_member = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); 1116 1117 $params[] = "mode=$mode"; 1118 $pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", implode('&', $params)); 1119 1120 // Some search user specific data 1121 if ($mode == 'searchuser' && ($config['load_search'] || $auth->acl_get('a_'))) 1122 { 1123 $group_selected = request_var('search_group_id', 0); 1124 $s_group_select = '<option value="0"' . ((!$group_selected) ? ' selected="selected"' : '') . '> </option>'; 1125 1126 $sql = 'SELECT group_id, group_name, group_type 1127 FROM ' . GROUPS_TABLE . ' 1128 WHERE group_type <> ' . GROUP_HIDDEN . ' 1129 ORDER BY group_name ASC'; 1130 $result = $db->sql_query($sql); 1131 1132 while ($row = $db->sql_fetchrow($result)) 1133 { 1134 $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>'; 1135 } 1136 $db->sql_freeresult($result); 1137 1138 $template->assign_vars(array( 1139 'USERNAME' => $username, 1140 'EMAIL' => $email, 1141 'ICQ' => $icq, 1142 'AIM' => $aim, 1143 'YAHOO' => $yahoo, 1144 'MSNM' => $msn, 1145 'JABBER' => $jabber, 1146 'JOINED' => implode('-', $joined), 1147 'ACTIVE' => implode('-', $active), 1148 'COUNT' => $count, 1149 'IP' => $ipdomain, 1150 1151 'S_SEARCH_USER' => true, 1152 'S_FORM_NAME' => $form, 1153 'S_FIELD_NAME' => $field, 1154 'S_COUNT_OPTIONS' => $s_find_count, 1155 'S_SORT_OPTIONS' => $s_sort_key, 1156 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, 1157 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, 1158 'S_GROUP_SELECT' => $s_group_select, 1159 'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) 1160 ); 1161 } 1162 1163 $sql = 'SELECT session_user_id, MAX(session_time) AS session_time 1164 FROM ' . SESSIONS_TABLE . ' 1165 WHERE session_time >= ' . (time() - $config['session_length']) . ' 1166 AND session_user_id <> ' . ANONYMOUS . ' 1167 GROUP BY session_user_id'; 1168 $result = $db->sql_query($sql); 1169 1170 $session_times = array(); 1171 while ($row = $db->sql_fetchrow($result)) 1172 { 1173 $session_times[$row['session_user_id']] = $row['session_time']; 1174 } 1175 $db->sql_freeresult($result); 1176 1177 // Do the SQL thang 1178 $sql = "SELECT u.* 1179 $sql_select 1180 FROM " . USERS_TABLE . " u 1181 $sql_from 1182 WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ") 1183 $sql_where 1184 ORDER BY $order_by"; 1185 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); 1186 1187 $id_cache = array(); 1188 while ($row = $db->sql_fetchrow($result)) 1189 { 1190 $row['session_time'] = (!empty($session_times[$row['user_id']])) ? $session_times[$row['user_id']] : ''; 1191 1192 $id_cache[$row['user_id']] = $row; 1193 } 1194 $db->sql_freeresult($result); 1195 1196 // Load custom profile fields 1197 if ($config['load_cpf_memberlist']) 1198 { 1199 include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); 1200 $cp = new custom_profile(); 1201 1202 // Grab all profile fields from users in id cache for later use - similar to the poster cache 1203 $profile_fields_cache = $cp->generate_profile_fields_template('grab', array_keys($id_cache)); 1204 } 1205 1206 $i = 0; 1207 foreach ($id_cache as $user_id => $row) 1208 { 1209 $cp_row = array(); 1210 if ($config['load_cpf_memberlist']) 1211 { 1212 $cp_row = (isset($profile_fields_cache[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array(); 1213 } 1214 1215 $memberrow = array_merge(show_profile($row), array( 1216 'ROW_NUMBER' => $i + ($start + 1), 1217 1218 'S_CUSTOM_PROFILE' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, 1219 'S_GROUP_LEADER' => (isset($row['group_leader']) && $row['group_leader']) ? true : false, 1220 1221 'U_VIEWPROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id)) 1222 ); 1223 1224 if (isset($cp_row['row']) && sizeof($cp_row['row'])) 1225 { 1226 $memberrow = array_merge($memberrow, $cp_row['row']); 1227 } 1228 1229 $template->assign_block_vars('memberrow', $memberrow); 1230 1231 if (isset($cp_row['blockrow']) && sizeof($cp_row['blockrow'])) 1232 { 1233 foreach ($cp_row['blockrow'] as $field_data) 1234 { 1235 $template->assign_block_vars('memberrow.custom_fields', $field_data); 1236 } 1237 } 1238 1239 $i++; 1240 unset($id_cache[$user_id]); 1241 } 1242 1243 // Generate page 1244 $template->assign_vars(array( 1245 'PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start), 1246 'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start), 1247 'TOTAL_USERS' => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users), 1248 1249 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), 1250 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 1251 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 1252 'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']), 1253 'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']), 1254 'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']), 1255 'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']), 1256 'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']), 1257 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 1258 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 1259 1260 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser') : '', 1261 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser') ? $u_hide_find_member : '', 1262 'U_SORT_USERNAME' => $pagination_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 1263 'U_SORT_FROM' => $pagination_url . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 1264 'U_SORT_JOINED' => $pagination_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), 1265 'U_SORT_POSTS' => $pagination_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), 1266 'U_SORT_EMAIL' => $pagination_url . '&sk=e&sd=' . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), 1267 'U_SORT_WEBSITE' => $pagination_url . '&sk=f&sd=' . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), 1268 'U_SORT_LOCATION' => $pagination_url . '&sk=n&sd=' . (($sort_key == 'n' && $sort_dir == 'a') ? 'd' : 'a'), 1269 'U_SORT_ICQ' => $pagination_url . '&sk=g&sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), 1270 'U_SORT_AIM' => $pagination_url . '&sk=h&sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'), 1271 'U_SORT_MSN' => $pagination_url . '&sk=i&sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'), 1272 'U_SORT_YIM' => $pagination_url . '&sk=j&sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'), 1273 'U_SORT_ACTIVE' => $pagination_url . '&sk=k&sd=' . (($sort_key == 'k' && $sort_dir == 'a') ? 'd' : 'a'), 1274 'U_SORT_RANK' => $pagination_url . '&sk=m&sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'), 1275 'U_LIST_CHAR' => $pagination_url . '&sk=a&sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a'), 1276 1277 'S_SHOW_GROUP' => ($mode == 'group') ? true : false, 1278 'S_MODE_SELECT' => $s_sort_key, 1279 'S_ORDER_SELECT' => $s_sort_dir, 1280 'S_CHAR_OPTIONS' => $s_char_options, 1281 'S_MODE_ACTION' => $pagination_url . "&form=$form") 1282 ); 1283 } 1284 1285 // Output the page 1286 page_header($page_title); 1287 1288 $template->set_filenames(array( 1289 'body' => $template_html) 1290 ); 1291 make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); 1292 1293 page_footer(); 1294 1295 /** 1296 * Get user rank title and image 1297 */ 1298 function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src) 1299 { 1300 global $ranks, $config; 1301 1302 if (!empty($user_rank)) 1303 { 1304 $rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : ''; 1305 $rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : ''; 1306 $rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : ''; 1307 } 1308 else 1309 { 1310 if (isset($ranks['normal'])) 1311 { 1312 foreach ($ranks['normal'] as $rank) 1313 { 1314 if ($user_posts >= $rank['rank_min']) 1315 { 1316 $rank_title = $rank['rank_title']; 1317 $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : ''; 1318 $rank_img_src = (!empty($rank['rank_image'])) ? $config['ranks_path'] . '/' . $rank['rank_image'] : ''; 1319 break; 1320 } 1321 } 1322 } 1323 } 1324 } 1325 1326 /** 1327 * Prepare profile data 1328 */ 1329 function show_profile($data) 1330 { 1331 global $config, $auth, $template, $user, $phpEx, $phpbb_root_path; 1332 1333 $username = $data['username']; 1334 $user_id = $data['user_id']; 1335 1336 $rank_title = $rank_img = $rank_img_src = ''; 1337 get_user_rank($data['user_rank'], $data['user_posts'], $rank_title, $rank_img, $rank_img_src); 1338 1339 if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_email')) 1340 { 1341 $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']); 1342 } 1343 else 1344 { 1345 $email = ''; 1346 } 1347 1348 $last_visit = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit']; 1349 1350 if ($config['load_onlinetrack']) 1351 { 1352 $update_time = $config['load_online_time'] * 60; 1353 $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['user_allow_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; 1354 } 1355 else 1356 { 1357 $online = false; 1358 } 1359 1360 $age = ''; 1361 1362 if ($data['user_birthday']) 1363 { 1364 list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday'])); 1365 1366 if ($bday_year) 1367 { 1368 $now = getdate(time() + $user->timezone + $user->dst - (date('H', time()) - gmdate('H', time())) * 3600); 1369 1370 $diff = $now['mon'] - $bday_month; 1371 if ($diff == 0) 1372 { 1373 $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; 1374 } 1375 else 1376 { 1377 $diff = ($diff < 0) ? 1 : 0; 1378 } 1379 1380 $age = (int) ($now['year'] - $bday_year - $diff); 1381 } 1382 } 1383 1384 // Dump it out to the template 1385 return array( 1386 'AGE' => $age, 1387 'USERNAME' => $username, 1388 'USER_COLOR' => (!empty($data['user_colour'])) ? $data['user_colour'] : '', 1389 'RANK_TITLE' => $rank_title, 1390 'JOINED' => $user->format_date($data['user_regdate']), 1391 'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit), 1392 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, 1393 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, 1394 1395 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 1396 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, 1397 'RANK_IMG' => $rank_img, 1398 'RANK_IMG_SRC' => $rank_img_src, 1399 '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" />' : '', 1400 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, 1401 1402 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $user_id), 1403 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', 1404 '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) : '', 1405 'U_WARN' => $auth->acl_getf_global('m_warn') ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '', 1406 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '', 1407 'U_EMAIL' => $email, 1408 'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '', 1409 'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . $data['user_icq'] : '', 1410 'U_AIM' => ($data['user_aim']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $user_id) : '', 1411 'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $data['user_yim'] . '&.src=pg' : '', 1412 'U_MSN' => ($data['user_msnm']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $user_id) : '', 1413 'U_JABBER' => ($data['user_jabber']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', 1414 'LOCATION' => ($data['user_from']) ? $data['user_from'] : '', 1415 1416 'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username), 1417 ); 1418 } 1419 1420 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 22 00:35:05 2006 | Cross-referenced by PHPXref 0.6 |