[ Index ]

PHP Cross Reference of MyBB 1.6.5

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: global.php 5365 2011-02-16 21:59:02Z MattR $
  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) || stripos(SAPI_NAME, 'cgi') !== false || defined("ARCHIVE_QUERY_STRINGS"))
  45  {
  46      $url = $_SERVER['QUERY_STRING'];
  47      $base_url = $mybb->settings['bburl']."/archive/index.php?";
  48      $endpart = $url;
  49  }
  50  // Otherwise, we're using 100% friendly URLs
  51  else
  52  {
  53      if($_SERVER['REQUEST_URI'])
  54      {
  55          $url = $_SERVER['REQUEST_URI'];
  56      }
  57      elseif($_SERVER['REDIRECT_URL'])
  58      {
  59          $url = $_SERVER['REDIRECT_URL'];
  60      }
  61      elseif($_SERVER['PATH_INFO'])
  62      {
  63          $url = $_SERVER['PATH_INFO'];
  64      }
  65      else
  66      {
  67          $url = $_SERVER['PHP_SELF'];
  68      }
  69      $base_url = $mybb->settings['bburl']."/archive/index.php/";
  70      $endpart = my_substr(strrchr($url, "/"), 1);
  71  }
  72  
  73  $action = "index";
  74  
  75  // This seems to work the same as the block below except without the css bugs O_o
  76  $archiveurl = $mybb->settings['bburl'].'/archive';
  77  
  78  if($endpart != "index.php")
  79  {
  80      $endpart = str_replace(".html", "", $endpart);
  81      $todo = explode("-", $endpart, 3);
  82      if($todo[0])
  83      {
  84          $action = $action2 = $todo[0];
  85      }
  86      $page = intval($todo[2]);
  87      $id = intval($todo[1]);
  88  
  89      // Get the thread, announcement or forum information.
  90      if($action == "announcement")
  91      {
  92          $time = TIME_NOW;
  93          $query = $db->query("
  94              SELECT a.*, u.username
  95              FROM ".TABLE_PREFIX."announcements a
  96              LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
  97              WHERE a.aid='{$id}' AND startdate < '{$time}'  AND (enddate > '{$time}' OR enddate = 0)
  98          ");
  99          $announcement = $db->fetch_array($query);
 100          if(!$announcement['aid'])
 101          {
 102              $action = "404";
 103          }
 104      }
 105      elseif($action == "thread")
 106      {
 107          $query = $db->simple_select("threads", "*", "tid='{$id}' AND closed NOT LIKE 'moved|%'");
 108          $thread = $db->fetch_array($query);
 109          if(!$thread['tid'])
 110          {
 111              $action = "404";
 112          }
 113      }
 114      elseif($action == "forum")
 115      {
 116          $query = $db->simple_select("forums", "*", "fid='{$id}' AND active!=0 AND password=''");
 117          $forum = $db->fetch_array($query);
 118          if(!$forum['fid'])
 119          {
 120              $action = "404";
 121          }
 122      }
 123      elseif($action != 'index')
 124      {
 125          $action = "404";
 126      }
 127  }
 128  
 129  // Define the full MyBB version location of this page.
 130  if($action == "thread")
 131  {
 132      define(MYBB_LOCATION, get_thread_link($id));
 133  }
 134  elseif($action == "forum")
 135  {
 136      define(MYBB_LOCATION, get_forum_link($id));
 137  }
 138  elseif($action == "announcement")
 139  {
 140      define(MYBB_LOCATION, get_announcement_link($id));
 141  }
 142  else
 143  {
 144      define(MYBB_LOCATION, INDEX_URL);
 145  }
 146  
 147  // Initialise session
 148  $session = new session;
 149  $session->init();
 150  
 151  if(!$mybb->settings['bblanguage'])
 152  {
 153      $mybb->settings['bblanguage'] = "english";
 154  }
 155  $lang->set_language($mybb->settings['bblanguage']);
 156  
 157  // Load global language phrases
 158  $lang->load("global");
 159  $lang->load("messages");
 160  $lang->load("archive");
 161  
 162  // Draw up the basic part of our naviagation
 163  $navbits[0]['name'] = $mybb->settings['bbname_orig'];
 164  $navbits[0]['url'] = $mybb->settings['bburl']."/archive/index.php";
 165  
 166  // Check banned ip addresses
 167  if(is_banned_ip($session->ipaddress))
 168  {
 169      archive_error($lang->error_banned);
 170  }
 171  
 172  // If our board is closed..
 173  if($mybb->settings['boardclosed'] == 1)
 174  {
 175      if($mybb->usergroup['cancp'] != 1)
 176      {
 177          $lang->error_boardclosed .= "<blockquote>".$mybb->settings['boardclosed_reason']."</blockquote>";
 178          archive_error($lang->error_boardclosed);
 179      }
 180  }
 181  
 182  // Load Limiting - DIRECTORY_SEPARATOR checks if running windows
 183  if(DIRECTORY_SEPARATOR != '\\')
 184  {
 185      if($uptime = @exec('uptime'))
 186      {
 187          preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $uptime, $regs);
 188          $load = $regs[1];
 189          if($mybb->usergroup['cancp'] != 1 && $load > $mybb->settings['load'] && $mybb->settings['load'] > 0)
 190          {
 191              archive_error($lang->error_loadlimit);
 192          }
 193      }
 194  }
 195  
 196  if($mybb->usergroup['canview'] == 0)
 197  {
 198      archive_error_no_permission();
 199  }
 200  ?>


Generated: Sun Dec 11 14:16:27 2011 Cross-referenced by PHPXref 0.7.1