mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 07:36:32 +02:00
Fixes #3546 Social network trackers now ignored during THEME_LAYOUT detection.
This commit is contained in:
@@ -1028,7 +1028,7 @@ class eRouter
|
|||||||
*/
|
*/
|
||||||
public $notFoundUrl = 'system/error/404?type=routeError';
|
public $notFoundUrl = 'system/error/404?type=routeError';
|
||||||
|
|
||||||
protected $_trackers = array('fbclid','utm_source','utm_medium','utm_content','utm_campaign');
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
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
|
* Load config and url rules, if not available - build it on the fly
|
||||||
* @return eRouter
|
* @return eRouter
|
||||||
@@ -1805,16 +1800,7 @@ class eRouter
|
|||||||
|
|
||||||
|
|
||||||
// Ignore social trackers when determining route.
|
// Ignore social trackers when determining route.
|
||||||
$get = $_GET;
|
$get = eHelper::removeTrackers($_GET);
|
||||||
$trackers = $this->getTrackers();
|
|
||||||
|
|
||||||
foreach($trackers as $val)
|
|
||||||
{
|
|
||||||
if(isset($get[$val]))
|
|
||||||
{
|
|
||||||
unset($get[$val]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route to front page - index/index/index route
|
// Route to front page - index/index/index route
|
||||||
if(!$rawPathInfo && (!$this->getMainModule() || empty($get)))
|
if(!$rawPathInfo && (!$this->getMainModule() || empty($get)))
|
||||||
@@ -4949,4 +4935,28 @@ class eHelper
|
|||||||
|
|
||||||
return array(1 => $multi, 2 => $params, 3 => $parmstr);
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -279,6 +279,29 @@ class e_theme
|
|||||||
return isset($this->_data[$this->_current][$var]) ? $this->_data[$this->_current][$var] : false;
|
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.
|
* Calculate THEME_LAYOUT constant based on theme preferences and current URL.
|
||||||
@@ -306,6 +329,8 @@ class e_theme
|
|||||||
// FIX - check against urldecoded strings
|
// FIX - check against urldecoded strings
|
||||||
$c_url = rtrim(rawurldecode($c_url), '?');
|
$c_url = rtrim(rawurldecode($c_url), '?');
|
||||||
|
|
||||||
|
$c_url = $this->filterTrackers($c_url);
|
||||||
|
|
||||||
foreach($cusPagePref as $lyout=>$cusPageArray)
|
foreach($cusPagePref as $lyout=>$cusPageArray)
|
||||||
{
|
{
|
||||||
if(!is_array($cusPageArray)) { continue; }
|
if(!is_array($cusPageArray)) { continue; }
|
||||||
|
@@ -20,4 +20,4 @@ e107::css('inline','
|
|||||||
');
|
');
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
Reference in New Issue
Block a user