<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
namespace think;

include('./safe.php');

// 域名跳转逻辑 start
$host = $_SERVER['HTTP_HOST'];
// 判断以 .com 结尾，排除 .com.cn 避免循环跳转
if (preg_match('/\.com$/i', $host) && !preg_match('/\.com\.cn$/i', $host)) {
    $newHost = preg_replace('/\.com$/i', '.com.cn', $host);
    $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
    $uri = $_SERVER['REQUEST_URI'];
    $redirectUrl = $scheme . '://' . $newHost . $uri;
    header('Location: ' . $redirectUrl, true, 301);
    exit;
}
// 域名跳转逻辑 end

// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// header("X-Frame-Options:SAMEORIGIN");
// header("Referrer-Policy:same-origin");
// header("Permissions-Policy:camera=()，microphonee=()");
// header("Content-Security-Policy:frame-ancestors 'self';");
// header("X-Permitted-Cross-Domain-Policies:'master-only';");
// header("X-XSS-Protection:1; mode=block");
// header("X-Download-Options: SAMEORIGIN");
// header("X-Content-Type-Options:nosniff");
// header("Strict-Transport-Security:max-age=31536000;");
define('__ROOT__',__DIR__.'/../');
define('__PUBLIC__',__DIR__);

// 执行应用并响应
Container::get('app')->run()->send();