[ Index ]

PHP Cross Reference of MyBB 1.8.17

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


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