add cms, add todo
[ssproject1617.git] / testcms-final-anon / system / bootstrap.php
diff --git a/testcms-final-anon/system/bootstrap.php b/testcms-final-anon/system/bootstrap.php
new file mode 100644 (file)
index 0000000..d4f43e3
--- /dev/null
@@ -0,0 +1,101 @@
+<?php defined('IN_CMS') or die('No direct access allowed.');\r
+\r
+/**\r
+       Check our environment\r
+*/\r
+if(version_compare(PHP_VERSION, '5.3.0', '<')) {\r
+       // echo and exit with some usful information\r
+       echo 'Test CMS requires PHP 5.3 or newer, your current environment is running PHP ' . PHP_VERSION;\r
+       exit(1);\r
+}\r
+\r
+// get our autoloader\r
+require PATH . 'system/classes/helpers.php';\r
+require PATH . 'system/classes/autoload.php';\r
+\r
+// directly map classes for super fast loading\r
+Autoloader::map(array(\r
+       'Config' => PATH . 'system/classes/config.php',\r
+       'Error' => PATH . 'system/classes/error.php',\r
+       'Session' => PATH . 'system/classes/session.php',\r
+       'TestCMS' => PATH . 'system/classes/testcms.php',\r
+       'Template' => PATH . 'system/classes/template.php',\r
+       'Request' => PATH . 'system/classes/request.php',\r
+       'Response' => PATH . 'system/classes/response.php',\r
+       'Log' => PATH . 'system/classes/log.php',\r
+       'Db' => PATH . 'system/classes/db.php',\r
+       'IoC' => PATH . 'system/classes/ioc.php',\r
+       'Url' => PATH . 'system/classes/url.php'\r
+));\r
+\r
+// tell the autoloader where to find classes\r
+Autoloader::directory(array(\r
+       PATH . 'system/classes/'\r
+));\r
+\r
+// register the auto loader\r
+Autoloader::register();\r
+\r
+/**\r
+       Report all errors let our error class decide which to display\r
+*/\r
+error_reporting(-1);\r
+\r
+/**\r
+       Error display will be handled by our error class\r
+*/\r
+ini_safe_set('display_errors', false);\r
+\r
+/**\r
+       Disable magic quotes\r
+       note: magic quotes is deprecated in PHP 5.3\r
+       src: php.net/manual/en/security.magicquotes.disabling.php\r
+*/\r
+if(function_exists('get_magic_quotes_gpc')) {\r
+       if(get_magic_quotes_gpc()) {\r
+               ini_safe_set('magic_quotes_gpc', false);\r
+               ini_safe_set('magic_quotes_runtime', false);\r
+               ini_safe_set('magic_quotes_sybase', false);\r
+       }\r
+}\r
+\r
+/**\r
+       Check our installation\r
+*/\r
+if(Config::load(PATH . 'config.php') === false) {\r
+       // looks like we are missing a config file\r
+       echo file_get_contents(PATH . 'system/admin/theme/error_config.php');\r
+       exit(1);\r
+}\r
+\r
+// Register the default timezone for the application.\r
+date_default_timezone_set(Config::get('application.timezone'));\r
+\r
+// Register the PHP exception handler.\r
+set_exception_handler(array('Error', 'exception'));\r
+\r
+// Register the PHP error handler.\r
+set_error_handler(array('Error', 'native'));\r
+\r
+// Register the shutdown handler.\r
+register_shutdown_function(array('Error', 'shutdown'));\r
+\r
+/**\r
+       Start session handler\r
+*/\r
+Session::start();\r
+\r
+/**\r
+       Handle routing\r
+*/\r
+TestCMS::run();\r
+\r
+/**\r
+       Close and end session\r
+*/\r
+Session::end();\r
+\r
+/**\r
+       Output awesomeness!\r
+*/\r
+Response::send();\r