d4f43e39c44f77fe35dd0a7107f4d8a4f7b17399
[ssproject1617.git] / testcms-final-anon / system / bootstrap.php
1 <?php defined('IN_CMS') or die('No direct access allowed.');
2
3 /**
4 Check our environment
5 */
6 if(version_compare(PHP_VERSION, '5.3.0', '<')) {
7 // echo and exit with some usful information
8 echo 'Test CMS requires PHP 5.3 or newer, your current environment is running PHP ' . PHP_VERSION;
9 exit(1);
10 }
11
12 // get our autoloader
13 require PATH . 'system/classes/helpers.php';
14 require PATH . 'system/classes/autoload.php';
15
16 // directly map classes for super fast loading
17 Autoloader::map(array(
18 'Config' => PATH . 'system/classes/config.php',
19 'Error' => PATH . 'system/classes/error.php',
20 'Session' => PATH . 'system/classes/session.php',
21 'TestCMS' => PATH . 'system/classes/testcms.php',
22 'Template' => PATH . 'system/classes/template.php',
23 'Request' => PATH . 'system/classes/request.php',
24 'Response' => PATH . 'system/classes/response.php',
25 'Log' => PATH . 'system/classes/log.php',
26 'Db' => PATH . 'system/classes/db.php',
27 'IoC' => PATH . 'system/classes/ioc.php',
28 'Url' => PATH . 'system/classes/url.php'
29 ));
30
31 // tell the autoloader where to find classes
32 Autoloader::directory(array(
33 PATH . 'system/classes/'
34 ));
35
36 // register the auto loader
37 Autoloader::register();
38
39 /**
40 Report all errors let our error class decide which to display
41 */
42 error_reporting(-1);
43
44 /**
45 Error display will be handled by our error class
46 */
47 ini_safe_set('display_errors', false);
48
49 /**
50 Disable magic quotes
51 note: magic quotes is deprecated in PHP 5.3
52 src: php.net/manual/en/security.magicquotes.disabling.php
53 */
54 if(function_exists('get_magic_quotes_gpc')) {
55 if(get_magic_quotes_gpc()) {
56 ini_safe_set('magic_quotes_gpc', false);
57 ini_safe_set('magic_quotes_runtime', false);
58 ini_safe_set('magic_quotes_sybase', false);
59 }
60 }
61
62 /**
63 Check our installation
64 */
65 if(Config::load(PATH . 'config.php') === false) {
66 // looks like we are missing a config file
67 echo file_get_contents(PATH . 'system/admin/theme/error_config.php');
68 exit(1);
69 }
70
71 // Register the default timezone for the application.
72 date_default_timezone_set(Config::get('application.timezone'));
73
74 // Register the PHP exception handler.
75 set_exception_handler(array('Error', 'exception'));
76
77 // Register the PHP error handler.
78 set_error_handler(array('Error', 'native'));
79
80 // Register the shutdown handler.
81 register_shutdown_function(array('Error', 'shutdown'));
82
83 /**
84 Start session handler
85 */
86 Session::start();
87
88 /**
89 Handle routing
90 */
91 TestCMS::run();
92
93 /**
94 Close and end session
95 */
96 Session::end();
97
98 /**
99 Output awesomeness!
100 */
101 Response::send();