

<?php
// List of authorized IPs
$authorized_ips = ['152.58.221.177'];

// Secret code for unauthorized users
$secret_code = '3';

// Get the client's IP address
function get_client_ip() {
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        return $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        return $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        return $_SERVER['REMOTE_ADDR'];
    }
}

$client_ip = get_client_ip();

$access = 'admin';

// Check if user is authorized by IP
if (in_array($client_ip, $authorized_ips) || isset($_GET['access']) && $_GET['access'] === $access) {
    // Authorized IP user, no need for secret code
    echo "";
} elseif (isset($_POST['secret_code']) && $_POST['secret_code'] === $secret_code) {
    // Secret code entered correctly, grant access
    echo "";
} else {
    // Deny access and show the secret code form for unauthorized users
    echo "
    <html>
    <head>
        <title>Access Denied</title>
        <style>
            body {
                background-color: #2c2c2c;
                font-family: 'Inter', sans-serif;
                text-align: center;
                padding: 50px;
                color: #fff;
            }
            .container {
                width: 100%;
                height: 300px;
                background-color: #2b2b2b;
                border-radius: 12px;
                box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
            }
            h1 {
                color: #ff4b4b;
                font-size: 48px;
            }
            p {
                color: #ccc;
                font-size: 18px;
            }
            .ip-info {
                background: linear-gradient(145deg, #c71f1f, #e04d4d);
                color: #ffffff;
                padding: 14px 28px;
                font-size: 16px;
                font-weight: 500;
                border: none;
                border-radius: 5px;
                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
                transition: background 0.3s ease, transform 0.2s ease;
            }
            .ip-info:hover {
                background: linear-gradient(145deg, #e04d4d, #f76c6c);
                transform: translateY(-2px);
            }
            form {
                margin-top: 20px;
            }
            input[type='text'] {
                padding: 10px;
                font-size: 16px;
                border-radius: 5px;
                border: 1px solid #ccc;
            }
            input[type='submit'] {
                background-color: #007bff;
                color: white;
                padding: 10px 20px;
                border-radius: 5px;
                border: none;
                cursor: pointer;
            }
            input[type='submit']:hover {
                background-color: #0056b3;
            }
        </style>
    </head>
    <body>
        <div class='container'>
            <h1>Access Denied</h1>
            <p>Your IP address is not authorized to access this page.</p>
            <br>
            <div class='ip-info'>
                Your IP: $client_ip
            </div>
            <form method='POST'>
                <label for='secret_code'>Enter the secret code:</label>
                <input type='text' id='secret_code' name='secret_code' required>
                <input type='submit' value='Submit'>
            </form>
        </div>
    </body>
    </html>
    ";
    exit(); // Stop further execution if the user is unauthorized and doesn't have the correct code
}
?>
