better GET params handling when the server is badly configured and missing the globel params

This commit is contained in:
krasi georgiev 2016-10-30 18:25:10 +00:00
parent bdd90a680d
commit bad5a1c3f2
2 changed files with 12 additions and 6 deletions

View File

@ -51,7 +51,7 @@ if( ($Url->whereAmI()==='post') && ($Url->notFound()===false) )
// Build posts by specific tag.
elseif( ($Url->whereAmI()==='tag') && ($Url->notFound()===false) )
{
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
}
// Build posts for homepage or admin area.
else

View File

@ -18,11 +18,17 @@ class Url
// remove parameters GET, do not use parse_url because has problem with utf-8.
$explode = explode('?', $decode);
$this->uri = $explode[0];
$this->uri = $explode[0];
$this->parameters = $_GET;
// deal with server config when missing the get params
if(empty($_GET)){
isset($explode[1]) ? parse_str($explode[1], $this->parameters):"";
}
else{
$this->parameters=$_GET;
}
$this->uriStrlen = Text::length($this->uri);
$this->uriStrlen = Text::length($this->uri);
$this->whereAmI = 'home';
@ -142,7 +148,7 @@ class Url
public function pageNumber()
{
if(isset($this->parameters['page'])) {
if(isset($this->parameters['page'])) {
return $this->parameters['page'];
}
return 0;
@ -170,7 +176,7 @@ class Url
// Check if the filter is in the uri.
$position = Text::stringPosition($this->uri, $filter);
// If the position is FALSE, the filter isn't in the URI.
// If the position is FALSE, the filter isn't in the URI.
if($position===false) {
return false;
}