Add bot user agent detection (close #32)
This commit is contained in:
parent
f1e406bace
commit
7e4783ded3
2523
lib/bots.json
Normal file
2523
lib/bots.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,13 @@ if (!$database->has("settings", ["AND" => ["siteid" => getsiteid(), "key" => "an
|
||||
throw new Exception("Do-Not-Track header detected, skipping analytics");
|
||||
}
|
||||
|
||||
$bots = json_decode(file_get_contents(__DIR__ . "/bots.json"), true);
|
||||
foreach ($bots as $bot) {
|
||||
if (preg_match('/' . $bot['pattern'] . '/', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
throw new Exception("Bot/crawler detected, skipping analytics");
|
||||
}
|
||||
}
|
||||
|
||||
$time = date("Y-m-d H:i:s");
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user