/** * Initalizes the <i>Application</i>. */ public static function initalize() { // Initalizes configuration array require "../local/config.php"; Application::$config = $cfg; // Reads mode from config if (isset(Application::$config["mode"]) && Application::$config["mode"] == false) { // development mode Application::$mode = false; } else { // production mode // turns off all error reporting error_reporting(0); } // Initializes MySQL-connection if (!isset(Application::$config["mysql"])) { // Throws an error of there's no MySQL-access-data die("<b>Error: </b>MySQL access data is missing."); } switch (strtolower(Application::$config["mysql"]["driver"])) { // Checks, whether the mysql-driver from config is valid and constructs the classes instance ... case "pdo": Application::$connection = new PDOConnection(Application::$config["mysql"]["access"]["hostname"], Application::$config["mysql"]["access"]["database"], Application::$config["mysql"]["access"]["username"], Application::$config["mysql"]["access"]["password"]); break; default: // ...or lets the whole thing die otherwise. die("<b>Error: </b>Driver <i>" . Application::$config["mysql"]["driver"] . "</i> is invalid."); } // Initalizes path array $path = $_REQUEST["path"]; // Gets the path string. $path = strtolower($path); // Makes the path ignoring upper-/lowercase. $path = trim("/"); // Strips slashes from end of path, which prevents an empty array element. $path = explode("/", $path); // Transforms path string to array. Application::$path = $path; // Calculates ProjectEngine's root directory Application::$cookiePath = preg_replace("/^(.*)" . preg_quote($_GET["path"], "/") . "\$/", "\$1", $_SERVER["REQUEST_URI"]); Application::$root = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["HTTP_HOST"] . Application::$cookiePath; // Configures session and starts it session_cache_expire(); session_cache_limiter("nocache"); session_name("pe-session"); session_set_cookie_params(time() + 30 * 24 * 60 * 60, Application::$cookiePath); session_start(); }