[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 define("IN_MYBB", 1); 13 define('THIS_SCRIPT', 'memberlist.php'); 14 15 $templatelist = "memberlist,memberlist_search,memberlist_user,memberlist_user_groupimage,memberlist_user_avatar,multipage_prevpage"; 16 $templatelist .= ",multipage_nextpage,multipage_page_current,multipage_page,multipage_start,multipage_end,multipage,memberlist_referrals,memberlist_referrals_bit"; 17 require_once "./global.php"; 18 19 // Load global language phrases 20 $lang->load("memberlist"); 21 22 if($mybb->settings['enablememberlist'] == 0) 23 { 24 error($lang->memberlist_disabled); 25 } 26 27 $plugins->run_hooks("memberlist_start"); 28 29 add_breadcrumb($lang->nav_memberlist); 30 31 if($mybb->usergroup['canviewmemberlist'] == 0) 32 { 33 error_no_permission(); 34 } 35 36 // Showing advanced search page? 37 if($mybb->input['action'] == "search") 38 { 39 $plugins->run_hooks("memberlist_search"); 40 eval("\$search_page = \"".$templates->get("memberlist_search")."\";"); 41 output_page($search_page); 42 } 43 else 44 { 45 $colspan = 5; 46 $search_url = ''; 47 48 // Referral? 49 if($mybb->settings['usereferrals'] == 1) 50 { 51 $colspan = 6; 52 eval("\$referral_header = \"".$templates->get("memberlist_referrals")."\";"); 53 } 54 55 // Incoming sort field? 56 if($mybb->input['sort']) 57 { 58 $mybb->input['sort'] = strtolower($mybb->input['sort']); 59 } 60 else 61 { 62 $mybb->input['sort'] = $mybb->settings['default_memberlist_sortby']; 63 } 64 65 switch($mybb->input['sort']) 66 { 67 case "regdate": 68 $sort_field = "u.regdate"; 69 break; 70 case "lastvisit": 71 $sort_field = "u.lastactive"; 72 break; 73 case "reputation": 74 $sort_field = "u.reputation"; 75 break; 76 case "postnum": 77 $sort_field = "u.postnum"; 78 break; 79 case "referrals": 80 $sort_field = "u.referrals"; 81 break; 82 default: 83 $sort_field = "u.username"; 84 $mybb->input['sort'] = 'username'; 85 break; 86 } 87 $sort_selected[$mybb->input['sort']] = " selected=\"selected\""; 88 89 // Incoming sort order? 90 if($mybb->input['order']) 91 { 92 $mybb->input['order'] = strtolower($mybb->input['order']); 93 } 94 else 95 { 96 $mybb->input['order'] = strtolower($mybb->settings['default_memberlist_order']); 97 } 98 99 if($mybb->input['order'] == "ascending" || (!$mybb->input['order'] && $mybb->input['sort'] == 'username')) 100 { 101 $sort_order = "ASC"; 102 $mybb->input['order'] = "ascending"; 103 } 104 else 105 { 106 $sort_order = "DESC"; 107 $mybb->input['order'] = "descending"; 108 } 109 $order_check[$mybb->input['order']] = " checked=\"checked\""; 110 111 // Incoming results per page? 112 $mybb->input['perpage'] = intval($mybb->input['perpage']); 113 if($mybb->input['perpage'] > 0 && $mybb->input['perpage'] <= 500) 114 { 115 $per_page = $mybb->input['perpage']; 116 } 117 else if($mybb->settings['membersperpage']) 118 { 119 $per_page = $mybb->input['perpage'] = intval($mybb->settings['membersperpage']); 120 } 121 else 122 { 123 $per_page = $mybb->input['perpage'] = 20; 124 } 125 126 $search_query = '1=1'; 127 $search_url = "memberlist.php?sort={$mybb->input['sort']}&order={$mybb->input['order']}&perpage={$mybb->input['perpage']}"; 128 129 // Limiting results to a certain letter 130 if($mybb->input['letter']) 131 { 132 $letter = chr(ord($mybb->input['letter'])); 133 if($mybb->input['letter'] == -1) 134 { 135 $search_query .= " AND u.username NOT REGEXP('[a-zA-Z]')"; 136 } 137 else if(strlen($letter) == 1) 138 { 139 $search_query .= " AND u.username LIKE '".$db->escape_string_like($letter)."%'"; 140 } 141 $search_url .= "&letter={$letter}"; 142 } 143 144 // Searching for a matching username 145 $search_username = htmlspecialchars_uni(trim($mybb->input['username'])); 146 if($search_username != '') 147 { 148 $username_like_query = $db->escape_string_like($search_username); 149 150 // Name begins with 151 if($mybb->input['username_match'] == "begins") 152 { 153 $search_query .= " AND u.username LIKE '".$username_like_query."%'"; 154 $search_url .= "&username_match=begins"; 155 } 156 // Just contains 157 else 158 { 159 $search_query .= " AND u.username LIKE '%".$username_like_query."%'"; 160 } 161 162 $search_url .= "&username=".urlencode($search_username); 163 } 164 165 // Website contains 166 $search_website = htmlspecialchars_uni($mybb->input['website']); 167 if(trim($mybb->input['website'])) 168 { 169 $search_query .= " AND u.website LIKE '%".$db->escape_string_like($mybb->input['website'])."%'"; 170 $search_url .= "&website=".urlencode($mybb->input['website']); 171 } 172 173 // AIM Identity 174 if(trim($mybb->input['aim'])) 175 { 176 $search_query .= " AND u.aim LIKE '%".$db->escape_string_like($mybb->input['aim'])."%'"; 177 $search_url .= "&aim=".urlencode($mybb->input['aim']); 178 } 179 180 // ICQ Number 181 if(trim($mybb->input['icq'])) 182 { 183 $search_query .= " AND u.icq LIKE '%".$db->escape_string_like($mybb->input['icq'])."%'"; 184 $search_url .= "&icq=".urlencode($mybb->input['icq']); 185 } 186 187 // MSN/Windows Live Messenger address 188 if(trim($mybb->input['msn'])) 189 { 190 $search_query .= " AND u.msn LIKE '%".$db->escape_string_like($mybb->input['msn'])."%'"; 191 $search_url .= "&msn=".urlencode($mybb->input['msn']); 192 } 193 194 // Yahoo! Messenger address 195 if(trim($mybb->input['yahoo'])) 196 { 197 $search_query .= " AND u.yahoo LIKE '%".$db->escape_string_like($mybb->input['yahoo'])."%'"; 198 $search_url .= "&yahoo=".urlencode($mybb->input['yahoo']); 199 } 200 201 $query = $db->simple_select("users u", "COUNT(*) AS users", "{$search_query}"); 202 $num_users = $db->fetch_field($query, "users"); 203 204 $page = intval($mybb->input['page']); 205 if($page && $page > 0) 206 { 207 $start = ($page - 1) * $per_page; 208 } 209 else 210 { 211 $start = 0; 212 $page = 1; 213 } 214 $search_url = htmlspecialchars_uni($search_url); 215 $multipage = multipage($num_users, $per_page, $page, $search_url); 216 217 // Cache a few things 218 $usergroups_cache = $cache->read('usergroups'); 219 $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC')); 220 while($usertitle = $db->fetch_array($query)) 221 { 222 $usertitles_cache[$usertitle['posts']] = $usertitle; 223 } 224 $query = $db->query(" 225 SELECT u.*, f.* 226 FROM ".TABLE_PREFIX."users u 227 LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid) 228 WHERE {$search_query} 229 ORDER BY {$sort_field} {$sort_order} 230 LIMIT {$start}, {$per_page} 231 "); 232 while($user = $db->fetch_array($query)) 233 { 234 $user = $plugins->run_hooks("memberlist_user", $user); 235 if(!$user['username']) 236 { 237 continue; 238 } 239 240 $alt_bg = alt_trow(); 241 242 $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']); 243 244 $user['profilelink'] = build_profile_link($user['username'], $user['uid']); 245 246 // Get the display usergroup 247 if(!$user['displaygroup']) 248 { 249 $user['displaygroup'] = $user['usergroup']; 250 } 251 $usergroup = $usergroups_cache[$user['displaygroup']]; 252 253 // Build referral? 254 if($mybb->settings['usereferrals'] == 1) 255 { 256 eval("\$referral_bit = \"".$templates->get("memberlist_referrals_bit")."\";"); 257 } 258 259 // Work out the usergroup/title stuff 260 if(!empty($usergroup['image'])) 261 { 262 if(!empty($mybb->user['language'])) 263 { 264 $language = $mybb->user['language']; 265 } 266 else 267 { 268 $language = $mybb->settings['bblanguage']; 269 } 270 $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']); 271 $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']); 272 eval("\$usergroup['groupimage'] = \"".$templates->get("memberlist_user_groupimage")."\";"); 273 } 274 275 $has_custom_title = 0; 276 if(trim($user['usertitle']) != "") 277 { 278 $has_custom_title = 1; 279 } 280 281 if($usergroup['usertitle'] != "" && !$has_custom_title) 282 { 283 $user['usertitle'] = $usergroup['usertitle']; 284 } 285 elseif(is_array($usertitles_cache) && !$usergroup['usertitle']) 286 { 287 foreach($usertitles_cache as $posts => $titleinfo) 288 { 289 if($user['postnum'] >= $posts) 290 { 291 if(!$has_custom_title) 292 { 293 $user['usertitle'] = $titleinfo['title']; 294 } 295 $user['stars'] = $titleinfo['stars']; 296 $user['starimage'] = $titleinfo['starimage']; 297 break; 298 } 299 } 300 } 301 302 if($usergroup['stars']) 303 { 304 $user['stars'] = $usergroup['stars']; 305 } 306 307 if(!$user['starimage']) 308 { 309 $user['starimage'] = $usergroup['starimage']; 310 } 311 312 if($user['starimage']) 313 { 314 // Only display stars if we have an image to use... 315 $starimage = str_replace("{theme}", $theme['imgdir'], $user['starimage']); 316 $user['userstars'] = ''; 317 318 for($i = 0; $i < $user['stars']; ++$i) 319 { 320 $user['userstars'] .= "<img src=\"{$starimage}\" border=\"0\" alt=\"*\" />"; 321 } 322 } 323 324 if($user['userstars'] && $usergroup['groupimage']) 325 { 326 $user['userstars'] = "<br />".$user['userstars']; 327 } 328 329 // Show avatar 330 if($user['avatar'] != '') 331 { 332 $user['avatar'] = htmlspecialchars_uni($user['avatar']); 333 $avatar_dimensions = explode("|", $user['avatardimensions']); 334 335 if($avatar_dimensions[0] && $avatar_dimensions[1]) 336 { 337 list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['memberlistmaxavatarsize'])); 338 if($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height) 339 { 340 require_once MYBB_ROOT."inc/functions_image.php"; 341 $scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height); 342 $avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\""; 343 } 344 else 345 { 346 $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\""; 347 } 348 } 349 350 eval("\$user['avatar'] = \"".$templates->get("memberlist_user_avatar")."\";"); 351 } 352 else 353 { 354 $user['avatar'] = ""; 355 } 356 357 $user['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']).", ".my_date($mybb->settings['timeformat'], $user['regdate']); 358 $user['lastvisit'] = my_date($mybb->settings['dateformat'], $user['lastactive']).", ".my_date($mybb->settings['timeformat'], $user['lastactive']); 359 $user['postnum'] = my_number_format($user['postnum']); 360 eval("\$users .= \"".$templates->get("memberlist_user")."\";"); 361 } 362 363 // Do we have no results? 364 if(!$users) 365 { 366 $users = "<tr>\n<td colspan=\"".$colspan."\" align=\"center\" class=\"trow1\">$lang->error_no_members</td>\n</tr>"; 367 } 368 369 $plugins->run_hooks("memberlist_end"); 370 371 eval("\$memberlist = \"".$templates->get("memberlist")."\";"); 372 output_page($memberlist); 373 } 374 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |