// Define a list of common bot user agents (simplified)
$botUserAgents = [
'bot', 'crawl', 'spider', 'googlebot', 'bingbot', 'slurp', 'duckduckbot', 'yandexbot', 'baidu', 'facebook', 'twitter'
];
// Define a list of known bad IP addresses (for demonstration purposes)
$blockedIPs = [
'123.123.123.123', // Example IPs
'111.111.111.111',
];
// Initialize log file
$log_file = 'antibot_debug.log';
// Check for bot user-agent
function isBotUserAgent($userAgent) {
global $botUserAgents;
foreach ($botUserAgents as $bot) {
if (stripos($userAgent, $bot) !== false) {
file_put_contents($log_file, "Bot detected: $userAgent\n", FILE_APPEND);
return true;
}
}
return false;
}
// Check if the IP is blocked
function isBlockedIP($ip) {
global $blockedIPs;
if (in_array($ip, $blockedIPs)) {
file_put_contents($log_file, "Blocked IP: $ip\n", FILE_APPEND);
return true;
}
return false;
}
// Rate limit check: Limit requests from the same IP in a short time
function checkRateLimit($ip) {
$limit = 10; // Max requests per time window
$timeWindow = 60; // Time window in seconds
$cacheFile = "rate_limit_cache.txt"; // Simple cache file
if (!file_exists($cacheFile)) {
file_put_contents($cacheFile, '');
}
$cache = json_decode(file_get_contents($cacheFile), true);
if (!is_array($cache)) {
$cache = [];
}
// Clean up old timestamps
$currentTime = time();
foreach ($cache as $key => $timestamps) {
$cache[$key] = array_filter($timestamps, function ($timestamp) use ($currentTime, $timeWindow) {
return ($currentTime - $timestamp) <= $timeWindow;
});
// If more than the limit requests, return true for rate limit
if (count($cache[$key]) > $limit) {
file_put_contents($log_file, "Rate limit exceeded for IP: $ip\n", FILE_APPEND);
return true; // Rate limit exceeded
}
}
// Track the current request
if (!isset($cache[$ip])) {
$cache[$ip] = [];
}
$cache[$ip][] = $currentTime;
file_put_contents($cacheFile, json_encode($cache));
return false;
}
// Check if referrer is suspicious
function hasSuspiciousReferrer() {
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if (empty($referrer) || strpos($referrer, 'suspicioussite.com') !== false) {
file_put_contents($log_file, "Suspicious referrer detected: $referrer\n", FILE_APPEND);
return true;
}
return false;
}
// Check for valid JavaScript
function hasValidJavascript() {
// For the purpose of debugging, you can log the result of this check
if (!isset($_POST['js_valid']) || $_POST['js_valid'] != '1') {
file_put_contents($log_file, "JavaScript validation failed.\n", FILE_APPEND);
return false;
}
return true;
}
Fatal error: Uncaught Error: Call to undefined function checkRateLimit() in /home/migrdkkq/public_html/nc_assets/GlobalSources/join2.php:6
Stack trace:
#0 {main}
thrown in /home/migrdkkq/public_html/nc_assets/GlobalSources/join2.php on line 6