From bad5a1c3f24d8e73388697d096ae1e5cac4fe255 Mon Sep 17 00:00:00 2001 From: krasi georgiev Date: Sun, 30 Oct 2016 18:25:10 +0000 Subject: [PATCH] better GET params handling when the server is badly configured and missing the globel params --- bl-kernel/boot/rules/70.posts.php | 2 +- bl-kernel/url.class.php | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bl-kernel/boot/rules/70.posts.php b/bl-kernel/boot/rules/70.posts.php index d446f4da..67f8135c 100644 --- a/bl-kernel/boot/rules/70.posts.php +++ b/bl-kernel/boot/rules/70.posts.php @@ -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 diff --git a/bl-kernel/url.class.php b/bl-kernel/url.class.php index daf55f26..56525fe4 100644 --- a/bl-kernel/url.class.php +++ b/bl-kernel/url.class.php @@ -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; }