diff --git a/src/atk14/atk14_controller.php b/src/atk14/atk14_controller.php index ef806f8e..72dcb7ac 100644 --- a/src/atk14/atk14_controller.php +++ b/src/atk14/atk14_controller.php @@ -590,7 +590,7 @@ function _execute_action($action,$options = array()){ $this->action_executed = true; - if(strlen($this->response->getLocation())>0){ + if(strlen((string) $this->response->getLocation())>0){ return; } diff --git a/src/atk14/atk14_dispatcher.php b/src/atk14/atk14_dispatcher.php index fb79a0f2..6b3e39d5 100644 --- a/src/atk14/atk14_dispatcher.php +++ b/src/atk14/atk14_dispatcher.php @@ -105,39 +105,41 @@ static function Dispatch($options = array()){ $_GET = array_merge($_GET,$route_ar["get_params"]); Atk14Timer::Stop("Atk14Url::RecognizeRoute"); - if(strlen($uri)==strlen($route_ar["force_redirect"])){ - // Here solving PHP's dot to underscore conversion. - // If the uri contains a parametr with dot in it's name, PHP silently converts it to underscore. - // Thus such URL: - // http://www.myapp.com/en/books/detail/?id=1&in.format=xml - // should not be redirected to - // http://www.myapp.com/en/books/detail/?id=1&in_format=xml - $_meaningful_redirect = false; - for($i=0;$iget() && strlen($route_ar["force_redirect"])>0 && !$request->xhr()){ - $HTTP_RESPONSE->setLocation($route_ar["force_redirect"],array("moved_permanently" => true)); - $options["display_response"] && $HTTP_RESPONSE->flushAll(); - - $ctrl = null; - if($options["return_controller"]){ - $ctrl = Atk14Dispatcher::ExecuteAction($route_ar["controller"],$route_ar["action"],array( - "page_title" => $route_ar["page_title"], - "page_description" => $route_ar["page_description"], - "return_controller" => true, - "request" => $request - )); - $ctrl->response->setLocation($route_ar["force_redirect"],array("moved_permanently" => true)); + if($request->get() && strlen($route_ar["force_redirect"])>0 && !$request->xhr()){ + $HTTP_RESPONSE->setLocation($route_ar["force_redirect"],array("moved_permanently" => true)); + $options["display_response"] && $HTTP_RESPONSE->flushAll(); + + $ctrl = null; + if($options["return_controller"]){ + $ctrl = Atk14Dispatcher::ExecuteAction($route_ar["controller"],$route_ar["action"],array( + "page_title" => $route_ar["page_title"], + "page_description" => $route_ar["page_description"], + "return_controller" => true, + "request" => $request + )); + $ctrl->response->setLocation($route_ar["force_redirect"],array("moved_permanently" => true)); + } + + return Atk14Dispatcher::_ReturnResponseOrController($HTTP_RESPONSE,$ctrl,$options); } - - return Atk14Dispatcher::_ReturnResponseOrController($HTTP_RESPONSE,$ctrl,$options); } // prestehovano Atk14Url::RecognizeRoute() @@ -154,7 +156,8 @@ static function Dispatch($options = array()){ )); // ajaxove presmerovani... - if(strlen($ctrl->response->getLocation())>0 && $request->xhr() && !preg_match('/^(text|application)\/(html|json|xml)/',$request->getHeader("Accept"))){ + $location = (string) $ctrl->response->getLocation(); + if(strlen($location)>0 && $request->xhr() && !preg_match('/^(text|application)\/(html|json|xml)/',$request->getHeader("Accept"))){ // tohle by snad melo byt vraceno pokud je v requestu // Accept: */* // Accept: text/javascript diff --git a/src/atk14/atk14_global.php b/src/atk14/atk14_global.php index bb6f4558..d3b879ca 100644 --- a/src/atk14/atk14_global.php +++ b/src/atk14/atk14_global.php @@ -582,7 +582,7 @@ function getPreparedRoutes($namespace = "",$options = array()){ // pokud se zajimeme o konkretni path, // prihodime nakonec i vychozi (nepojmenovane) routy - if(strlen($path = $options["path"])){ + if(strlen($path = (string) $options["path"])){ $out = array(); if(isset($ROUTES_BY_PATH[$namespace][$path])){ $out = $ROUTES_BY_PATH[$namespace][$path]; } foreach($ROUTES_WITH_NO_PATH[$namespace] as $k => $v){ diff --git a/src/atk14/atk14_url.php b/src/atk14/atk14_url.php index 6bac3366..fdd95120 100644 --- a/src/atk14/atk14_url.php +++ b/src/atk14/atk14_url.php @@ -440,7 +440,7 @@ static function BuildLink($params,$options = array(),$__current_ary__ = array()) $_namespace = ""; if(strlen($params["namespace"])>0){ $_namespace = "$params[namespace]/"; } $out = $ATK14_GLOBAL->getBaseHref().$_namespace.$out.Atk14Url::EncodeParams($get_params,array("connector" => $options["connector"])); - if(strlen($options["anchor"])>0){ $out .= "#$options[anchor]"; } + if(strlen((string) $options["anchor"])>0){ $out .= "#$options[anchor]"; } // Internally, the port 80 is treated as standard ssl port. // It's quite common that Apache is running on non-ssl port 80 and ssl is provided by Nginx in reverse proxy mode. diff --git a/src/atk14/atk14_utils.php b/src/atk14/atk14_utils.php index fab40467..96b71418 100644 --- a/src/atk14/atk14_utils.php +++ b/src/atk14/atk14_utils.php @@ -467,8 +467,9 @@ static function ErrorLog($message,&$response){ * @return boolean true - output produced, false - nothing produced */ static function ResponseProduced(&$controller){ + $location = $controller->response->getLocation(); return !( - strlen($controller->response->getLocation())==0 && + ($location === null || strlen($location)==0) && !$controller->action_executed && $controller->response->buffer->getLength()==0 && $controller->response->getStatusCode()==200 diff --git a/src/dbmole/pgmole.php b/src/dbmole/pgmole.php index de109211..df926df9 100644 --- a/src/dbmole/pgmole.php +++ b/src/dbmole/pgmole.php @@ -104,7 +104,7 @@ function _freeResult(&$result){ } function escapeString4Sql($s){ - return "'".pg_escape_string($s)."'"; + return "'".pg_escape_string($this->_getDbConnect(), $s)."'"; } function _runQuery($query){ diff --git a/src/functions.php b/src/functions.php index 01430d7b..765473b8 100644 --- a/src/functions.php +++ b/src/functions.php @@ -30,7 +30,7 @@ function h($string, $flags = null, $encoding = null){ // I think that the encoding ISO-8859-1 works well in UTF-8 applications $encoding = "ISO-8859-1"; } - return htmlspecialchars($string,$flags,$encoding); + return htmlspecialchars((string) $string,$flags,$encoding); } /** diff --git a/src/http/httprequest.php b/src/http/httprequest.php index 6d323a01..d1528cee 100644 --- a/src/http/httprequest.php +++ b/src/http/httprequest.php @@ -644,8 +644,9 @@ function xhr(){ if(isset($_SERVER["X_ORIGINAL_REQUEST_URI"]) && preg_match('/(&|\?)__xhr_request=1(|&.*)$/',$_SERVER["X_ORIGINAL_REQUEST_URI"])){ return true; } - - return strtolower($this->getHeader("X-Requested-With"))=="xmlhttprequest"; + + $xrequested=$this->getHeader("X-Requested-With"); + return $xrequested != null && strtolower($xrequested) == "xmlhttprequest"; } /** diff --git a/src/http/httpresponse.php b/src/http/httpresponse.php index 53fd1917..65b8272e 100644 --- a/src/http/httpresponse.php +++ b/src/http/httpresponse.php @@ -721,7 +721,7 @@ protected function _flushHeaders(){ if($this->_ContentCharset){ $_content_type_header .= "; charset=$this->_ContentCharset";} $this->_header($_content_type_header); - if(strlen($this->_Location)>0){ + if($this->_Location !== null && strlen($this->_Location)>0){ $this->_header("Location: $this->_Location"); } diff --git a/src/miniyaml/miniyaml.php b/src/miniyaml/miniyaml.php index 5fe3109f..aaed2ac7 100644 --- a/src/miniyaml/miniyaml.php +++ b/src/miniyaml/miniyaml.php @@ -183,6 +183,9 @@ function _load($yaml){ * @return int */ function _getIndent($line){ + if($line === null) { + return 0; + } preg_match("/^( *)/",$line,$matches); return strlen($matches[1]); } @@ -332,7 +335,7 @@ function _readHashArray($block,&$lines_read){ $key = $matches[1]; $_values = trim($matches[2]); $next_line_indent = $this->_getIndent($next_line); - if($next_line_indent>0 || preg_match("/^- /",$next_line)){ + if($next_line_indent>0 || preg_match("/^- /",(string) $next_line)){ $value_block = $this->_cutOutBlock_Stripped($i+1,$next_line_indent,$block); $value = $this->_readVar($value_block,$li); $i += $li;