From 96481892cf693fa33d5f14a3ec6beaed26bd4485 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 15 Mar 2017 17:01:02 +0100 Subject: * bumping Prado version to 3.3.2-r5dd4b52 --- lib/prado/HISTORY | 5 +++++ lib/prado/framework/Web/THttpRequest.php | 10 ++++++++- lib/prado/framework/Web/THttpResponse.php | 18 +++++++++++++++-- lib/prado/framework/Web/UI/TTemplateManager.php | 4 ++-- lib/prado/framework/pradolite.php | 27 ++++++++++++++++++++----- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/lib/prado/HISTORY b/lib/prado/HISTORY index 2a17246..80b5781 100644 --- a/lib/prado/HISTORY +++ b/lib/prado/HISTORY @@ -1,3 +1,8 @@ +Version 3.3.X in development + +BUG: Issue #625 - The url tag produce an extra directory separator before the result (ctrlaltca) +BUG: Issue #610 - IIS: Page redirect dosn't work (ctrlaltca) + Version 3.3.2 August 23, 2016 BUG: Issue #592 - Fix TActiveMultiView broken on 3.3.1 (ctrlaltca) diff --git a/lib/prado/framework/Web/THttpRequest.php b/lib/prado/framework/Web/THttpRequest.php index 926cfa4..724c641 100644 --- a/lib/prado/framework/Web/THttpRequest.php +++ b/lib/prado/framework/Web/THttpRequest.php @@ -533,6 +533,15 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null; } + /** + * @return string server software + * @since 3.3.3 + */ + public function getServerSoftware() + { + return isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:null; + } + /** * @return integer server port number */ @@ -1403,4 +1412,3 @@ class THttpRequestUrlFormat extends TEnumerable const Path='Path'; const HiddenPath='HiddenPath'; } - diff --git a/lib/prado/framework/Web/THttpResponse.php b/lib/prado/framework/Web/THttpResponse.php index 93d3c91..48328c3 100644 --- a/lib/prado/framework/Web/THttpResponse.php +++ b/lib/prado/framework/Web/THttpResponse.php @@ -426,13 +426,28 @@ class THttpResponse extends TModule implements ITextWriter { $this->ensureHeadersSent(); + // Under IIS, explicitly send an HTTP response including the status code + // this is handled automatically by PHP on Apache and others + $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); if($url[0]==='/') $url=$this->getRequest()->getBaseUrl().$url; if ($this->_status >= 300 && $this->_status < 400) + { // The status code has been modified to a valid redirection status, send it + if($isIIS) + { + header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ + array_key_exists($this->_status, self::$HTTP_STATUS_CODES) + ? $this->_status + : 302 + ]); + } header('Location: '.str_replace('&','&',$url), true, $this->_status); - else + } else { + if($isIIS) + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); header('Location: '.str_replace('&','&',$url)); + } if(!$this->getApplication()->getRequestCompleted()) $this->getApplication()->onEndRequest(); @@ -719,4 +734,3 @@ class THttpResponse extends TModule implements ITextWriter return Prado::createComponent($type, $writer); } } - diff --git a/lib/prado/framework/Web/UI/TTemplateManager.php b/lib/prado/framework/Web/UI/TTemplateManager.php index b6eddab..c25e668 100644 --- a/lib/prado/framework/Web/UI/TTemplateManager.php +++ b/lib/prado/framework/Web/UI/TTemplateManager.php @@ -662,7 +662,7 @@ class TTemplate extends TApplicationComponent implements ITemplate else if($str[2]==='~') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); else if($str[2]==='/') - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'")); + $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); else if($str[2]==='[') { $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); @@ -901,7 +901,7 @@ class TTemplate extends TApplicationComponent implements ITemplate return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); elseif($value[2]==='/') { $literal = trim(substr($value,3,strlen($value)-5)); - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); + return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); } } else diff --git a/lib/prado/framework/pradolite.php b/lib/prado/framework/pradolite.php index 2c12c05..37f93ec 100644 --- a/lib/prado/framework/pradolite.php +++ b/lib/prado/framework/pradolite.php @@ -1,7 +1,7 @@ ensureHeadersSent(); + $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); if($url[0]==='/') $url=$this->getRequest()->getBaseUrl().$url; if ($this->_status >= 300 && $this->_status < 400) - header('Location: '.str_replace('&','&',$url), true, $this->_status); - else + { + if($isIIS) + { + header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ + array_key_exists($this->_status, self::$HTTP_STATUS_CODES) + ? $this->_status + : 302 + ]); + } + header('Location: '.str_replace('&','&',$url), true, $this->_status); + } else { + if($isIIS) + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); header('Location: '.str_replace('&','&',$url)); + } if(!$this->getApplication()->getRequestCompleted()) $this->getApplication()->onEndRequest(); exit(); @@ -8854,7 +8871,7 @@ class TTemplate extends TApplicationComponent implements ITemplate else if($str[2]==='~') $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); else if($str[2]==='/') - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'")); + $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); else if($str[2]==='[') { $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); @@ -9071,7 +9088,7 @@ class TTemplate extends TApplicationComponent implements ITemplate return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); elseif($value[2]==='/') { $literal = trim(substr($value,3,strlen($value)-5)); - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); + return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); } } else -- cgit v1.2.3