mirror of
https://github.com/SophiaAtkinson/steamwidgets-web.git
synced 2025-06-27 08:07:41 -07:00
Do only track hostname
This commit is contained in:
@ -47,7 +47,7 @@ class HitsModel extends \Asatru\Database\Model
|
|||||||
static::validateHitType($type);
|
static::validateHitType($type);
|
||||||
|
|
||||||
$token = md5($_SERVER['REMOTE_ADDR']);
|
$token = md5($_SERVER['REMOTE_ADDR']);
|
||||||
$referrer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
|
$referrer = (isset($_SERVER['HTTP_REFERER']) ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) : '');
|
||||||
|
|
||||||
HitsModel::raw('INSERT INTO `' . self::tableName() . '` (hash_token, hittype, referrer, created_at) VALUES(?, ?, ?, CURRENT_TIMESTAMP)', [
|
HitsModel::raw('INSERT INTO `' . self::tableName() . '` (hash_token, hittype, referrer, created_at) VALUES(?, ?, ?, CURRENT_TIMESTAMP)', [
|
||||||
$token,
|
$token,
|
||||||
@ -100,9 +100,8 @@ class HitsModel extends \Asatru\Database\Model
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$furl = parse_url($item->get('referrer'), PHP_URL_HOST);
|
if (!static::referrer_exists($item->get('referrer'), $result)) {
|
||||||
if (!in_array($furl, $result)) {
|
$entry['ref'] = $item->get('referrer');
|
||||||
$entry['ref'] = $furl;
|
|
||||||
$entry['count'] = $item->get('count');
|
$entry['count'] = $item->get('count');
|
||||||
$result[] = $entry;
|
$result[] = $entry;
|
||||||
}
|
}
|
||||||
@ -114,6 +113,24 @@ class HitsModel extends \Asatru\Database\Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if referrer has already been added to the array
|
||||||
|
*
|
||||||
|
* @param $needle
|
||||||
|
* @param $haystack
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function referrer_exists($needle, $haystack)
|
||||||
|
{
|
||||||
|
foreach ($haystack as $item) {
|
||||||
|
if ((isset($item['ref']) && ($item['ref'] === $needle))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get initial start date
|
* Get initial start date
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user