|
|
|
@ -65,31 +65,29 @@ class Flight {
|
|
|
|
|
* Initializes the framework.
|
|
|
|
|
*/
|
|
|
|
|
public static function init() {
|
|
|
|
|
static $initialized = false;
|
|
|
|
|
|
|
|
|
|
if (!$initialized) {
|
|
|
|
|
// Handle errors internally
|
|
|
|
|
set_error_handler(array(__CLASS__, 'handleError'));
|
|
|
|
|
|
|
|
|
|
// Handle exceptions internally
|
|
|
|
|
set_exception_handler(array(__CLASS__, 'handleException'));
|
|
|
|
|
|
|
|
|
|
// Fix magic quotes
|
|
|
|
|
if (get_magic_quotes_gpc()) {
|
|
|
|
|
$func = function ($value) use (&$func) {
|
|
|
|
|
return is_array($value) ? array_map($func, $value) : stripslashes($value);
|
|
|
|
|
};
|
|
|
|
|
$_GET = array_map($func, $_GET);
|
|
|
|
|
$_POST = array_map($func, $_POST);
|
|
|
|
|
$_COOKIE = array_map($func, $_COOKIE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load core components
|
|
|
|
|
if (self::$loader == null) {
|
|
|
|
|
self::$loader = new \flight\core\Loader();
|
|
|
|
|
self::$loader->start();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
self::$loader->reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self::$dispatcher == null) {
|
|
|
|
|
self::$dispatcher = new \flight\core\Dispatcher();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
self::$dispatcher->reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize autoloading
|
|
|
|
|
self::$loader->init();
|
|
|
|
|
// Register framework directory
|
|
|
|
|
self::$loader->addDirectory(dirname(__DIR__));
|
|
|
|
|
|
|
|
|
|
// Register default components
|
|
|
|
@ -115,9 +113,6 @@ class Flight {
|
|
|
|
|
|
|
|
|
|
// Enable output buffering
|
|
|
|
|
ob_start();
|
|
|
|
|
|
|
|
|
|
$initialized = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|