<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Verify User</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f9;
        }
        .container {
            background: #ffffff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        label {
            display: block;
            margin-bottom: 8px;
            color: #555;
        }
        input {
            width: 100%;
            padding: 10px;
            margin-bottom: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
        .result {
            margin-top: 16px;
            padding: 10px;
            border-radius: 4px;
            font-size: 14px;
        }
        .success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Verify User</h1>
        <label for="username">Username:</label>
        <input type="text" id="username" placeholder="Enter username" required>
        <button onclick="verifyUser()">Check User</button>
        <div id="result" class="result" style="display: none;"></div>
    </div>

    <script>
        async function verifyUser() {
            const username = document.getElementById('username').value;
            const resultDiv = document.getElementById('result');

            if (!username) {
                resultDiv.textContent = 'Please enter a username.';
                resultDiv.className = 'result error';
                resultDiv.style.display = 'block';
                return;
            }

            const sellerKey = '2572c45d67618757714b094dc01de4d9';
            const url = `https://keyauth.win/api/seller/?sellerkey=${sellerKey}&type=verifyuser&user=${encodeURIComponent(username)}`;

            try {
                const response = await fetch(url, {
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });

                if (!response.ok) {
                    if (response.status === 0) {
                        throw new Error('CORS or network error occurred.');
                    }
                    throw new Error(`HTTP error! Status: ${response.status}`);
                }

                const data = await response.json();

                if (data.success) {
                    resultDiv.textContent = `User exists: ${data.message}`;
                    resultDiv.className = 'result success';
                } else {
                    resultDiv.textContent = `Error: ${data.message || 'User does not exist'}`;
                    resultDiv.className = 'result error';
                }
            } catch (error) {
                resultDiv.textContent = `An error occurred: ${error.message}`;
                resultDiv.className = 'result error';
            }

            resultDiv.style.display = 'block';
        }
    </script>
</body>
</html>
