Exemple #1
0
 static function init()
 {
     // Begin the benchmark
     self::$time_init = microtime(true);
     register_shutdown_function(array('Kennel', 'onShutdown'));
     if (array_key_exists('HTTP_HOST', $_SERVER)) {
         // Running from a HTTP request
         self::$ROOT_PATH = str_replace('\\', '/', dirname($_SERVER['SCRIPT_FILENAME']));
         self::$ROOT_URL = trim("http://{$_SERVER['HTTP_HOST']}", '\\/') . '/' . trim(substr(self::$ROOT_PATH, strlen($_SERVER['DOCUMENT_ROOT'])), '\\/');
         self::$ROOT_URL = trim(self::$ROOT_URL, '/');
     } else {
         // Runing from the command line
         self::$ROOT_PATH = str_replace('\\', '/', $_SERVER['PWD']);
     }
     // Get the application settings
     if (file_exists('settings.php')) {
         require_once 'settings.php';
         self::$_APP_SETTINGS = $settings;
     } else {
         self::controllerAction('Ksetup', 'firststeps');
     }
     // Detect the modules
     self::fetchModules();
     // Accept language prefixes if i18n is being used
     if (self::getSetting('i18n', 'enabled')) {
         router::prefix(self::getSetting('i18n', 'list'));
     }
     // Set the default timezone
     date_default_timezone_set(self::getSetting('application', 'timezone'));
     // Process the HTTP request (skipped when running from the command line)
     if (array_key_exists('HTTP_HOST', $_SERVER)) {
         Request::process();
     }
 }