summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2010-02-22 08:56:54 +0000
committergodzilla80@gmx.net <>2010-02-22 08:56:54 +0000
commitf010032dde58e31afee0677d66b579b64a9b766a (patch)
treeba9ca539c78a8687244d1756a6b7a65a88cdf297
parent17a29ce7e90fb28c9606342a803a7a5b7f3e16f3 (diff)
Fixed Issues#113/195, but i decide to enable it manualy using the new introduced "CgiFix" property.
Since i'm not able to reproduce the problem and for example in my tests 'ORIG_SCRIPT_NAME' contains '/php/php-cgi.exe' <module id="request" class="System.Web.THttpRequest" CgiFix="1" UrlManager="friendlyurl-manager" UrlFormat="Get"/> Use 'ORIG_PATH_INFO' CgiFix="1" Return 'ORIG_SCRIPT_NAME' in getApplicationUrl() CgiFix="2" Or to enable both: CgiFix="3"
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/THttpRequest.php32
2 files changed, 31 insertions, 2 deletions
diff --git a/HISTORY b/HISTORY
index 8a05a294..3cad212c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3,6 +3,7 @@ ENH: Issue#24 - Specify needed fields on demand (Yves)
BUG: Issue#80 - Inconsistencies in TRegularExpressionValidator (Christophe)
BUG: Issue#86 - THttpSession.CookieMode ignored / Session ID leak (Christophe)
BUG: Issue#94 - DataGrid header/footer renderers unable to locate their parent grid in setData() method (Christophe)
+BUG: Issue#113/195 - THttpRequest -> getPathInfo doesn't work on servers when cgi.fix_pathinfo=1 (Yves)
BUG: Issue#151 - TTextBox fails to display inital line break (Yves)
BUG: Issue#153 - Bug with calls like MyActiveRedorc->withText()->withUser()->find(...) and null result (Christophe)
BUG: Issue#157 - Enabled does not work properly on TActiveRadioButton/CheckBoxList controls (Bradley, Carl)
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index c3926d08..74bd8ef3 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']));
@@ -349,7 +354,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
{
return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:'';
}
-
+
/**
* @return string part of that request URL after the host info (including pathinfo and query string)
*/
@@ -376,6 +381,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'];
}
@@ -498,6 +506,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()