Always detect requested URL from REQUEST_URI
It's permit to access raw URL parameter values without automatic urldecode when access using $_GET or $_REQUEST. Also add UrlRequest::get_param() method that allow to access raw parameters values (without any decoding).
This commit is contained in:
parent
a120571e62
commit
6d8abbf391
2 changed files with 18 additions and 12 deletions
|
@ -174,17 +174,6 @@ function url_match($pattern, $current_url=false, $methods=null) {
|
||||||
* @retval string|false The current request URL or false if fail
|
* @retval string|false The current request URL or false if fail
|
||||||
**/
|
**/
|
||||||
function get_current_url() {
|
function get_current_url() {
|
||||||
if (isset($_REQUEST['go']))
|
|
||||||
return $_REQUEST['go'];
|
|
||||||
return detect_current_url();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to detect current requested URL and return it
|
|
||||||
*
|
|
||||||
* @retval string|false The current request URL or false if detection fail
|
|
||||||
**/
|
|
||||||
function detect_current_url() {
|
|
||||||
logging('DEBUG', "URL : request URI = '".$_SERVER['REQUEST_URI']."'");
|
logging('DEBUG', "URL : request URI = '".$_SERVER['REQUEST_URI']."'");
|
||||||
|
|
||||||
$base = get_rewrite_base();
|
$base = get_rewrite_base();
|
||||||
|
@ -460,6 +449,23 @@ class UrlRequest {
|
||||||
return array_key_exists($key, $this->url_params);
|
return array_key_exists($key, $this->url_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get request parameter
|
||||||
|
*
|
||||||
|
* @param[in] $parameter string The name of the parameter
|
||||||
|
* @param[in] $decode string If true, the parameter value will be urldecoded (optional, default: true)
|
||||||
|
*
|
||||||
|
* @retval mixed The value or false if parameter does not exists
|
||||||
|
**/
|
||||||
|
public function get_param($parameter, $decode=true) {
|
||||||
|
if (array_key_exists($parameter, $this->url_params)) {
|
||||||
|
if ($decode)
|
||||||
|
return urldecode($this->url_params[$parameter]);
|
||||||
|
return $this->url_params[$parameter];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get request referer (if known)
|
* Get request referer (if known)
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,4 +5,4 @@ RewriteBase /eesyphp
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
# If the request is not for a valid link
|
# If the request is not for a valid link
|
||||||
RewriteCond %{REQUEST_FILENAME} !-l
|
RewriteCond %{REQUEST_FILENAME} !-l
|
||||||
RewriteRule ^(.*)$ index.php?go=$1 [L,QSA]
|
RewriteRule ^ index.php [L]
|
||||||
|
|
Loading…
Reference in a new issue