| @@ -4,9 +4,14 @@ | ||
| 4 | 4 | class berqDetectCrawler { |
| 5 | 5 | public static function is_crawler() { |
| 6 | 6 | // Load the JSON data |
| 7 | 7 | $json_file = optifer_PATH . '/inc/crawler/crawler-user-agents.json'; |
| 8 | + if (empty($_SERVER['HTTP_USER_AGENT'])) { | |
| 9 | + return false; | |
| 10 | + } | |
| 8 | 11 | $user_agent = $_SERVER['HTTP_USER_AGENT']; |
| 12 | + | |
| 13 | + | |
| 9 | 14 | $crawler_data = json_decode(file_get_contents($json_file), true); |
| 10 | 15 | |
| 11 | 16 | if (!$crawler_data) { |
| 12 | 17 | error_log('Failed to load or decode the JSON file.'); |