[-] CORE : Report of https://github.com/PrestaShop/PrestaShop-1.4/commit/a6e8a2eda7fe3bab5245df9b98df7b2f6f7d541f
This commit is contained in:
committed by
Francois Gaillard
parent
fce9a0e285
commit
f8359173be
@@ -61,38 +61,39 @@ class ConnectionsSourceCore extends ObjectModel
|
|||||||
$cookie = Context::getContext()->cookie;
|
$cookie = Context::getContext()->cookie;
|
||||||
if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections))
|
if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// If the referrer is not correct, we drop the connection
|
||||||
|
if (isset($_SERVER['HTTP_REFERER']) && !Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER']))
|
||||||
|
return false;
|
||||||
|
// If there is no referrer and we do not want to save direct traffic (as opposed to referral traffic), we drop the connection
|
||||||
if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC'))
|
if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC'))
|
||||||
return false;
|
return false;
|
||||||
if(Configuration::get('TRACKING_DIRECT_TRAFFIC'))
|
|
||||||
{
|
$source = new ConnectionsSource();
|
||||||
$source = new ConnectionsSource();
|
|
||||||
if (isset($_SERVER['HTTP_REFERER']) && Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER']))
|
// There are a few more operations if there is a referrer
|
||||||
{
|
if (isset($_SERVER['HTTP_REFERER']))
|
||||||
$parsed = parse_url($_SERVER['HTTP_REFERER']);
|
{
|
||||||
$parsed_host = parse_url(Tools::getProtocol().Tools::getHttpHost(false, false).__PS_BASE_URI__);
|
// If the referrer is internal (i.e. from your own website), then we drop the connection
|
||||||
if ((!isset($parsed['path']) ||!isset($parsed_host['path'])) || (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)))
|
$parsed = parse_url($_SERVER['HTTP_REFERER']);
|
||||||
&& !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__)))
|
$parsed_host = parse_url(Tools::getProtocol().Tools::getHttpHost(false, false).__PS_BASE_URI__);
|
||||||
return false;
|
if ((!isset($parsed['path']) ||!isset($parsed_host['path'])) || (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false))) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__)))
|
||||||
if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER'])))
|
return false;
|
||||||
{
|
|
||||||
$source->http_referer = substr(strval($_SERVER['HTTP_REFERER']), 0, ConnectionsSource::$uri_max_size);
|
$source->http_referer = substr($_SERVER['HTTP_REFERER'], 0, ConnectionsSource::$uri_max_size);
|
||||||
$source->keywords = substr(trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER']))), 0, ConnectionsSource::$uri_max_size);
|
$source->keywords = substr(trim(SearchEngine::getKeywords($_SERVER['HTTP_REFERER'])), 0, ConnectionsSource::$uri_max_size);
|
||||||
if (!Validate::isMessage($source->keywords))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$source->id_connections = (int)$cookie->id_connections;
|
|
||||||
$source->request_uri = Tools::getHttpHost(false, false);
|
|
||||||
if (isset($_SERVER['REDIRECT_URL']))
|
|
||||||
$source->request_uri .= strval($_SERVER['REDIRECT_URL']);
|
|
||||||
elseif (isset($_SERVER['REQUEST_URI']))
|
|
||||||
$source->request_uri .= strval($_SERVER['REQUEST_URI']);
|
|
||||||
if (!Validate::isUrl($source->request_uri))
|
|
||||||
$source->request_uri = '';
|
|
||||||
$source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
|
|
||||||
return $source->add();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$source->id_connections = (int)$cookie->id_connections;
|
||||||
|
$source->request_uri = Tools::getHttpHost(false, false);
|
||||||
|
if (isset($_SERVER['REDIRECT_URL']))
|
||||||
|
$source->request_uri .= $_SERVER['REDIRECT_URL'];
|
||||||
|
elseif (isset($_SERVER['REQUEST_URI']))
|
||||||
|
$source->request_uri .= $_SERVER['REQUEST_URI'];
|
||||||
|
if (!Validate::isUrl($source->request_uri))
|
||||||
|
$source->request_uri = '';
|
||||||
|
$source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
|
||||||
|
return $source->add();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOrderSources($id_order)
|
public static function getOrderSources($id_order)
|
||||||
@@ -106,4 +107,4 @@ class ConnectionsSourceCore extends ObjectModel
|
|||||||
WHERE id_order = '.(int)($id_order).'
|
WHERE id_order = '.(int)($id_order).'
|
||||||
ORDER BY cos.date_add DESC');
|
ORDER BY cos.date_add DESC');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,8 @@ class SearchEngineCore extends ObjectModel
|
|||||||
if (empty($array[0]))
|
if (empty($array[0]))
|
||||||
return false;
|
return false;
|
||||||
$str = urldecode(str_replace('+', ' ', ltrim(substr(rtrim($array[0], '&'), strlen($varname) + 1), '=')));
|
$str = urldecode(str_replace('+', ' ', ltrim(substr(rtrim($array[0], '&'), strlen($varname) + 1), '=')));
|
||||||
|
if (!Validate::isMessage($str))
|
||||||
|
return false;
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user