[ Index ]

PHP Cross Reference of MyBB 1.8.26

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


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