/** * Class constructor * * @return void */ public function __construct() { $this->config = Config::get('routing'); // Determine the base_url if (empty(Config::get('main')->base_url)) { if (isset($_SERVER['SERVER_ADDR'])) { if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) { $server_addr = '[' . $_SERVER['SERVER_ADDR'] . ']'; } else { $server_addr = $_SERVER['SERVER_ADDR']; } $base_url = (Core::isHttps() ? 'https' : 'http') . '://' . $server_addr . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); } else { $base_url = 'http://localhost/'; } Config::get('main')->base_url = $base_url; } // If query strings are enabled, we don't need to parse any segments. // However, they don't make sense under CLI. if (Core::isCli() or $this->config->enable_query_strings !== TRUE) { $this->_permitted_uri_chars = $this->config->permitted_uri_chars; // If it's a CLI request, ignore the configuration if (Core::isCli()) { $uri = $this->_parse_argv(); } else { $protocol = $this->config->uri_protocol; empty($protocol) && ($protocol = 'REQUEST_URI'); switch ($protocol) { case 'AUTO': // For BC purposes only // For BC purposes only case 'REQUEST_URI': $uri = $this->_parse_request_uri(); break; case 'QUERY_STRING': $uri = $this->_parse_query_string(); break; case 'PATH_INFO': default: $uri = isset($_SERVER[$protocol]) ? $_SERVER[$protocol] : $this->_parse_request_uri(); break; } } $this->_set_uri_string($uri); } }