[ Index ]

PHP Cross Reference of MyBB 1.8.37

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


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