properly compare user agent against user agent array
This commit is contained in:
parent
038e250527
commit
8fed9cb2e4
|
@ -41,8 +41,10 @@ class ImageViewCounter extends Extension
|
|||
// Don't add view for common crawler user agents
|
||||
$ua = $_SERVER["HTTP_USER_AGENT"] ?? "No UA";
|
||||
$ua_arr = ['googlebot', 'yandexbot', 'yandex', 'petalbot', 'baiduspider', 'bingbot', 'msnbot', 'semrushbot', 'dataforseobot', 'dotbot', 'rogerbot', 'slurp', 'duckduckbot', 'sogou', 'exabot', 'facebot', 'facebook', 'ia_archiver', 'applebot'];
|
||||
if (in_array(strtolower($ua), $ua_arr)) {
|
||||
return;
|
||||
foreach($ua_arr as $ua_part) {
|
||||
if (str_contains(strtolower($ua), $ua_part)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add view for current IP
|
||||
|
|
Loading…
Reference in New Issue