<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]
namespace think;
error_reporting(E_ALL ^ E_NOTICE);

// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'");

define('__ROOT_DIR__', str_replace("\\", '/', realpath(dirname(__FILE__) . '/../')));
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
define("PUBLIC_PATH", __DIR__ . DIRECTORY_SEPARATOR);
define("ADDON_PATH", ROOT_PATH . 'app' . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR);
define("WEBSITE_PREFIX", 'cn');
define("WEB_IPLOCATION_NOCDN", "https://8.218.212.110/");         # 如果网站配置了CDN则需要填写静态地址

require __DIR__ . '/../vendor/autoload.php';
if (is_file(__DIR__ . '/../extend/360_safe/WebScan.php')) {
    include_once(__DIR__ . '/../extend/360_safe/WebScan.php');
}

# 执行HTTP应用并响应
$http = (new App())->http;

# 判断是否开启了CDN缓存
$path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if (WEB_IPLOCATION_NOCDN){
    if (stripos($path, '@growthman1688') == 1 || stripos($path, 'captcha') == 1 || stripos($path, 'addons') == 1) {
        # 后台不缓存
        header('Cache-Control: no-cache, no-store, must-revalidate');
        header('Pragma: no-cache');
        header('Expires: 0');
    }
}

$response = $http->run();
$response->send();

$http->end($response);
