[ Index ]

PHP Cross Reference of MyBB 1.6.5

title

Body

[close]

/inc/ -> init.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: init.php 5456 2011-05-01 14:25:55Z ralgith $
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  if(function_exists("unicode_decode"))
  19  {
  20      // Unicode extension introduced in 6.0
  21      error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_STRICT);
  22  }
  23  elseif(defined("E_DEPRECATED"))
  24  {
  25      // E_DEPRECATED introduced in 5.3
  26      error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE);
  27  }
  28  else
  29  {
  30      error_reporting(E_ALL & ~E_NOTICE);
  31  }
  32  
  33  /* Defines the root directory for MyBB.
  34  
  35      Uncomment the below line and set the path manually
  36      if you experience problems. Acceptable values are:
  37  
  38      Always add a trailing slash to the end of the path.
  39  
  40      * Path to your copy of MyBB
  41      * "./"
  42   */
  43  //define('MYBB_ROOT', "./");
  44  
  45  // Attempt autodetection
  46  if(!defined('MYBB_ROOT'))
  47  {
  48      define('MYBB_ROOT', dirname(dirname(__FILE__))."/");
  49  }
  50  
  51  define("TIME_NOW", time());
  52  
  53  if(function_exists('date_default_timezone_set') && !ini_get('date.timezone'))
  54  {
  55      date_default_timezone_set('GMT');
  56  }
  57  
  58  require_once  MYBB_ROOT."inc/functions_compat.php";
  59  
  60  require_once  MYBB_ROOT."inc/class_error.php";
  61  $error_handler = new errorHandler();
  62  
  63  require_once  MYBB_ROOT."inc/functions.php";
  64  
  65  require_once  MYBB_ROOT."inc/class_timers.php";
  66  $maintimer = new timer();
  67  
  68  require_once  MYBB_ROOT."inc/class_core.php";
  69  $mybb = new MyBB;
  70  
  71  if(!file_exists(MYBB_ROOT."inc/config.php"))
  72  {
  73      $mybb->trigger_generic_error("board_not_installed");
  74  }
  75  
  76  // Include the required core files
  77  require_once MYBB_ROOT."inc/config.php";
  78  $mybb->config = &$config;
  79  
  80  if(!isset($config['database']))
  81  {
  82      $mybb->trigger_generic_error("board_not_installed");
  83  }
  84  
  85  if(!is_array($config['database']))
  86  {
  87      $mybb->trigger_generic_error("board_not_upgraded");
  88  }
  89  
  90  if(empty($config['admin_dir']))
  91  {
  92      $config['admin_dir'] = "admin";
  93  }
  94  
  95  // Trigger an error if the installation directory exists
  96  if(is_dir(MYBB_ROOT."install") && !file_exists(MYBB_ROOT."install/lock"))
  97  {
  98      $mybb->trigger_generic_error("install_directory");
  99  }
 100  
 101  require_once MYBB_ROOT."inc/db_".$config['database']['type'].".php";
 102  
 103  switch($config['database']['type'])
 104  {
 105      case "sqlite":
 106          $db = new DB_SQLite;
 107          break;
 108      case "pgsql":
 109          $db = new DB_PgSQL;
 110          break;
 111      case "mysqli":
 112          $db = new DB_MySQLi;
 113          break;
 114      default:
 115          $db = new DB_MySQL;
 116  }
 117  
 118  // Check if our DB engine is loaded
 119  if(!extension_loaded($db->engine))
 120  {
 121      // Throw our super awesome db loading error
 122      $mybb->trigger_generic_error("sql_load_error");
 123  }
 124  
 125  require_once  MYBB_ROOT."inc/class_templates.php";
 126  $templates = new templates;
 127  
 128  require_once  MYBB_ROOT."inc/class_datacache.php";
 129  $cache = new datacache;
 130  
 131  require_once  MYBB_ROOT."inc/class_plugins.php";
 132  $plugins = new pluginSystem;
 133  
 134  // Include our base data handler class
 135  require_once  MYBB_ROOT."inc/datahandler.php";
 136  
 137  // Connect to Database
 138  define("TABLE_PREFIX", $config['database']['table_prefix']);
 139  $db->connect($config['database']);
 140  $db->set_table_prefix(TABLE_PREFIX);
 141  $db->type = $config['database']['type'];
 142  
 143  // Language initialisation
 144  require_once  MYBB_ROOT."inc/class_language.php";
 145  $lang = new MyLanguage;
 146  $lang->set_path(MYBB_ROOT."inc/languages");
 147  
 148  // Load cache
 149  $cache->cache();
 150  
 151  // Load Settings
 152  if(file_exists(MYBB_ROOT."inc/settings.php"))
 153  {
 154      require_once  MYBB_ROOT."inc/settings.php";
 155  }
 156  
 157  if(!file_exists(MYBB_ROOT."inc/settings.php") || !$settings)
 158  {
 159      if(function_exists('rebuild_settings'))
 160      {
 161          rebuild_settings();
 162      }
 163      else
 164      {
 165          $options = array(
 166              "order_by" => "title",
 167              "order_dir" => "ASC"
 168          );
 169          
 170          $query = $db->simple_select("settings", "value, name", "", $options);
 171          while($setting = $db->fetch_array($query))
 172          {
 173              $setting['value'] = str_replace("\"", "\\\"", $setting['value']);
 174              $settings[$setting['name']] = $setting['value'];
 175          }
 176          $db->free_result($query);
 177      }
 178  }
 179  
 180  $settings['wolcutoff'] = $settings['wolcutoffmins']*60;
 181  $settings['bbname_orig'] = $settings['bbname'];
 182  $settings['bbname'] = strip_tags($settings['bbname']);
 183  $settings['orig_bblanguage'] = $settings['bblanguage'];
 184  
 185  // Fix for people who for some specify a trailing slash on the board URL
 186  if(substr($settings['bburl'], -1) == "/")
 187  {
 188      $settings['bburl'] = my_substr($settings['bburl'], 0, -1);
 189  }
 190  
 191  // Setup our internal settings and load our encryption key
 192  $settings['internal'] = $cache->read("internal_settings");
 193  if(!$settings['internal']['encryption_key'])
 194  {
 195      $cache->update("internal_settings", array('encryption_key' => random_str(32)));
 196      $settings['internal'] = $cache->read("internal_settings");
 197  }
 198  
 199  $mybb->settings = &$settings;
 200  $mybb->parse_cookies();
 201  $mybb->cache = &$cache;
 202  
 203  if($mybb->settings['useshutdownfunc'] != 0)
 204  {
 205      $mybb->use_shutdown = true;
 206      register_shutdown_function(array(&$mybb, "__destruct"));
 207  }
 208  
 209  // Did we just upgrade to a new version and haven't run the upgrade scripts yet?
 210  $version = $cache->read("version");
 211  if(!defined("IN_INSTALL") && !defined("IN_UPGRADE") && $version['version_code'] < $mybb->version_code)
 212  {
 213      $version_history = $cache->read("version_history");
 214      if(empty($version_history) || file_exists(MYBB_ROOT."install/resources/upgrade".intval(end($version_history)+1).".php"))
 215      {
 216          $mybb->trigger_generic_error("board_not_upgraded");
 217      }
 218  }
 219  
 220  // Load plugins
 221  if(!defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1))
 222  {
 223      $plugins->load();
 224  }
 225  
 226  // Set up any shutdown functions we need to run globally
 227  add_shutdown('send_mail_queue');
 228  
 229  /* URL Definitions */
 230  if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
 231  {
 232      define('FORUM_URL', "forum-{fid}.html");
 233      define('FORUM_URL_PAGED', "forum-{fid}-page-{page}.html");
 234      define('THREAD_URL', "thread-{tid}.html");
 235      define('THREAD_URL_PAGED', "thread-{tid}-page-{page}.html");
 236      define('THREAD_URL_ACTION', 'thread-{tid}-{action}.html');
 237      define('THREAD_URL_POST', 'thread-{tid}-post-{pid}.html');
 238      define('POST_URL', "post-{pid}.html");
 239      define('PROFILE_URL', "user-{uid}.html");
 240      define('ANNOUNCEMENT_URL', "announcement-{aid}.html");
 241      define('CALENDAR_URL', "calendar-{calendar}.html");
 242      define('CALENDAR_URL_YEAR', 'calendar-{calendar}-year-{year}.html');
 243      define('CALENDAR_URL_MONTH', 'calendar-{calendar}-year-{year}-month-{month}.html');
 244      define('CALENDAR_URL_DAY', 'calendar-{calendar}-year-{year}-month-{month}-day-{day}.html');
 245      define('CALENDAR_URL_WEEK', 'calendar-{calendar}-week-{week}.html');
 246      define('EVENT_URL', "event-{eid}.html");
 247      define('INDEX_URL', "index.php");
 248  }
 249  else
 250  {
 251      define('FORUM_URL', "forumdisplay.php?fid={fid}");
 252      define('FORUM_URL_PAGED', "forumdisplay.php?fid={fid}&page={page}");
 253      define('THREAD_URL', "showthread.php?tid={tid}");
 254      define('THREAD_URL_PAGED', "showthread.php?tid={tid}&page={page}");
 255      define('THREAD_URL_ACTION', 'showthread.php?tid={tid}&action={action}');
 256      define('THREAD_URL_POST', 'showthread.php?tid={tid}&pid={pid}');
 257      define('POST_URL', "showthread.php?pid={pid}");
 258      define('PROFILE_URL', "member.php?action=profile&uid={uid}");
 259      define('ANNOUNCEMENT_URL', "announcements.php?aid={aid}");
 260      define('CALENDAR_URL', "calendar.php?calendar={calendar}");
 261      define('CALENDAR_URL_YEAR', "calendar.php?action=yearview&calendar={calendar}&year={year}");
 262      define('CALENDAR_URL_MONTH', "calendar.php?calendar={calendar}&year={year}&month={month}");
 263      define('CALENDAR_URL_DAY', 'calendar.php?action=dayview&calendar={calendar}&year={year}&month={month}&day={day}');
 264      define('CALENDAR_URL_WEEK', 'calendar.php?action=weekview&calendar={calendar}&week={week}');
 265      define('EVENT_URL', "calendar.php?action=event&eid={eid}");
 266      define('INDEX_URL', "index.php");
 267  }
 268  
 269  // An array of valid date formats (Used for user selections etc)
 270  $date_formats = array(
 271      1 => "m-d-Y",
 272      2 => "m-d-y",
 273      3 => "m.d.Y",
 274      4 => "m.d.y",
 275      5 => "d-m-Y",
 276      6 => "d-m-y",
 277      7 => "d.m.Y",
 278      8 => "d.m.y",
 279      9 => "F jS, Y",
 280      10 => "l, F jS, Y",
 281      11 => "jS F, Y",
 282      12 => "l, jS F, Y"
 283  );
 284  
 285  // An array of valid time formats (Used for user selections etc)
 286  $time_formats = array(
 287      1 => "h:i a",
 288      2 => "h:i A",
 289      3 => "H:i"
 290  );
 291  
 292  ?>


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