/** * Initializes the environment: * * - Loads hooks * - Converts all input variables to the configured character set * * @return void */ public static function init() { if (self::$init === TRUE) { return; } // Test if the current environment is command-line self::$is_cli = PHP_SAPI === 'cli'; // Test if the current evironment is Windows self::$is_windows = DIRECTORY_SEPARATOR === '\\'; // Determine if the server supports UTF-8 natively utf8::$server_utf8 = extension_loaded('mbstring'); // Load the file path cache self::$file_path = Kohana::cache('kohana_file_paths'); // Load the configuration loader self::$config = new Kohana_Config_Loader(); // Import the main configuration locally $config = self::$config->kohana; // Set the default locale self::$default_locale = $config->default_locale; self::$save_cache = $config->save_cache; self::$charset = $config->charset; // Localize the environment self::locale($config->locale); // Set the enviroment time self::timezone($config->timezone); // Enable modules self::modules($config->modules); if ($hooks = self::list_files('hooks', TRUE)) { foreach ($hooks as $hook) { // Load each hook in the order they appear require $hook; } } // Convert global variables to current charset. $_GET = utf8::clean($_GET, self::$charset); $_POST = utf8::clean($_POST, self::$charset); $_SERVER = utf8::clean($_SERVER, self::$charset); // The system has been initialized self::$init = TRUE; }