[ Index ]

PHP Cross Reference of MyBB 1.8.29

title

Body

[close]

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


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