From f89aee37f5e7a8d93876e6ce6c22b3f263967d76 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 29 Jan 2015 05:11:00 +0100 Subject: [PATCH] Fixed a bug where the referer might not be picked up correctly. --- app/controllers/HomeController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 64169899b9..f0d6c35651 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -90,9 +90,16 @@ class HomeController extends BaseController public function sessionNext() { Navigation::next(); - if (isset($_SERVER['HTTP_REFERER']) && (!strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')) === false)) { + $strPosition = strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')); + Log::debug('HTTP_REFERER is: ' . $_SERVER['HTTP_REFERER']); + Log::debug('App.url = ' . Config::get('app.url')); + Log::debug('strpos() = ' . Steam::boolString($strPosition)); + + if (isset($_SERVER['HTTP_REFERER']) && $strPosition === 0) { + Log::debug('Redirect back'); return Redirect::back(); } else { + Log::debug('Redirect intended'); return Redirect::intended(); } @@ -104,10 +111,17 @@ class HomeController extends BaseController public function sessionPrev() { Navigation::prev(); + $strPosition = strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')); + Log::debug('HTTP_REFERER is: ' . $_SERVER['HTTP_REFERER']); + Log::debug('App.url = ' . Config::get('app.url')); + Log::debug('strpos() = ' . Steam::boolString($strPosition)); - if (isset($_SERVER['HTTP_REFERER']) && (!strpos($_SERVER['HTTP_REFERER'], Config::get('app.url')) === false)) { + + if (isset($_SERVER['HTTP_REFERER']) && $strPosition === 0) { + Log::debug('Redirect back'); return Redirect::back(); } else { + Log::debug('Redirect intended'); return Redirect::intended(); } }