[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/archive/ -> global.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  // If archive mode does not work, uncomment the line below and try again
  13  // define("ARCHIVE_QUERY_STRINGS", 1);
  14  
  15  // Lets pretend we're a level higher
  16  chdir('./../');
  17  
  18  require_once dirname(dirname(__FILE__))."/inc/init.php";
  19  
  20  require_once  MYBB_ROOT."inc/functions_archive.php";
  21  require_once  MYBB_ROOT."inc/class_session.php";
  22  require_once  MYBB_ROOT."inc/class_parser.php";
  23  $parser = new postParser;
  24  
  25  $groupscache = $cache->read("usergroups");
  26  if(!is_array($groupscache))
  27  {
  28      $cache->update_usergroups();
  29      $groupscache = $cache->read("usergroups");
  30  }
  31  $fpermissioncache = $cache->read("forumpermissions");
  32  
  33  // Send headers before anything else.
  34  send_page_headers();
  35  
  36  // If the installer has not been removed and no lock exists, die.
  37  if(is_dir(MYBB_ROOT."install") && !file_exists(MYBB_ROOT."install/lock"))
  38  {
  39      echo "Please remove the install directory from your server, or create a file called 'lock' in the install directory. Until you do so, your board will remain unaccessable";
  40      exit;
  41  }
  42  
  43  // If the server OS is not Windows and not Apache or the PHP is running as a CGI or we have defined ARCHIVE_QUERY_STRINGS, use query strings - DIRECTORY_SEPARATOR checks if running windows
  44  // if((DIRECTORY_SEPARATOR == '\\' && stripos($_SERVER['SERVER_SOFTWARE'], 'apache') == false) || strstr(php_sapi_name(),'cgi') || defined("ARCHIVE_QUERY_STRINGS"))
  45  // http://dev.mybb.com/issues/1489 - remove automatic detection and rely on users to set the right option here
  46  if($mybb->settings['seourls_archive'] == 1)
  47  {
  48      if($_SERVER['REQUEST_URI'])
  49      {
  50          $url = $_SERVER['REQUEST_URI'];
  51      }
  52      elseif($_SERVER['REDIRECT_URL'])
  53      {
  54          $url = $_SERVER['REDIRECT_URL'];
  55      }
  56      elseif($_SERVER['PATH_INFO'])
  57      {
  58          $url = $_SERVER['PATH_INFO'];
  59      }
  60      else
  61      {
  62          $url = $_SERVER['PHP_SELF'];
  63      }
  64      $base_url = $mybb->settings['bburl']."/archive/index.php/";
  65      $endpart = my_substr(strrchr($url, "/"), 1);
  66  }
  67  else
  68  {
  69      $url = $_SERVER['QUERY_STRING'];
  70      $base_url = $mybb->settings['bburl']."/archive/index.php?";
  71      $endpart = $url;
  72  }
  73  
  74  $action = "index";
  75  
  76  // This seems to work the same as the block below except without the css bugs O_o
  77  $archiveurl = $mybb->settings['bburl'].'/archive';
  78  
  79  if($endpart != "index.php")
  80  {
  81      $endpart = str_replace(".html", "", $endpart);
  82      $todo = explode("-", $endpart, 3);
  83      if($todo[0])
  84      {
  85          $action = $action2 = $todo[0];
  86      }
  87      $page = intval($todo[2]);
  88      $id = intval($todo[1]);
  89  
  90      // Get the thread, announcement or forum information.
  91      if($action == "announcement")
  92      {
  93          $time = TIME_NOW;
  94          $query = $db->query("
  95              SELECT a.*, u.username
  96              FROM ".TABLE_PREFIX."announcements a
  97              LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
  98              WHERE a.aid='{$id}' AND startdate < '{$time}'  AND (enddate > '{$time}' OR enddate = 0)
  99          ");
 100          $announcement = $db->fetch_array($query);
 101          if(!$announcement['aid'])
 102          {
 103              $action = "404";
 104          }
 105      }
 106      elseif($action == "thread")
 107      {
 108          $query = $db->simple_select("threads", "*", "tid='{$id}' AND closed NOT LIKE 'moved|%'");
 109          $thread = $db->fetch_array($query);
 110          if(!$thread['tid'])
 111          {
 112              $action = "404";
 113          }
 114      }
 115      elseif($action == "forum")
 116      {
 117          $query = $db->simple_select("forums", "*", "fid='{$id}' AND active!=0 AND password=''");
 118          $forum = $db->fetch_array($query);
 119          if(!$forum['fid'])
 120          {
 121              $action = "404";
 122          }
 123      }
 124      elseif($action != 'index')
 125      {
 126          $action = "404";
 127      }
 128  }
 129  
 130  // Define the full MyBB version location of this page.
 131  if($action == "thread")
 132  {
 133      define(MYBB_LOCATION, get_thread_link($id));
 134  }
 135  elseif($action == "forum")
 136  {
 137      define(MYBB_LOCATION, get_forum_link($id));
 138  }
 139  elseif($action == "announcement")
 140  {
 141      define(MYBB_LOCATION, get_announcement_link($id));
 142  }
 143  else
 144  {
 145      define(MYBB_LOCATION, INDEX_URL);
 146  }
 147  
 148  // Initialise session
 149  $session = new session;
 150  $session->init();
 151  
 152  if(!$mybb->settings['bblanguage'])
 153  {
 154      $mybb->settings['bblanguage'] = "english";
 155  }
 156  $lang->set_language($mybb->settings['bblanguage']);
 157  
 158  // Load global language phrases
 159  $lang->load("global");
 160  $lang->load("messages");
 161  $lang->load("archive");
 162  
 163  // Draw up the basic part of our naviagation
 164  $navbits[0]['name'] = $mybb->settings['bbname_orig'];
 165  $navbits[0]['url'] = $mybb->settings['bburl']."/archive/index.php";
 166  
 167  // Check banned ip addresses
 168  if(is_banned_ip($session->ipaddress))
 169  {
 170      archive_error($lang->error_banned);
 171  }
 172  
 173  // If our board is closed..
 174  if($mybb->settings['boardclosed'] == 1)
 175  {
 176      if($mybb->usergroup['cancp'] != 1)
 177      {
 178          $lang->error_boardclosed .= "<blockquote>".$mybb->settings['boardclosed_reason']."</blockquote>";
 179          archive_error($lang->error_boardclosed);
 180      }
 181  }
 182  
 183  // Load Limiting - DIRECTORY_SEPARATOR checks if running windows
 184  if(DIRECTORY_SEPARATOR != '\\')
 185  {
 186      if($uptime = @exec('uptime'))
 187      {
 188          preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $regs);
 189          $load = $regs[1];
 190          if($mybb->usergroup['cancp'] != 1 && $load > $mybb->settings['load'] && $mybb->settings['load'] > 0)
 191          {
 192              archive_error($lang->error_loadlimit);
 193          }
 194      }
 195  }
 196  
 197  if($mybb->usergroup['canview'] == 0)
 198  {
 199      archive_error_no_permission();
 200  }
 201  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1