2020-01-26 13:19:35 +00:00
|
|
|
<?php declare(strict_types=1);
|
2015-08-02 14:47:04 +00:00
|
|
|
/*
|
|
|
|
* Load all the files into memory, sanitise the environment, but don't
|
|
|
|
* actually do anything as far as the app is concerned
|
|
|
|
*/
|
|
|
|
|
2019-10-02 09:49:32 +00:00
|
|
|
global $cache, $config, $database, $user, $page, $_tracer;
|
2015-08-02 18:29:25 +00:00
|
|
|
|
2018-11-05 22:30:18 +00:00
|
|
|
require_once "core/sys_config.php";
|
|
|
|
require_once "core/polyfills.php";
|
|
|
|
require_once "core/util.php";
|
2016-05-11 22:27:42 +00:00
|
|
|
require_once "vendor/autoload.php";
|
2015-08-02 14:47:04 +00:00
|
|
|
|
|
|
|
// set up and purify the environment
|
|
|
|
_version_check();
|
|
|
|
_sanitise_environment();
|
|
|
|
|
2019-07-31 13:52:17 +00:00
|
|
|
// The trace system has a certain amount of memory consumption every time it is used,
|
|
|
|
// so to prevent running out of memory during complex operations code that uses it should
|
|
|
|
// check if tracer output is enabled before making use of it.
|
|
|
|
$tracer_enabled = constant('TRACE_FILE')!==null;
|
|
|
|
|
2015-08-02 14:47:04 +00:00
|
|
|
// load base files
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->begin("Bootstrap");
|
2019-08-07 19:53:59 +00:00
|
|
|
$_tracer->begin("Opening core files");
|
2017-09-17 18:37:30 +00:00
|
|
|
$_shm_files = array_merge(
|
2019-05-28 16:59:38 +00:00
|
|
|
zglob("core/*.php"),
|
|
|
|
zglob("core/{".ENABLED_MODS."}/*.php"),
|
2019-08-07 19:53:59 +00:00
|
|
|
zglob("ext/*/info.php")
|
2015-08-02 14:47:04 +00:00
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($_shm_files as $_shm_filename) {
|
|
|
|
if (basename($_shm_filename)[0] != "_") {
|
|
|
|
require_once $_shm_filename;
|
|
|
|
}
|
2015-08-02 14:47:04 +00:00
|
|
|
}
|
2017-09-17 18:37:30 +00:00
|
|
|
unset($_shm_files);
|
|
|
|
unset($_shm_filename);
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->end();
|
2015-08-02 14:47:04 +00:00
|
|
|
|
2019-10-02 09:49:32 +00:00
|
|
|
$_tracer->begin("Connecting to Cache");
|
|
|
|
$cache = new Cache(CACHE_DSN);
|
|
|
|
$_tracer->end();
|
|
|
|
|
2019-09-29 13:50:31 +00:00
|
|
|
$_tracer->begin("Connecting to DB");
|
|
|
|
$database = new Database();
|
|
|
|
$config = new DatabaseConfig($database);
|
|
|
|
$_tracer->end();
|
|
|
|
|
2019-08-07 19:53:59 +00:00
|
|
|
$_tracer->begin("Loading extension info");
|
|
|
|
ExtensionInfo::load_all_extension_info();
|
|
|
|
Extension::determine_enabled_extensions();
|
|
|
|
$_tracer->end();
|
|
|
|
|
|
|
|
$_tracer->begin("Opening enabled extension files");
|
|
|
|
$_shm_files = zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/main.php");
|
|
|
|
foreach ($_shm_files as $_shm_filename) {
|
|
|
|
if (basename($_shm_filename)[0] != "_") {
|
|
|
|
require_once $_shm_filename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($_shm_files);
|
|
|
|
unset($_shm_filename);
|
|
|
|
$_tracer->end();
|
|
|
|
|
2015-08-02 14:47:04 +00:00
|
|
|
// load the theme parts
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->begin("Loading themelets");
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach (_get_themelet_files(get_theme()) as $themelet) {
|
|
|
|
require_once $themelet;
|
2015-08-02 14:47:04 +00:00
|
|
|
}
|
2015-08-02 18:29:25 +00:00
|
|
|
unset($themelet);
|
2015-08-02 14:47:04 +00:00
|
|
|
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->end();
|
2015-08-02 14:47:04 +00:00
|
|
|
|
2019-06-27 13:12:15 +00:00
|
|
|
// hook up event handlers
|
|
|
|
$_tracer->begin("Loading event listeners");
|
2015-08-02 19:54:41 +00:00
|
|
|
_load_event_listeners();
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->end();
|
2019-07-05 18:14:09 +00:00
|
|
|
|
2019-11-03 18:28:38 +00:00
|
|
|
if (AUTO_DB_UPGRADE) {
|
|
|
|
send_event(new DatabaseUpgradeEvent());
|
2019-11-03 17:19:37 +00:00
|
|
|
}
|
2019-11-03 18:32:50 +00:00
|
|
|
send_event(new InitExtEvent());
|
2019-07-05 19:49:47 +00:00
|
|
|
$_tracer->end();
|