This may be an alternative way detect spiders:
PHP Code:
// Skip API call for known spiders if enabled
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$spiders_file = DIR_WS_INCLUDES . 'spiders.txt';
$spiders = file($spiders_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($spiders as $spider) {
if (strpos($user_agent, $spider) !== false) {
$spider_flag = true;
break;
}
}
if ($spider_flag && $spider_allow == 'true') {
// Check if logging is enabled for allowed spiders
$log_file_name_spiders = 'abuseipdb_spiders_' . date('Y_m') . '.log';
$log_file_path_spiders = $log_file_path . $log_file_name_spiders;
$log_message = date('Y-m-d H:i:s') . ' IP address ' . $ip . ' is identified as a Spider. AbuseIPDB API check was bypassed.' . PHP_EOL;
if ($spider_log_enabled == 'true') {
file_put_contents($log_file_path_spiders, $log_message, FILE_APPEND);
}
return 0; // Return 0 score for spiders or whatever default value you want
}
Bookmarks