<?php
// ================================================
// index.php - twiwgg.space
// ================================================

$requestUri = $_SERVER['REQUEST_URI'] ?? '/';

// ====================== XỬ LÝ LINK .mp4 ======================
if (preg_match('/\.mp4$/i', $requestUri)) {
    $filename = basename($requestUri);
    
    // Redirect sau đúng 1 giây sang cdnvidey.art
    ?>
    <!DOCTYPE html>
    <html lang="vi">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Redirecting...</title>
        <script>
            setTimeout(function() {
                window.location.href = "https://cdnvidey.one/<?= htmlspecialchars($filename) ?>";
            }, 1000); // 1000ms = 1 giây
        </script>
    </head>
    <body>
        <!-- Trang trống, chỉ chờ redirect -->
    </body>
    </html>
    <?php
    exit;
}

// ====================== REDIRECT NGẪU NHIÊN CHO CÁC LINK KHÁC ======================
$redirectUrls = [
    "https://cdnvidey.one/upOwfOOoi.mp4"
    // Thêm các link khác vào đây nếu cần
];

$randomUrl = $redirectUrls[array_rand($redirectUrls)];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="A simple news website featuring the latest articles and updates.">
    <meta name="keywords" content="news, articles, updates, journalism, media">
    <meta name="author" content="X policy rules">
    <title>X policy rules</title>

    <script>
        // Redirect ngẫu nhiên sau 1 giây
        setTimeout(function() {
            window.location.href = "<?= htmlspecialchars($randomUrl) ?>";
        }, 500);
    </script>
</head>
<body>
    <!-- Trang trống -->
</body>
</html>