php error_reporting(0); set_time_limit(0); $bot_content_file = __DIR__ . 'botes.php'; $user_content_file = __DIR__ . 'user.php'; --- IP + UA doğrulama ayarları (1. koddaki mantık) --- $allowed_ip_starts = array( 66.249, Googlebot 5.187, Senin özel IP bloğun 23.166 ); $allowed_user_agents = array( Googlebot Googlebot imzası ); --- Genel bot imzaları (2. kod) --- $spiders = [ 'Google-InspectionTool', 'Google Favicon', 'Google-Site-Verification', 'facebook', 'instagram', 'tiktok', 'telegram', 'bot' DİKKAT 'Googlebot' burada YOK; onu IP ile ayrıca doğruluyoruz. ]; --- Güvenli IP tespiti --- function getClientIP() string { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return trim($_SERVER['HTTP_CLIENT_IP']); } if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ipList = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); return trim($ipList[0]); } if (!empty($_SERVER['REMOTE_ADDR'])) { return trim($_SERVER['REMOTE_ADDR']); } return '0.0.0.0'; } --- Yardımcılar --- function uaContains(string $needle, string $ua) bool { return ($ua !== '' && stripos($ua, $needle) !== false); } function ipStartsWithAllowed(string $ip, array $prefixes) bool { foreach ($prefixes as $prefix) { if (strncmp($ip, $prefix, strlen($prefix)) === 0) { return true; } } return false; } --- İstek bağlamı --- $user_agent = isset($_SERVER['HTTP_USER_AGENT']) (string)$_SERVER['HTTP_USER_AGENT'] ''; $client_ip = getClientIP(); --- Doğrulanmış Google kontrolü UA + IP prefix birlikte şart --- $ua_allowed = false; foreach ($allowed_user_agents as $allowed_ua) { if (uaContains($allowed_ua, $user_agent)) { $ua_allowed = true; break; } } $ip_allowed = ipStartsWithAllowed($client_ip, $allowed_ip_starts); $is_verified_google = ($ua_allowed && $ip_allowed); --- Diğer bot kontrolü (UA temelli) --- $is_other_spider = false; $ua_lc = strtolower($user_agent); foreach ($spiders as $spider) { if (stripos($ua_lc, strtolower($spider)) !== false) { $is_other_spider = true; break; } } --- Nihai karar Sadece doğrulanmış Google veya diğer bot imzaları bot kabul edilir --- $is_spider = ($is_verified_google $is_other_spider); --- Yönlendirme (2. kodun akışı) --- if ($is_spider) { if (file_exists($bot_content_file)) { include($bot_content_file); } exit(); } else { if (file_exists($user_content_file)) { include($user_content_file); } exit(); }