[ Index ]

PHP Cross Reference of MyBB 1.8.27

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


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