diff options
author | ctrlaltca@gmail.com <> | 2011-06-20 10:48:45 +0000 |
---|---|---|
committer | ctrlaltca@gmail.com <> | 2011-06-20 10:48:45 +0000 |
commit | 656c339879a071f2f875831281ed833b876e4361 (patch) | |
tree | b6f11d3ad8cb1f61b10b4e3b9fcb0a7d4d30f9e1 /framework/Web/THttpRequest.php | |
parent | 0956370d34e2eefd0b5e556a6aaca6297ce1e3ce (diff) |
removed useless calls to empty contructor; reverted some additional undocumented changes; upported the "cgi workaround" to trunk/; large (fake) changeset are due to mixed cr/crlf used previously
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r-- | framework/Web/THttpRequest.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 925160c8..c16b07a8 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -70,6 +70,8 @@ Prado::using('System.Web.TUrlManager'); */ class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule { + const CGIFIX__PATH_INFO = 1; + const CGIFIX__SCRIPT_NAME = 2; /** * @var TUrlManager the URL manager module */ @@ -110,6 +112,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar private $_services; private $_requestResolved=false; private $_enableCookieValidation=false; + private $_cgiFix=0; /** * @var string request URL */ @@ -183,7 +186,9 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar else // TBD: in this case, SCRIPT_NAME need to be escaped $this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']); - if(isset($_SERVER['PATH_INFO'])) + if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) + $this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME'])); + elseif(isset($_SERVER['PATH_INFO'])) $this->_pathInfo=$_SERVER['PATH_INFO']; else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) $this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])); @@ -394,6 +399,9 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ public function getApplicationUrl() { + if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) + return $_SERVER['ORIG_SCRIPT_NAME']; + return $_SERVER['SCRIPT_NAME']; } @@ -519,6 +527,26 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar } /** + * @return integer whether to use ORIG_PATH_INFO and/or ORIG_SCRIPT_NAME. Defaults to 0. + * @see THttpRequest::CGIFIX__PATH_INFO, THttpRequest::CGIFIX__SCRIPT_NAME + */ + public function getCgiFix() + { + return $this->_cgiFix; + } + + /** + * Enable this, if you're using PHP via CGI with php.ini setting "cgi.fix_pathinfo=1" + * and have trouble with friendly URL feature. Enable this only if you really know what you are doing! + * @param integer enable bitwise to use ORIG_PATH_INFO and/or ORIG_SCRIPT_NAME. + * @see THttpRequest::CGIFIX__PATH_INFO, THttpRequest::CGIFIX__SCRIPT_NAME + */ + public function setCgiFix($value) + { + $this->_cgiFix=TPropertyValue::ensureInteger($value); + } + + /** * @return THttpCookieCollection list of cookies to be sent */ public function getCookies() @@ -857,7 +885,6 @@ class THttpCookieCollection extends TList public function __construct($owner=null) { $this->_o=$owner; - parent::__construct(); } /** |