[ Index ]

PHP Cross Reference of MyBB 1.8.12

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      eval('$statspage = "'.$templates->get('index_statspage').'";');
  38  }
  39  
  40  $whosonline = '';
  41  if($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0)
  42  {
  43      // Get the online users.
  44      if($mybb->settings['wolorder'] == 'username')
  45      {
  46          $order_by = 'u.username ASC';
  47          $order_by2 = 's.time DESC';
  48      }
  49      else
  50      {
  51          $order_by = 's.time DESC';
  52          $order_by2 = 'u.username ASC';
  53      }
  54  
  55      $timesearch = TIME_NOW - (int)$mybb->settings['wolcutoff'];
  56      $comma = '';
  57      $query = $db->query("
  58          SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup
  59          FROM ".TABLE_PREFIX."sessions s
  60          LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
  61          WHERE s.time > '".$timesearch."'
  62          ORDER BY {$order_by}, {$order_by2}
  63      ");
  64  
  65      $forum_viewers = $doneusers = array();
  66      $membercount = $guestcount = $anoncount = $botcount = 0;
  67      $onlinemembers = $comma = '';
  68  
  69      // Fetch spiders
  70      $spiders = $cache->read('spiders');
  71  
  72      // Loop through all users.
  73      while($user = $db->fetch_array($query))
  74      {
  75          // Create a key to test if this user is a search bot.
  76          $botkey = my_strtolower(str_replace('bot=', '', $user['sid']));
  77  
  78          // Decide what type of user we are dealing with.
  79          if($user['uid'] > 0)
  80          {
  81              // The user is registered.
  82              if(empty($doneusers[$user['uid']]) || $doneusers[$user['uid']] < $user['time'])
  83              {
  84                  // If the user is logged in anonymously, update the count for that.
  85                  if($user['invisible'] == 1)
  86                  {
  87                      ++$anoncount;
  88                  }
  89                  ++$membercount;
  90                  if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
  91                  {
  92                      // If this usergroup can see anonymously logged-in users, mark them.
  93                      if($user['invisible'] == 1)
  94                      {
  95                          $invisiblemark = '*';
  96                      }
  97                      else
  98                      {
  99                          $invisiblemark = '';
 100                      }
 101  
 102                      // Properly format the username and assign the template.
 103                      $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
 104                      $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
 105                      eval('$onlinemembers .= "'.$templates->get('index_whosonline_memberbit', 1, 0).'";');
 106                      $comma = $lang->comma;
 107                  }
 108                  // This user has been handled.
 109                  $doneusers[$user['uid']] = $user['time'];
 110              }
 111          }
 112          elseif(my_strpos($user['sid'], 'bot=') !== false && $spiders[$botkey])
 113          {
 114              // The user is a search bot.
 115              $onlinemembers .= $comma.format_name($spiders[$botkey]['name'], $spiders[$botkey]['usergroup']);
 116              $comma = $lang->comma;
 117              ++$botcount;
 118          }
 119          else
 120          {
 121              // The user is a guest.
 122              ++$guestcount;
 123          }
 124  
 125          if($user['location1'])
 126          {
 127              ++$forum_viewers[$user['location1']];
 128          }
 129      }
 130  
 131      // Build the who's online bit on the index page.
 132      $onlinecount = $membercount + $guestcount + $botcount;
 133  
 134      if($onlinecount != 1)
 135      {
 136          $onlinebit = $lang->online_online_plural;
 137      }
 138      else
 139      {
 140          $onlinebit = $lang->online_online_singular;
 141      }
 142      if($membercount != 1)
 143      {
 144          $memberbit = $lang->online_member_plural;
 145      }
 146      else
 147      {
 148          $memberbit = $lang->online_member_singular;
 149      }
 150      if($anoncount != 1)
 151      {
 152          $anonbit = $lang->online_anon_plural;
 153      }
 154      else
 155      {
 156          $anonbit = $lang->online_anon_singular;
 157      }
 158      if($guestcount != 1)
 159      {
 160          $guestbit = $lang->online_guest_plural;
 161      }
 162      else
 163      {
 164          $guestbit = $lang->online_guest_singular;
 165      }
 166      $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);
 167      eval('$whosonline = "'.$templates->get('index_whosonline').'";');
 168  }
 169  
 170  // Build the birthdays for to show on the index page.
 171  $bdays = $birthdays = '';
 172  if($mybb->settings['showbirthdays'] != 0)
 173  {
 174      // First, see what day this is.
 175      $bdaycount = $bdayhidden = 0;
 176      $bdaydate = my_date('j-n', TIME_NOW, '', 0);
 177      $year = my_date('Y', TIME_NOW, '', 0);
 178  
 179      $bdaycache = $cache->read('birthdays');
 180  
 181      if(!is_array($bdaycache))
 182      {
 183          $cache->update_birthdays();
 184          $bdaycache = $cache->read('birthdays');
 185      }
 186  
 187      $hiddencount = $today_bdays = 0;
 188      if(isset($bdaycache[$bdaydate]))
 189      {
 190          $hiddencount = $bdaycache[$bdaydate]['hiddencount'];
 191          $today_bdays = $bdaycache[$bdaydate]['users'];
 192      }
 193  
 194      $comma = '';
 195      if(!empty($today_bdays))
 196      {
 197          if((int)$mybb->settings['showbirthdayspostlimit'] > 0)
 198          {
 199              $bdayusers = array();
 200              foreach($today_bdays as $key => $bdayuser_pc)
 201              {
 202                  $bdayusers[$bdayuser_pc['uid']] = $key;
 203              }
 204  
 205              if(!empty($bdayusers))
 206              {
 207                  // Find out if our users have enough posts to be seen on our birthday list
 208                  $bday_sql = implode(',', array_keys($bdayusers));
 209                  $query = $db->simple_select('users', 'uid, postnum', "uid IN ({$bday_sql})");
 210  
 211                  while($bdayuser = $db->fetch_array($query))
 212                  {
 213                      if($bdayuser['postnum'] < $mybb->settings['showbirthdayspostlimit'])
 214                      {
 215                          unset($today_bdays[$bdayusers[$bdayuser['uid']]]);
 216                      }
 217                  }
 218              }
 219          }
 220  
 221          // We still have birthdays - display them in our list!
 222          if(!empty($today_bdays))
 223          {
 224              foreach($today_bdays as $bdayuser)
 225              {
 226                  if($bdayuser['displaygroup'] == 0)
 227                  {
 228                      $bdayuser['displaygroup'] = $bdayuser['usergroup'];
 229                  }
 230  
 231                  // If this user's display group can't be seen in the birthday list, skip it
 232                  if($groupscache[$bdayuser['displaygroup']] && $groupscache[$bdayuser['displaygroup']]['showinbirthdaylist'] != 1)
 233                  {
 234                      continue;
 235                  }
 236  
 237                  $age = '';
 238                  $bday = explode('-', $bdayuser['birthday']);
 239                  if($year > $bday['2'] && $bday['2'] != '')
 240                  {
 241                      $age = ' ('.($year - $bday['2']).')';
 242                  }
 243  
 244                  $bdayuser['username'] = format_name(htmlspecialchars_uni($bdayuser['username']), $bdayuser['usergroup'], $bdayuser['displaygroup']);
 245                  $bdayuser['profilelink'] = build_profile_link($bdayuser['username'], $bdayuser['uid']);
 246                  eval('$bdays .= "'.$templates->get('index_birthdays_birthday', 1, 0).'";');
 247                  ++$bdaycount;
 248                  $comma = $lang->comma;
 249              }
 250          }
 251      }
 252  
 253      if($hiddencount > 0)
 254      {
 255          if($bdaycount > 0)
 256          {
 257              $bdays .= ' - ';
 258          }
 259  
 260          $bdays .= "{$hiddencount} {$lang->birthdayhidden}";
 261      }
 262  
 263      // If there are one or more birthdays, show them.
 264      if($bdaycount > 0 || $hiddencount > 0)
 265      {
 266          eval('$birthdays = "'.$templates->get('index_birthdays').'";');
 267      }
 268  }
 269  
 270  // Build the forum statistics to show on the index page.
 271  $forumstats = '';
 272  if($mybb->settings['showindexstats'] != 0)
 273  {
 274      // First, load the stats cache.
 275      $stats = $cache->read('stats');
 276  
 277      // Check who's the newest member.
 278      if(!$stats['lastusername'])
 279      {
 280          $newestmember = $lang->nobody;;
 281      }
 282      else
 283      {
 284          $newestmember = build_profile_link($stats['lastusername'], $stats['lastuid']);
 285      }
 286  
 287      // Format the stats language.
 288      $lang->stats_posts_threads = $lang->sprintf($lang->stats_posts_threads, my_number_format($stats['numposts']), my_number_format($stats['numthreads']));
 289      $lang->stats_numusers = $lang->sprintf($lang->stats_numusers, my_number_format($stats['numusers']));
 290      $lang->stats_newestuser = $lang->sprintf($lang->stats_newestuser, $newestmember);
 291  
 292      // Find out what the highest users online count is.
 293      $mostonline = $cache->read('mostonline');
 294      if($onlinecount > $mostonline['numusers'])
 295      {
 296          $time = TIME_NOW;
 297          $mostonline['numusers'] = $onlinecount;
 298          $mostonline['time'] = $time;
 299          $cache->update('mostonline', $mostonline);
 300      }
 301      $recordcount = $mostonline['numusers'];
 302      $recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']);
 303      $recordtime = my_date($mybb->settings['timeformat'], $mostonline['time']);
 304  
 305      // Then format that language string.
 306      $lang->stats_mostonline = $lang->sprintf($lang->stats_mostonline, my_number_format($recordcount), $recorddate, $recordtime);
 307  
 308      eval('$forumstats = "'.$templates->get('index_stats').'";');
 309  }
 310  
 311  // Show the board statistics table only if one or more index statistics are enabled.
 312  $boardstats = '';
 313  if(($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0) || $mybb->settings['showindexstats'] != 0 || ($mybb->settings['showbirthdays'] != 0 && $bdaycount > 0))
 314  {
 315      if(!isset($stats) || isset($stats) && !is_array($stats))
 316      {
 317          // Load the stats cache.
 318          $stats = $cache->read('stats');
 319      }
 320  
 321      eval('$boardstats = "'.$templates->get('index_boardstats').'";');
 322  }
 323  
 324  if($mybb->user['uid'] == 0)
 325  {
 326      // Build a forum cache.
 327      $query = $db->simple_select('forums', '*', 'active!=0', array('order_by' => 'pid, disporder'));
 328  
 329      $forumsread = array();
 330      if(isset($mybb->cookies['mybb']['forumread']))
 331      {
 332          $forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);
 333      }
 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  
 347  while($forum = $db->fetch_array($query))
 348  {
 349      if($mybb->user['uid'] == 0)
 350      {
 351          if(!empty($forumsread[$forum['fid']]))
 352          {
 353              $forum['lastread'] = $forumsread[$forum['fid']];
 354          }
 355      }
 356      $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
 357  }
 358  $forumpermissions = forum_permissions();
 359  
 360  // Get the forum moderators if the setting is enabled.
 361  $moderatorcache = array();
 362  if($mybb->settings['modlist'] != 0 && $mybb->settings['modlist'] != 'off')
 363  {
 364      $moderatorcache = $cache->read('moderators');
 365  }
 366  
 367  $excols = 'index';
 368  $permissioncache['-1'] = '1';
 369  $bgcolor = 'trow1';
 370  
 371  // Decide if we're showing first-level subforums on the index page.
 372  $showdepth = 2;
 373  if($mybb->settings['subforumsindex'] != 0)
 374  {
 375      $showdepth = 3;
 376  }
 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);


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