<?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;

// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';

// 支持事先使用静态方法设置Request对象和Config对象
// [ 应用入口文件 ]
 
// 准许跨域请求。
//跨域访问的时候才会存在此字段  
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : ''; 
// if($origin == ''){
//     $origin = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; 
// }

// 正式
 //$allow_origin = array(
// 	'http://lyfthomezt.huichifangqiu.com',
// 	'http://192.168.1.127:8080', // dujun
// 	'http://localhost:8080', // fangjc
// 	'http://lyft.huichifangqiu.com', // yangla
// 	'http://lyftdemo.huichifangqiu.com', // fangjc
// 	'http://192.168.1.133:8080' // fangjc
// );
// if(in_array($origin, $allow_origin)){
// 	header('Access-Control-Allow-Origin:'.$origin); 
// 	header("Access-Control-Allow-Credentials: true"); 
// 	header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); 
 //}

// header('Access-Control-Allow-Origin:localhost:8888'); 
// header("Access-Control-Allow-Credentials: true"); 
// header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");

// 测试
if($origin){
	header('Access-Control-Allow-Origin:'.$origin);
	header('Access-Control-Allow-Headers:Authorization, Origin, X-Requested-With, Content-Type, Accept, token, Token');
	header("Access-Control-Allow-Credentials: true"); 
	header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
}

// 执行应用并响应
Container::get('app')->run()->send();
