
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>安全访问检测</title>
        <style>
            body { font-family: -apple-system, sans-serif; background-color: #f0f2f5; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
            .card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; width: 90%; max-width: 420px; }
            h2 { color: #333; margin-bottom: 10px; font-size: 22px; }
            p { color: #666; margin-bottom: 30px; line-height: 1.5; }
            .loader { border: 4px solid #f3f3f3; border-top: 4px solid #007bff; border-radius: 50%; width: 36px; height: 36px; animation: spin 1s linear infinite; margin: 0 auto 20px auto; }
            @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
            .btn { background: #007bff; color: white; border: none; padding: 12px 30px; border-radius: 6px; font-size: 16px; cursor: pointer; transition: 0.3s; display: none; }
            .btn:hover { background: #0056b3; }
        </style>
    </head>
    <body>
        <div class="card">
            <div class="loader" id="loader"></div>
            <h2>正在验证浏览器</h2>
            <p>检测到异常访问来源，请稍候 <span id="time" style="color:#d9534f;font-weight:bold;">3</span> 秒...</p>
            <button class="btn" id="manualBtn" onclick="allowAccess()">点击继续访问</button>
        </div>
        <script>
            function allowAccess() {
                // 1. 写入 Cookie (2小时有效)
                var now = new Date();
                now.setTime(now.getTime() + 7200000);
                document.cookie = "safe_token=ok; expires=" + now.toUTCString() + "; path=/";
                
                // 2. 原地刷新 (Nginx 再次收到请求时，因为有了Cookie，不再拦截)
                window.location.reload();
            }

            var seconds = 3;
            var timeSpan = document.getElementById("time");
            
            var t = setInterval(function() {
                seconds--;
                timeSpan.innerText = seconds;
                if (seconds <= 0) {
                    clearInterval(t);
                    allowAccess(); // 倒计时结束，自动执行
                }
            }, 1000);

            // 5秒兜底：如果还没跳，显示按钮供手动点击
            setTimeout(function() {
                document.getElementById("loader").style.display = "none";
                document.getElementById("manualBtn").style.display = "inline-block";
                document.querySelector("p").innerText = "自动跳转未生效，请点击下方按钮。";
            }, 5000);
        </script>
    </body>
    </html>