PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/system/bootstrap.php

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