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