From 9e09cf836e6c332310897f3c11610a4aabd18d93 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 24 Jan 2019 11:36:14 -0800 Subject: [PATCH] Fixes #3546 Social network trackers now ignored during THEME_LAYOUT detection. --- e107_handlers/application.php | 42 ++++++++++++++++++------------ e107_handlers/theme_handler.php | 25 ++++++++++++++++++ e107_plugins/tinymce4/e_header.php | 2 +- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 654dada4a..5c8a5c3e4 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -1028,7 +1028,7 @@ class eRouter */ public $notFoundUrl = 'system/error/404?type=routeError'; - protected $_trackers = array('fbclid','utm_source','utm_medium','utm_content','utm_campaign'); + public function __construct() @@ -1090,11 +1090,6 @@ class eRouter } - public function getTrackers() - { - return $this->_trackers; - } - /** * Load config and url rules, if not available - build it on the fly * @return eRouter @@ -1805,16 +1800,7 @@ class eRouter // Ignore social trackers when determining route. - $get = $_GET; - $trackers = $this->getTrackers(); - - foreach($trackers as $val) - { - if(isset($get[$val])) - { - unset($get[$val]); - } - } + $get = eHelper::removeTrackers($_GET); // Route to front page - index/index/index route if(!$rawPathInfo && (!$this->getMainModule() || empty($get))) @@ -4949,4 +4935,28 @@ class eHelper return array(1 => $multi, 2 => $params, 3 => $parmstr); } + + + /** + * Remove Social Media Trackers from a $_GET array based on key matches. + * @param array $get + * @return array + */ + public static function removeTrackers($get = array()) + { + $trackers = array('fbclid','utm_source','utm_medium','utm_content','utm_campaign'); + + foreach($trackers as $val) + { + if(isset($get[$val])) + { + unset($get[$val]); + } + } + + return $get; + + } + + } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 7dbf637dc..aaece00af 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -279,6 +279,29 @@ class e_theme return isset($this->_data[$this->_current][$var]) ? $this->_data[$this->_current][$var] : false; } + /** + * Rebuild URL without trackers, for matching against theme_layout prefs. + * @param string $url + * @return string + */ + private function filterTrackers($url) + { + if(strpos($url,'?') === false || empty($url)) + { + return $url; + } + + list($site,$query) = explode('?',$url); + + parse_str($query,$get); + + $get = eHelper::removeTrackers($get); + + $ret = empty($get) ? $site : $site.'?'.http_build_query($get); + + return $ret; + } + /** * Calculate THEME_LAYOUT constant based on theme preferences and current URL. @@ -306,6 +329,8 @@ class e_theme // FIX - check against urldecoded strings $c_url = rtrim(rawurldecode($c_url), '?'); + $c_url = $this->filterTrackers($c_url); + foreach($cusPagePref as $lyout=>$cusPageArray) { if(!is_array($cusPageArray)) { continue; } diff --git a/e107_plugins/tinymce4/e_header.php b/e107_plugins/tinymce4/e_header.php index 42ab8f9da..ee965bf54 100644 --- a/e107_plugins/tinymce4/e_header.php +++ b/e107_plugins/tinymce4/e_header.php @@ -20,4 +20,4 @@ e107::css('inline',' '); -?> +