<?php
// 获取用户浏览器的标识 (User-Agent)
$agent = $_SERVER['HTTP_USER_AGENT'];

// 判断是否包含 "QQ" 或 "MicroMessenger" (微信) 关键词
$isQQ = strpos($agent, 'QQ/') !== false;
$isWx = strpos($agent, 'MicroMessenger') !== false;

// 设定你要跳转的目标网址 (请修改这里)
$targetUrl = "https://www.baidu.com";

if ($isQQ || $isWx) {
    // === 场景 1：在 QQ 或微信中打开 ===
    // 显示你提供的“请在浏览器打开”的提示页面
    ?>
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>安全提示</title>
        <style>
            * { margin: 0; padding: 0; box-sizing: border-box; }
            body { font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif; background-color: #f2f3f5; height: 100vh; display: flex; justify-content: center; align-items: center; }
            .card { background-color: #fff; width: 90%; max-width: 400px; padding: 40px 20px; border-radius: 20px; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
            .logo { width: 80px; height: 80px; border-radius: 18px; margin-bottom: 20px; }
            .status-text { color: #40c866; font-size: 16px; font-weight: 500; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; }
            .status-text::before { content: "✓"; font-weight: bold; margin-right: 5px; }
            .main-title { font-size: 24px; color: #1a1a1a; font-weight: 700; margin-bottom: 10px; }
            .sub-text { font-size: 14px; color: #999; line-height: 1.6; margin-bottom: 30px; }
            .btn-copy { display: block; width: 100%; background-color: #007aff; color: #fff; font-size: 18px; font-weight: 500; padding: 14px 0; border-radius: 12px; border: none; text-decoration: none; }
            .footer-text { margin-top: 20px; font-size: 13px; color: #ccc; }
        </style>
    </head>
    <body>
        <div class="card">
            <img src="http://qq.888333.xyz/logo.png" alt="Logo" class="logo">
            <div class="status-text">已安全验证</div>
            <h1 class="main-title">请在浏览器内打开</h1>
            <p class="sub-text">点击下方按钮复制链接<br>粘贴到浏览器地址栏打开学习😉</p>
            <button class="btn-copy" onclick="alert('链接已复制，请去浏览器粘贴')">复制链接</button>
            <p class="footer-text">如已打开浏览器，请在地址栏粘贴访问</p>
        </div>
    </body>
    </html>
    <?php
} else {
    // === 场景 2：在其他浏览器 (Chrome, Safari, Edge等) 中打开 ===
    // 直接跳转到目标网址
    header("Location: " . $targetUrl);
    exit;
}
?>
