[ Index ]

PHP Cross Reference of MyBB 1.8.21

title

Body

[close]

/ -> index.php (source)

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


2005 - 2019 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref 0.7.1