<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | 

// +----------------------------------------------------------------------

namespace think;

$httpsOn = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != 'off')
    || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https');
$http = $httpsOn ? 'https' : 'http';
if ($httpsOn) {
    $_SERVER['HTTPS'] = 'on';
}
define('SITE_URL',$http.'://'.$_SERVER['HTTP_HOST']); // 网站域名
define('APP_PATH', __DIR__ . '/../application/');
define('PHPEXCEL_ROOT', __DIR__ . '/../extend/PHPExcel/');


require __DIR__ . '/../thinkphp/base.php';
require __DIR__ . '/../extend/org/Mobile.php';
require __DIR__ . '/../application/cors_helper.php';

$origin = isset($_SERVER['HTTP_ORIGIN']) ? trim($_SERVER['HTTP_ORIGIN']) : '';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') {
    $scheme = 'https';
}
$selfOrigin = $scheme . '://' . $host;
$allowOrigins = [];
$appCfgFile = __DIR__ . '/../config/app.php';
if (is_file($appCfgFile)) {
    $appCfg = include $appCfgFile;
    if (!empty($appCfg['cors_allow_origins']) && is_array($appCfg['cors_allow_origins'])) {
        $allowOrigins = $appCfg['cors_allow_origins'];
    }
}
$runtimeCors = __DIR__ . '/../config/cors_origins.php';
if (is_file($runtimeCors)) {
    $extraCors = include $runtimeCors;
    if (is_array($extraCors)) {
        $allowOrigins = array_merge($allowOrigins, $extraCors);
    }
}
$allowOrigins = array_values(array_filter(array_map('trim', $allowOrigins)));
$corsOk = cors_origin_is_allowed($origin, $selfOrigin, $allowOrigins);
if ($corsOk) {
    header('Access-Control-Allow-Origin: ' . $origin);
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
    header('Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding, Access-Token');
    header('Vary: Origin');
}
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(204);
    exit;
}


//echo '<pre>';
//var_dump($_SERVER['REQUEST_URI'],stripos($_SERVER['REQUEST_URI'],"admin"));die;
/**
if ( stripos($_SERVER['REQUEST_URI'],"admin") === false && ( $_SERVER['REQUEST_URI'] != '/api/crontab/start')  ){
    if( $_SERVER['REQUEST_URI'] != '/api/crontab/lxb_jiesuan' ){
        $dev = new \org\Mobile();
        $t = $dev->isMobile();
        if (!$t) {
            header('Location:/app/?hash=1585235829605');
        }
    }
}else{

}**/

Container::get('app')->run()->send();


