// Array of allowed country codes $allowedCountries = ['CH', 'RS']; // Get the current server API $api = php_sapi_name(); // Bypass geo checks for non-web server APIs if ($api == 'fpm-fcgi' || $api == 'cli') { return; // Early exit for CLI or FPM contexts } // Retrieve the country code or default to blocking access $countryCode = $_SERVER['GEOIP_COUNTRY_CODE'] ?? 'Unknown'; // Using null coalescing operator for clarity // Block access if the country code is not allowed if (!in_array($countryCode, $allowedCountries)) { header('HTTP/1.1 404 Not Found', true, 404); exit; } Available on DVD | Blue-Ray Archives -
Go to Top