Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/atk14/atk14_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
65 changes: 34 additions & 31 deletions src/atk14/atk14_dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;$i<strlen($uri);$i++){
if($uri[$i]==$route_ar["force_redirect"][$i]){ continue; }
if($uri[$i]=="." && $route_ar["force_redirect"][$i]=="_"){ continue; }
$_meaningful_redirect = true;
break;
if($route_ar["force_redirect"] !== null) {
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;$i<strlen($uri);$i++){
if($uri[$i]==$route_ar["force_redirect"][$i]){ continue; }
if($uri[$i]=="." && $route_ar["force_redirect"][$i]=="_"){ continue; }
$_meaningful_redirect = true;
break;
}
if(!$_meaningful_redirect){ $route_ar["force_redirect"] = null; }
}
if(!$_meaningful_redirect){ $route_ar["force_redirect"] = null; }
}

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));
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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/atk14/atk14_global.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/atk14/atk14_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/atk14/atk14_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/dbmole/pgmole.php
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/http/httprequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/http/httpresponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
5 changes: 4 additions & 1 deletion src/miniyaml/miniyaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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;
Expand Down