<?php define('EXECUTION_TIME_START', microtime()); // show errors when app is initializing ini_set('display_errors', 1); if (floatval(phpversion()) < 5.3) { exit('PHP 5.3 or greater is required for Walleye to function.' . "\n"); } // Be sure to configure the app in walleye.config.php require '../includes/core/walleye.php'; $appOptions = \Walleye\Config::getAppOptions(); // perform checks on config file to make sure app can run if ($appOptions['BASE'] == '') { exit('Please define the BASE directory' . "\n"); } if ($appOptions['ENVIRONMENT'] == \Walleye\Config::TESTING) { exit('Change the Environment from TESTING. TESTING should only be used for unit tests.' . "\n"); } if ($appOptions['ENVIRONMENT'] == \Walleye\Config::DEVELOPMENT && $appOptions['DEV_DOMAIN'] == '') { exit('Please define the DEV_DOMAIN.' . "\n"); } if ($appOptions['ENVIRONMENT'] == \Walleye\Config::PRODUCTION && $appOptions['PROD_DOMAIN'] == '') { exit('Please define the PROD_DOMAIN.' . "\n"); } if (!is_bool($appOptions['LOG_ERRORS'])) { exit('LOG_ERRORS must be a boolean.' . "\n"); } if (!is_numeric($appOptions['SESSION_KEY_EXPIRE_TIME'])) { exit('SESSION_KEY_EXPIRE_TIME should be set AND be numeric' . "\n"); } if (!is_bool($appOptions['PRINT_APP_INFO_ON_LOAD'])) {
/** * Starts the session, stores the post or get data, and the path given in the url */ private function __construct() { $this->startTime = EXECUTION_TIME_START; $appOptions = Config::getAppOptions(); $dbOptions = Config::getDbOptions(); if ($appOptions['ENVIRONMENT'] == Config::PRODUCTION) { self::$environment = Config::PRODUCTION; session_start(); $this->dbOptions = array('ENGINE' => $dbOptions['PROD_ENGINE'], 'SERVER' => $dbOptions['PROD_SERVER'], 'USER' => $dbOptions['PROD_USER'], 'PASS' => $dbOptions['PROD_PASS'], 'DATABASE' => $dbOptions['PROD_DATABASE'], 'PORT' => $dbOptions['PROD_PORT']); $this->appOptions = array('BASE' => $appOptions['BASE'], 'DOMAIN' => $appOptions['PROD_DOMAIN'], 'ENVIRONMENT' => $appOptions['ENVIRONMENT'], 'LOG_ERRORS' => $appOptions['LOG_ERRORS'], 'REG_KEY_EXPIRE_TIME' => $appOptions['REG_KEY_EXPIRE_TIME'], 'SESSION_KEY_EXPIRE_TIME' => $appOptions['SESSION_KEY_EXPIRE_TIME'], 'EMAIL_FROM' => $appOptions['EMAIL_FROM'], 'PRINT_APP_INFO_ON_LOAD' => $appOptions['PRINT_APP_INFO_ON_LOAD']); $this->data = $this->getDataFromUrl($_SERVER["REQUEST_URI"]); $url_array = explode('?', $_SERVER["REQUEST_URI"]); $this->url = $url_array[0]; $this->routes = \Walleye\Config::getRoutes(); if (isset($this->appOptions['BASE'])) { self::$server_base_dir = $this->appOptions['BASE']; } if (isset($this->appOptions['DOMAIN'])) { self::$domain = $this->appOptions['DOMAIN']; } } else { if ($appOptions['ENVIRONMENT'] == Config::DEVELOPMENT) { self::$environment = Config::DEVELOPMENT; session_start(); $this->dbOptions = array('ENGINE' => $dbOptions['DEV_ENGINE'], 'SERVER' => $dbOptions['DEV_SERVER'], 'USER' => $dbOptions['DEV_USER'], 'PASS' => $dbOptions['DEV_PASS'], 'DATABASE' => $dbOptions['DEV_DATABASE'], 'PORT' => $dbOptions['DEV_PORT']); $this->appOptions = array('BASE' => $appOptions['BASE'], 'DOMAIN' => $appOptions['DEV_DOMAIN'], 'ENVIRONMENT' => $appOptions['ENVIRONMENT'], 'LOG_ERRORS' => $appOptions['LOG_ERRORS'], 'REG_KEY_EXPIRE_TIME' => $appOptions['REG_KEY_EXPIRE_TIME'], 'SESSION_KEY_EXPIRE_TIME' => $appOptions['SESSION_KEY_EXPIRE_TIME'], 'EMAIL_FROM' => $appOptions['EMAIL_FROM'], 'PRINT_APP_INFO_ON_LOAD' => $appOptions['PRINT_APP_INFO_ON_LOAD']); $this->data = $this->getDataFromUrl($_SERVER["REQUEST_URI"]); $url_array = explode('?', $_SERVER["REQUEST_URI"]); $this->url = $url_array[0]; $this->routes = \Walleye\Config::getRoutes(); if (isset($this->appOptions['BASE'])) { self::$server_base_dir = $this->appOptions['BASE']; } if (isset($this->appOptions['DOMAIN'])) { self::$domain = $this->appOptions['DOMAIN']; } } else { self::$environment = Config::TESTING; $this->appOptions = array('BASE' => $appOptions['BASE'], 'ENVIRONMENT' => $appOptions['ENVIRONMENT'], 'LOG_ERRORS' => $appOptions['LOG_ERRORS'], 'REG_KEY_EXPIRE_TIME' => $appOptions['REG_KEY_EXPIRE_TIME'], 'SESSION_KEY_EXPIRE_TIME' => $appOptions['SESSION_KEY_EXPIRE_TIME'], 'EMAIL_FROM' => $appOptions['EMAIL_FROM'], 'PRINT_APP_INFO_ON_LOAD' => $appOptions['PRINT_APP_INFO_ON_LOAD']); $this->dbOptions = array('ENGINE' => $dbOptions['TEST_ENGINE'], 'SERVER' => $dbOptions['TEST_SERVER'], 'USER' => $dbOptions['TEST_USER'], 'PASS' => $dbOptions['TEST_PASS'], 'DATABASE' => $dbOptions['TEST_DATABASE'], 'PORT' => $dbOptions['TEST_PORT']); $this->routes = \Walleye\Config::getRoutes(); if (isset($this->appOptions['BASE'])) { self::$server_base_dir = $this->appOptions['BASE']; } } } }