<?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>
// +----------------------------------------------------------------------

use think\App;

// [ 应用入口文件 ]

$url = $_SERVER['REQUEST_URI'] ?? '';
$url_from = $_SERVER['HTTP_REFERER'] ?? '';

if(str_contains($url, '/business.php') || str_contains($url_from, '/business.php')){
    define('MN','business');
}elseif(str_contains($url, '/notify.php') || str_contains($url_from, '/notify.php')){
    define('MN','notify');
}elseif(str_contains($url, '/notify2.php') || str_contains($url_from, '/notify2.php')){
    define('MN','notify2');
} else{
    define('MN','index');
}

define("ROOT_PATH", dirname(__DIR__) . '/');
define('ROOT_PATH_PUBLIC', dirname(__DIR__) . '/public/');
define('APP_PATH', dirname(__DIR__) . '/app');
const WEB_PATH = __DIR__ . '/';

if((isset($_SERVER['REQUEST_SCHEME']) && 'https' == $_SERVER['REQUEST_SCHEME']) || (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) || (isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && 'https' == $_SERVER['HTTP_X_CLIENT_SCHEME'])){
    define('PRE_URL','https://'.($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME']));
}else{
    define('PRE_URL','http://'.($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME']));
}

require __DIR__ . '/../vendor/autoload.php';

// 执行HTTP应用并响应
$http = (new App())->http;

$response = $http->run();

$response->send();

$http->end($response);
