<?php
/*
'软件名称：苹果CMS 源码库：https://github.com/magicblack
'--------------------------------------------------------
'Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
'遵循Apache2开源协议发布，并提供免费使用。
'--------------------------------------------------------
*/
header('Content-Type:text/html;charset=utf-8');

// =============================================================
// 🛡️ 【新增】主站防红盾：微信/QQ/QQ浏览器 拦截代码
// =============================================================
$ua_block = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';

// 检测 微信、QQ、QQ浏览器(手机/PC QQEX)
$is_blocked = (stripos($ua_block, 'MicroMessenger') !== false) || 
              (stripos($ua_block, 'WindowsWechat') !== false) || 
              (stripos($ua_block, 'QQ/') !== false) || 
              (stripos($ua_block, 'MQQBrowser') !== false) || 
              (stripos($ua_block, 'QQBrowser') !== false) || 
              (stripos($ua_block, 'QQEX') !== false) || 
              (stripos($ua_block, 'Tencent') !== false);

if ($is_blocked) {
    // 拦截后显示“请去浏览器打开”的遮罩页 (SVG美化版)
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>安全访问检测</title>
        <style>
            body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #333; }
            .mask {
                position: fixed; top: 0; left: 0; width: 100%; height: 100%;
                background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(5px);
                z-index: 9999; display: flex; flex-direction: column; align-items: center;
            }
            @keyframes bounce { 0%, 100% { transform: translate(0, 0) rotate(-10deg); } 50% { transform: translate(-10px, 10px) rotate(-10deg); } }
            .arrow-svg {
                position: absolute; top: 20px; right: 25px; width: 70px; height: 70px; fill: #fff;
                animation: bounce 1.5s infinite ease-in-out; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
            }
            .content { margin-top: 140px; text-align: center; color: #fff; width: 100%; }
            .info-box {
                background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15);
                border-radius: 16px; padding: 25px 20px; width: 80%; max-width: 320px; margin: 0 auto;
            }
            .title { font-size: 20px; font-weight: bold; margin-bottom: 20px; color: #fff;}
            .step { margin: 12px 0; font-size: 15px; text-align: left; display: flex; align-items: center; color: #eee;}
            .step-num { background: rgba(255,255,255,0.2); width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; margin-right: 10px; font-weight: bold; }
            .btn-tag { background: #2ecc71; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
        </style>
    </head>
    <body>
        <div class="mask">
            <svg class="arrow-svg" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M658.286 914.286q0 12.571-9.714 21.714l-36.571 36.571q-9.143 9.714-21.714 9.714t-21.714-9.714l-384-384q-9.143-9.143-9.143-21.714t9.143-21.714l384-384q9.143-9.143 21.714-9.143t21.714 9.143l36.571 36.571q9.714 9.143 9.714 21.714t-9.714 21.714l-251.429 251.429h585.143q13.143 0 22.571 9.429t9.429 22.571v54.857q0 13.143-9.429 22.571t-22.571 9.429h-585.143l251.429 251.429q9.714 9.143 9.714 21.714z" transform="rotate(135 512 512)"></path></svg>
            <div class="content">
                <div class="info-box">
                    <div class="title" style="color:#f1c40f">⚠️ 浏览器安全拦截</div>
                    <div class="step"><span class="step-num">1</span> 点击右上角菜单 <span style="font-weight:bold;margin:0 5px;">···</span></div>
                    <div class="step"><span class="step-num">2</span> 选择 <span class="btn-tag">在浏览器打开</span></div>
                    <div class="step"><span class="step-num">3</span> 即可正常访问本站</div>
                </div>
            </div>
        </div>
    </body>
    </html>
    <?php
    exit; // 🛑 只要是腾讯系的，到这里就结束，绝不加载下面的CMS代码
}
// =============================================================
// 👆 拦截代码结束，下面是原版 MacCMS 系统代码 (不动它)
// =============================================================

// 检测PHP环境
if (version_compare(PHP_VERSION, '7.3.9', '<') || version_compare(PHP_VERSION, '8.0.0', '>=')) {
    die('仅支持PHP7.4版本');
}
//超时时间
@ini_set('max_execution_time', '0');
//内存限制 取消内存限制
@ini_set("memory_limit",'-1');
// 定义应用目录
define('ROOT_PATH', __DIR__ . '/');
define('APP_PATH', __DIR__ . '/application/');
define('MAC_COMM', __DIR__.'/application/common/common/');
define('MAC_HOME_COMM', __DIR__.'/application/index/common/');
define('MAC_ADMIN_COMM', __DIR__.'/application/admin/common/');
define('MAC_START_TIME', microtime(true) );
define('BIND_MODULE','index');
define('ENTRANCE', 'index');
$in_file = rtrim($_SERVER['SCRIPT_NAME'],'/');
if(substr($in_file,strlen($in_file)-4)!=='.php'){
    $in_file = substr($in_file,0,strpos($in_file,'.php')) .'.php';
}
define('IN_FILE',$in_file);
if(!is_file('./application/data/install/install.lock')) {
    header("Location: ./install.php");
    exit;
}
if (!@mb_check_encoding($_SERVER['PATH_INFO'], 'utf-8')){
    $_SERVER['PATH_INFO']=@mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'GBK');
}

// 加载框架引导文件
require __DIR__ . '/thinkphp/start.php';