mirror of
https://github.com/SophiaAtkinson/steamwidgets-web.git
synced 2025-06-28 03:17:41 -07:00
Filter assumed localhost addresses
This commit is contained in:
7
app/config/localhosts.php
Normal file
7
app/config/localhosts.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'localhost',
|
||||||
|
'127.0.0.1',
|
||||||
|
'0.0.0.0'
|
||||||
|
];
|
@ -101,6 +101,12 @@ class HitsModel extends \Asatru\Database\Model
|
|||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if (!static::referrer_exists($item->get('referrer'), $result)) {
|
if (!static::referrer_exists($item->get('referrer'), $result)) {
|
||||||
|
if (env('APP_STATSFILTERLOCAL', false)) {
|
||||||
|
if (static::assumed_localhost($item->get('referrer'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$entry['ref'] = $item->get('referrer');
|
$entry['ref'] = $item->get('referrer');
|
||||||
$entry['count'] = $item->get('count');
|
$entry['count'] = $item->get('count');
|
||||||
$result[] = $entry;
|
$result[] = $entry;
|
||||||
@ -131,6 +137,19 @@ class HitsModel extends \Asatru\Database\Model
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given referrer is a local address
|
||||||
|
*
|
||||||
|
* @param $referrer
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function assumed_localhost($referrer)
|
||||||
|
{
|
||||||
|
$localhosts = config('localhosts');
|
||||||
|
|
||||||
|
return in_array($referrer, $localhosts);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get initial start date
|
* Get initial start date
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user