PageRenderTime 94ms CodeModel.GetById 81ms app.highlight 9ms RepoModel.GetById 1ms 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/**
  4	Check our environment
  5*/
  6if(version_compare(PHP_VERSION, '5.3.0', '<')) {
  7	// echo and exit with some usful information
  8	echo 'Anchor requires PHP 5.3 or newer, your current environment is running PHP ' . PHP_VERSION;
  9	exit(1);
 10}
 11
 12// get our autoloader
 13require PATH . 'system/classes/helpers.php';
 14require PATH . 'system/classes/autoload.php';
 15
 16// directly map classes for super fast loading
 17Autoloader::map(array(
 18	'Config' => PATH . 'system/classes/config.php',
 19	'Error' => PATH . 'system/classes/error.php',
 20	'Session' => PATH . 'system/classes/session.php',
 21	'Anchor' => PATH . 'system/classes/anchor.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
 32Autoloader::directory(array(
 33	PATH . 'system/classes/'
 34));
 35
 36// register the auto loader
 37Autoloader::register();
 38
 39/**
 40	Report all errors let our error class decide which to display
 41*/
 42error_reporting(-1);
 43
 44/**
 45	Error display will be handled by our error class
 46*/
 47ini_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*/
 54if(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*/
 65if(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.
 72date_default_timezone_set(Config::get('application.timezone'));
 73
 74// Register the PHP exception handler.
 75set_exception_handler(array('Error', 'exception'));
 76
 77// Register the PHP error handler.
 78set_error_handler(array('Error', 'native'));
 79
 80// Register the shutdown handler.
 81register_shutdown_function(array('Error', 'shutdown'));
 82
 83/**
 84	Start session handler
 85*/
 86Session::start();
 87
 88/**
 89	Handle routing
 90*/
 91Anchor::run();
 92
 93/**
 94	Close and end session
 95*/
 96Session::end();
 97
 98/**
 99	Output awesomeness!
100*/
101Response::send();