<?php
/**
 * Geo diagnostic — open in browser to test country detection on cPanel.
 * Example: yoursite.com/natis/south/auth/geo_test.php
 * DELETE this file after testing.
 */
header('Content-Type: text/plain; charset=utf-8');

require_once __DIR__ . '/class/GeoAccess.php';

$start = microtime(true);
$ip = GeoAccess::resolveClientIp();
$info = GeoAccess::lookup($ip);
$ms = round((microtime(true) - $start) * 1000);

echo "=== GEO TEST ===\n";
echo "IP: " . $ip . "\n";
echo "Country: " . $info['code'] . " (" . $info['name'] . ")\n";
echo "Allowed: " . (!empty($info['allowed']) ? 'YES' : 'NO') . "\n";
echo "Geo off: " . (GeoAccess::isGeoDisabled() ? 'YES' : 'NO') . "\n";
echo "Allowed list: " . implode(', ', GeoAccess::$allowedCodes) . "\n";
echo "Lookup time: " . $ms . " ms\n";
echo "Config file: " . (is_readable(__DIR__ . '/cache/geo/geo_countries.cfg') ? 'OK' : 'MISSING') . "\n";
echo "curl: " . (function_exists('curl_init') ? 'YES' : 'NO') . "\n";
