forked from kajona/kajonacms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
91 lines (70 loc) · 4.26 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*"******************************************************************************************************
* (c) 2004-2006 by MulchProductions, www.mulchprod.de *
* (c) 2007-2014 by Kajona, www.kajona.de *
* Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt *
*-------------------------------------------------------------------------------------------------------*
* $Id$ *
********************************************************************************************************/
/**
* @package module_system
*/
//helper for bad bad bad cases
function rawIncludeError($strFileMissed) {
$strErrorMessage = "<html><head></head><body><div style=\"border: 1px solid red; padding: 5px; margin: 20px; font-family: arial,verdana, serif; font-size: 12px; \">\n";
$strErrorMessage .= "<div style=\"background-color: #cccccc; color: #000000; font-weight: bold; \">An error occurred:</div>\n";
$strErrorMessage .= "Error including necessary files. Can't proceed.<br />";
$strErrorMessage .= "Searched for ".$strFileMissed." but failed. Going home now...<br />";
$strErrorMessage .= "</div></body></html>";
die($strErrorMessage);
}
//---The Path on the filesystem--------------------------------------------------------------------------
//Determine the current path on the filesystem. Use the dir-name of the current file
define("_realpath_", str_replace(" ", "\040", substr(__DIR__, 0, -5)));
define("_corepath_", str_replace(" ", "\040", __DIR__));
//--- Loader pre-configuration
if(!defined("_xmlLoader_"))
define("_xmlLoader_", false);
//---Include Section 1-----------------------------------------------------------------------------------
//Setting up the default timezone, determined by the server / environment. may be redefined by _system_timezone_
@date_default_timezone_set(date_default_timezone_get());
//Functions to have fun & check for mb-string
if(!@include_once _corepath_."/module_system/system/functions.php")
rawIncludeError(_corepath_."/module_system/system/functions.php");
//Exception-Handler
if(!@include_once _corepath_."/module_system/system/class_exception.php")
rawIncludeError("global exception handler");
//register global exception handler for exceptions thrown but not catched (bad style ;) )
@set_exception_handler(array("class_exception", "globalExceptionHandler"));
//Include the logging-engine
if(!@include_once _corepath_."/module_system/system/class_logger.php")
rawIncludeError("logging engine");
//---The Path on web-------------------------------------------------------------------------------------
require_once _corepath_."/module_system/system/class_config.php";
$strHeaderName = class_config::readPlainConfigsFromFilesystem("https_header");
$strHeaderValue = strtolower(class_config::readPlainConfigsFromFilesystem("https_header_value"));
if(strpos($_SERVER['SCRIPT_FILENAME'], "/debug/")) {
//Determine the current path on the web
$strWeb = dirname(
(isset($_SERVER[$strHeaderName]) && (strtolower($_SERVER[$strHeaderName]) == $strHeaderValue) ? "https://" : "http://") .
$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']
);
define("_webpath_", saveUrlEncode(substr_replace($strWeb, "", strrpos($strWeb, "/"))));
}
else {
//Determine the current path on the web
$strWeb = dirname(
(isset($_SERVER[$strHeaderName]) && (strtolower($_SERVER[$strHeaderName]) == $strHeaderValue) ? "https://" : "http://") .
(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "localhost").$_SERVER['SCRIPT_NAME']
);
define("_webpath_", saveUrlEncode($strWeb));
}
//---Include Section 2-----------------------------------------------------------------------------------
//load module-ids
bootstrapIncludeModuleIds();
//---Auto-Loader for classes-----------------------------------------------------------------------------
require_once _corepath_."/module_system/system/class_classloader.php";
spl_autoload_register(array(class_classloader::getInstance(), "loadClass"));
//The Carrier-Class
if(!@include_once _corepath_."/module_system/system/class_carrier.php")
rawIncludeError("carrier-class");