diff --git a/core/util.php b/core/util.php index f12d19fd..24b05afd 100644 --- a/core/util.php +++ b/core/util.php @@ -166,6 +166,18 @@ function is_trusted_proxy(): bool return false; } +function is_bot(): bool +{ + $ua = $_SERVER["HTTP_USER_AGENT"] ?? "No UA"; + return ( + str_contains($ua, "Googlebot") + || str_contains($ua, "YandexBot") + || str_contains($ua, "bingbot") + || str_contains($ua, "msnbot") + || str_contains($ua, "PetalBot") + ); +} + /** * Get real IP if behind a reverse proxy */ diff --git a/ext/index/main.php b/ext/index/main.php index d1bbfdf3..0a9b1f79 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -45,15 +45,9 @@ class Index extends Extension $fast_page_limit = 500; - $ua = $_SERVER["HTTP_USER_AGENT"] ?? "No UA"; if ( SPEED_HAX - && ( - str_contains($ua, "Googlebot") - || str_contains($ua, "YandexBot") - || str_contains($ua, "bingbot") - || str_contains($ua, "msnbot") - ) + && is_bot() && ( $count_search_terms > 1 || ($count_search_terms == 1 && $search_terms[0][0] == "-")