| [ Index ] |
PHP Cross Reference of MyBB 1.6.5 |
[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: index.php 5594 2011-09-14 13:13:41Z Tomm $ 10 */ 11 12 define("IN_MYBB", 1); 13 define('THIS_SCRIPT', 'index.php'); 14 15 $templatelist = "index,index_whosonline,index_welcomemembertext,index_welcomeguest,index_whosonline_memberbit,forumbit_depth1_cat,forumbit_depth1_forum,forumbit_depth2_cat,forumbit_depth2_forum,forumbit_depth1_forum_lastpost,forumbit_depth2_forum_lastpost,index_modcolumn,forumbit_moderators,forumbit_subforums,index_welcomeguesttext"; 16 $templatelist .= ",index_birthdays_birthday,index_birthdays,index_pms,index_loginform,index_logoutlink,index_stats,forumbit_depth3,forumbit_depth3_statusicon,index_boardstats"; 17 18 require_once "./global.php"; 19 20 require_once MYBB_ROOT."inc/functions_post.php"; 21 require_once MYBB_ROOT."inc/functions_forumlist.php"; 22 require_once MYBB_ROOT."inc/class_parser.php"; 23 $parser = new postParser; 24 25 $plugins->run_hooks("index_start"); 26 27 // Load global language phrases 28 $lang->load("index"); 29 30 $logoutlink = $loginform = ''; 31 if($mybb->user['uid'] != 0) 32 { 33 eval("\$logoutlink = \"".$templates->get("index_logoutlink")."\";"); 34 } 35 else 36 { 37 //Checks to make sure the user can login; they haven't had too many tries at logging in. 38 //Function call is not fatal 39 if(login_attempt_check(false) !== false) 40 { 41 eval("\$loginform = \"".$templates->get("index_loginform")."\";"); 42 } 43 } 44 $whosonline = ''; 45 if($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0) 46 { 47 // Get the online users. 48 $timesearch = TIME_NOW - $mybb->settings['wolcutoff']; 49 $comma = ''; 50 $query = $db->query(" 51 SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup 52 FROM ".TABLE_PREFIX."sessions s 53 LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid) 54 WHERE s.time>'$timesearch' 55 ORDER BY u.username ASC, s.time DESC 56 "); 57 58 $forum_viewers = array(); 59 $membercount = 0; 60 $onlinemembers = ''; 61 $guestcount = 0; 62 $anoncount = 0; 63 $doneusers = array(); 64 65 // Fetch spiders 66 $spiders = $cache->read("spiders"); 67 68 // Loop through all users. 69 while($user = $db->fetch_array($query)) 70 { 71 // Create a key to test if this user is a search bot. 72 $botkey = my_strtolower(str_replace("bot=", '', $user['sid'])); 73 74 // Decide what type of user we are dealing with. 75 if($user['uid'] > 0) 76 { 77 // The user is registered. 78 if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']]) 79 { 80 // If the user is logged in anonymously, update the count for that. 81 if($user['invisible'] == 1) 82 { 83 ++$anoncount; 84 } 85 ++$membercount; 86 if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) 87 { 88 // If this usergroup can see anonymously logged-in users, mark them. 89 if($user['invisible'] == 1) 90 { 91 $invisiblemark = "*"; 92 } 93 else 94 { 95 $invisiblemark = ''; 96 } 97 98 // Properly format the username and assign the template. 99 $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']); 100 $user['profilelink'] = build_profile_link($user['username'], $user['uid']); 101 eval("\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";"); 102 $comma = $lang->comma; 103 } 104 // This user has been handled. 105 $doneusers[$user['uid']] = $user['time']; 106 } 107 } 108 elseif(my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey]) 109 { 110 // The user is a search bot. 111 $onlinemembers .= $comma.format_name($spiders[$botkey]['name'], $spiders[$botkey]['usergroup']); 112 $comma = $lang->comma; 113 ++$botcount; 114 } 115 else 116 { 117 // The user is a guest. 118 ++$guestcount; 119 } 120 121 if($user['location1']) 122 { 123 $forum_viewers[$user['location1']]++; 124 } 125 } 126 127 // Build the who's online bit on the index page. 128 $onlinecount = $membercount + $guestcount + $botcount; 129 130 if($onlinecount != 1) 131 { 132 $onlinebit = $lang->online_online_plural; 133 } 134 else 135 { 136 $onlinebit = $lang->online_online_singular; 137 } 138 if($membercount != 1) 139 { 140 $memberbit = $lang->online_member_plural; 141 } 142 else 143 { 144 $memberbit = $lang->online_member_singular; 145 } 146 if($anoncount != 1) 147 { 148 $anonbit = $lang->online_anon_plural; 149 } 150 else 151 { 152 $anonbit = $lang->online_anon_singular; 153 } 154 if($guestcount != 1) 155 { 156 $guestbit = $lang->online_guest_plural; 157 } 158 else 159 { 160 $guestbit = $lang->online_guest_singular; 161 } 162 $lang->online_note = $lang->sprintf($lang->online_note, my_number_format($onlinecount), $onlinebit, $mybb->settings['wolcutoffmins'], my_number_format($membercount), $memberbit, my_number_format($anoncount), $anonbit, my_number_format($guestcount), $guestbit); 163 eval("\$whosonline = \"".$templates->get("index_whosonline")."\";"); 164 } 165 166 // Build the birthdays for to show on the index page. 167 $bdays = $birthdays = ''; 168 if($mybb->settings['showbirthdays'] != 0) 169 { 170 // First, see what day this is. 171 $bdaycount = 0; $bdayhidden = 0; 172 $bdaytime = TIME_NOW; 173 $bdaydate = my_date("j-n", $bdaytime, '', 0); 174 $year = my_date("Y", $bdaytime, '', 0); 175 176 $bdaycache = $cache->read("birthdays"); 177 178 if(!is_array($bdaycache)) 179 { 180 $cache->update_birthdays(); 181 $bdaycache = $cache->read("birthdays"); 182 } 183 184 $hiddencount = $bdaycache[$bdaydate]['hiddencount']; 185 $today_bdays = $bdaycache[$bdaydate]['users']; 186 187 $comma = ''; 188 if(!empty($today_bdays)) 189 { 190 if(intval($mybb->settings['showbirthdayspostlimit']) > 0) 191 { 192 $bdayusers = array(); 193 foreach($today_bdays as $key => $bdayuser_pc) 194 { 195 $bdayusers[$bdayuser_pc['uid']] = $key; 196 } 197 198 if(!empty($bdayusers)) 199 { 200 // Find out if our users have enough posts to be seen on our birthday list 201 $bday_sql = implode(",", array_keys($bdayusers)); 202 $query = $db->simple_select("users", "uid, postnum", "uid IN ({$bday_sql})"); 203 204 while($bdayuser = $db->fetch_array($query)) 205 { 206 if($bdayuser['postnum'] < $mybb->settings['showbirthdayspostlimit']) 207 { 208 unset($today_bdays[$bdayusers[$bdayuser['uid']]]); 209 } 210 } 211 } 212 } 213 214 // We still have birthdays - display them in our list! 215 if(!empty($today_bdays)) 216 { 217 foreach($today_bdays as $bdayuser) 218 { 219 if($bdayuser['displaygroup'] == 0) 220 { 221 $bdayuser['displaygroup'] = $bdayuser['usergroup']; 222 } 223 224 // If this user's display group can't be seen in the birthday list, skip it 225 if($groupscache[$bdayuser['displaygroup']] && $groupscache[$bdayuser['displaygroup']]['showinbirthdaylist'] != 1) 226 { 227 continue; 228 } 229 230 $bday = explode("-", $bdayuser['birthday']); 231 if($year > $bday['2'] && $bday['2'] != '') 232 { 233 $age = " (".($year - $bday['2']).")"; 234 } 235 else 236 { 237 $age = ''; 238 } 239 240 $bdayuser['username'] = format_name($bdayuser['username'], $bdayuser['usergroup'], $bdayuser['displaygroup']); 241 $bdayuser['profilelink'] = build_profile_link($bdayuser['username'], $bdayuser['uid']); 242 eval("\$bdays .= \"".$templates->get("index_birthdays_birthday", 1, 0)."\";"); 243 ++$bdaycount; 244 $comma = $lang->comma; 245 } 246 } 247 } 248 249 if($hiddencount > 0) 250 { 251 if($bdaycount > 0) 252 { 253 $bdays .= " - "; 254 } 255 $bdays .= "{$hiddencount} {$lang->birthdayhidden}"; 256 } 257 258 // If there are one or more birthdays, show them. 259 if($bdaycount > 0 || $hiddencount > 0) 260 { 261 eval("\$birthdays = \"".$templates->get("index_birthdays")."\";"); 262 } 263 } 264 265 // Build the forum statistics to show on the index page. 266 if($mybb->settings['showindexstats'] != 0) 267 { 268 // First, load the stats cache. 269 $stats = $cache->read("stats"); 270 271 // Check who's the newest member. 272 if(!$stats['lastusername']) 273 { 274 $newestmember = "no-one"; 275 } 276 else 277 { 278 $newestmember = build_profile_link($stats['lastusername'], $stats['lastuid']); 279 } 280 281 // Format the stats language. 282 $lang->stats_posts_threads = $lang->sprintf($lang->stats_posts_threads, my_number_format($stats['numposts']), my_number_format($stats['numthreads'])); 283 $lang->stats_numusers = $lang->sprintf($lang->stats_numusers, my_number_format($stats['numusers'])); 284 $lang->stats_newestuser = $lang->sprintf($lang->stats_newestuser, $newestmember); 285 286 // Find out what the highest users online count is. 287 $mostonline = $cache->read("mostonline"); 288 if($onlinecount > $mostonline['numusers']) 289 { 290 $time = TIME_NOW; 291 $mostonline['numusers'] = $onlinecount; 292 $mostonline['time'] = $time; 293 $cache->update("mostonline", $mostonline); 294 } 295 $recordcount = $mostonline['numusers']; 296 $recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']); 297 $recordtime = my_date($mybb->settings['timeformat'], $mostonline['time']); 298 299 // Then format that language string. 300 $lang->stats_mostonline = $lang->sprintf($lang->stats_mostonline, my_number_format($recordcount), $recorddate, $recordtime); 301 302 eval("\$forumstats = \"".$templates->get("index_stats")."\";"); 303 } 304 305 // Show the board statistics table only if one or more index statistics are enabled. 306 if($mybb->settings['showwol'] != 0 || $mybb->settings['showindexstats'] != 0 || ($mybb->settings['showbirthdays'] != 0 && $bdaycount > 0)) 307 { 308 if(!is_array($stats)) 309 { 310 // Load the stats cache. 311 $stats = $cache->read("stats"); 312 } 313 314 $post_code_string = ''; 315 if($mybb->user['uid']) 316 { 317 $post_code_string = "&my_post_key=".$mybb->post_code; 318 } 319 320 eval("\$boardstats = \"".$templates->get("index_boardstats")."\";"); 321 } 322 323 if($mybb->user['uid'] == 0) 324 { 325 // Build a forum cache. 326 $query = $db->query(" 327 SELECT * 328 FROM ".TABLE_PREFIX."forums 329 WHERE active != 0 330 ORDER BY pid, disporder 331 "); 332 333 $forumsread = unserialize($mybb->cookies['mybb']['forumread']); 334 } 335 else 336 { 337 // Build a forum cache. 338 $query = $db->query(" 339 SELECT f.*, fr.dateline AS lastread 340 FROM ".TABLE_PREFIX."forums f 341 LEFT JOIN ".TABLE_PREFIX."forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}') 342 WHERE f.active != 0 343 ORDER BY pid, disporder 344 "); 345 } 346 while($forum = $db->fetch_array($query)) 347 { 348 if($mybb->user['uid'] == 0) 349 { 350 if($forumsread[$forum['fid']]) 351 { 352 $forum['lastread'] = $forumsread[$forum['fid']]; 353 } 354 } 355 $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; 356 } 357 $forumpermissions = forum_permissions(); 358 359 // Get the forum moderators if the setting is enabled. 360 if($mybb->settings['modlist'] != "off") 361 { 362 $moderatorcache = $cache->read("moderators"); 363 } 364 365 $excols = "index"; 366 $permissioncache['-1'] = "1"; 367 $bgcolor = "trow1"; 368 369 // Decide if we're showing first-level subforums on the index page. 370 if($mybb->settings['subforumsindex'] != 0) 371 { 372 $showdepth = 3; 373 } 374 else 375 { 376 $showdepth = 2; 377 } 378 $forum_list = build_forumbits(); 379 $forums = $forum_list['forum_list']; 380 381 $plugins->run_hooks("index_end"); 382 383 eval("\$index = \"".$templates->get("index")."\";"); 384 output_page($index); 385 386 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Dec 11 14:16:27 2011 | Cross-referenced by PHPXref 0.7.1 |