<?php

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');

// 加载应用公共函数文件（必须在框架加载前）
require APP_PATH . 'common.php';

// 强制禁用OPcache并清除字节码缓存
if (function_exists('opcache_get_status')) {
    $status = opcache_get_status();
    if (!empty($status['opcache_enabled'])) {
        // 清除所有缓存
        @opcache_reset();
        // 强制重新加载关键文件
        $filesToInvalidate = [
            __DIR__ . '/../thinkphp/library/think/Env.php',
            __DIR__ . '/../application/database.php',
            __DIR__ . '/../application/extra/upload.php',
            __DIR__ . '/../application/extra/site.php',
            __DIR__ . '/../thinkphp/library/think/App.php',
        ];
        foreach ($filesToInvalidate as $file) {
            if (function_exists('opcache_invalidate')) {
                @opcache_invalidate($file, true);
            }
        }
    }
}
if (function_exists('apc_clear_cache')) {
    @apc_clear_cache();
}
clearstatcache();

// 判断是否安装
if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
    header("location:./install.php");
    exit;
}

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