/** * Determines the requested URL. * * @return string * @access private */ public static function requestUri() { // Check ff this is the first time getting the request uri if (static::$requestUri === null) { $baseMikePath = "/" . static::$this_file; // Check if there is a PATH_INFO variable // Note: some servers seem to have trouble with getenv() $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); if (trim($path, '/') != '' && $path != $baseMikePath) { return static::$requestUri = $path; } // Check if ORIG_PATH_INFO exists $path = str_replace($_SERVER['SCRIPT_NAME'], '', isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO')); if (trim($path, '/') != '' && $path != $baseMikePath) { return static::$requestUri = $path; } // Check for ?uri=x/y/z if (isset($_REQUEST['url'])) { return static::$requestUri = $_REQUEST['url']; } // Check the _GET variable if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') { return static::$requestUri = key($_GET); } // Check for QUERY_STRING $path = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); if (trim($path, '/') != '') { return static::$requestUri = $path; } // Check for requestUri $path = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']); if (trim($path, '/') != '' && $path != $baseMikePath) { return static::$requestUri = str_replace(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']), '', $path); } // I dont know what else to try, leave it... return static::$requestUri = ''; } return static::$requestUri; }
/** * @return string */ public static function requestUri() { if (!static::$requestUri) { static::$requestUri = static::prepareRequestUri(); } return static::$requestUri; }
/** * Sets up the request. */ public static function init() { static::$query = new ParameterBag($_GET); static::$post = new ParameterBag($_POST); static::$properties = new ParameterBag(); static::$server = new ParameterBag($_SERVER); static::$headers = static::buildHeaderBag(); static::$method = isset($_POST['_method']) ? $_POST['_method'] : $_SERVER['REQUEST_METHOD']; static::$requestUri = $_SERVER['REQUEST_URI']; static::$scriptName = $_SERVER['SCRIPT_NAME']; static::$basePath = rtrim(str_replace(basename(static::$scriptName), '', static::$scriptName), '/'); static::$pathInfo = str_replace(static::$scriptName, '', static::$requestUri); static::$pathInfo = static::preparePathInfo(); static::$segments = explode('/', trim(static::$pathInfo, '/')); }
public function __construct() { static::$instance = $this; static::$request = $_REQUEST; static::$get = $_GET; static::$post = $_POST; static::$server = $_SERVER; static::$headers = static::getAllHeaders(); static::$requestUri = static::prepareRequestUri(); static::$baseUrl = static::prepareBaseUrl(); static::$basePath = static::prepareBasePath(); static::$pathInfo = static::preparePathInfo(); static::$method = static::$server['REQUEST_METHOD']; }
/** * Get the full Request URI path array * * I.e. "/foo/bar" would result in the following array: ["foo", "bar"] * * @since 0.1.0 * @access public * @return array The full URI path array * @static */ public static function getRequestUri() { if (static::$requestUri === null) { $Uri = Gdn::request()->requestUri(); static::$requestUri = explode("/", strtolower($Uri)); } return static::$requestUri; }