From 559222a5b4774662863acd2a9aa8e2d1c7e6871a Mon Sep 17 00:00:00 2001 From: techdealer Date: Sat, 26 Nov 2016 23:55:29 +0000 Subject: [PATCH 1/4] New plugin minhateca.com.br box --- hosts/upload/minhateca.com.br_box.index.php | 5 + hosts/upload/minhateca.com.br_box.php | 366 ++++++++++++++++++++ 2 files changed, 371 insertions(+) create mode 100644 hosts/upload/minhateca.com.br_box.index.php create mode 100644 hosts/upload/minhateca.com.br_box.php diff --git a/hosts/upload/minhateca.com.br_box.index.php b/hosts/upload/minhateca.com.br_box.index.php new file mode 100644 index 0000000..3e27fc3 --- /dev/null +++ b/hosts/upload/minhateca.com.br_box.index.php @@ -0,0 +1,5 @@ + diff --git a/hosts/upload/minhateca.com.br_box.php b/hosts/upload/minhateca.com.br_box.php new file mode 100644 index 0000000..1e114ce --- /dev/null +++ b/hosts/upload/minhateca.com.br_box.php @@ -0,0 +1,366 @@ +
Use Default login/pass.
\n"; +} +if ($_REQUEST['action'] == "FORM") + $continue_up=true; +else{ +?> + + + + + + + +
 User*  
 Password*  
*You can set it as default in
+ + + + +
+
Login to
+' . + '' . + '' . + '' . + '' . $_REQUEST['my_login'] . '' . + '' . strtolower(md5($_REQUEST['my_pass'])) . '' . + '4' . + '' . + 'chomikbox' . + '2.0.8.1' . + '' . + '' . + '' . + ''; + + $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/Auth\r\nContent-Type: text/xml;charset=utf-8\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); + is_page($page); + + + preg_match('/\(.*?)\<\/a:token\>/', $page, $temp); + if($temp) + { + $auth_token = $temp[1]; + } else { + html_error ('Login error'); + } + + preg_match('/\(.*?)\<\/a:hamsterId\>/', $page, $temp); + if($temp) + { + $chomik_id = $temp[1]; + } else { + html_error ('Login error'); + } + + ?> + +
Retrive upload ID
+ +' . + '' . + '' . + '' . + '' . $auth_token . '' . + '0' . + '' . $lname . '' . + '' . + '' . + ''; + + $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/UploadToken\r\nContent-Type: text/xml;charset=utf-8\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); + is_page($page); + + preg_match('/\(.*?)\<\/a:key\>/', $page, $temp); + if($temp) + { + $upload_key = $temp[1]; + } else { + html_error ('Error fetching upload page'); + } + + preg_match('/\(.*?)\<\/a:stamp\>/', $page, $temp); + if($temp) + { + $upload_time = $temp[1]; + } else { + html_error ('Error fetching upload page'); + } + + preg_match('/\(.*?)\<\/a:server\>/', $page, $temp); + if($temp) + { + $upload_server = $temp[1]; + $upload_host = explode(":", $upload_server)[0]; + $upload_port = explode(":", $upload_server)[1]; + } else { + html_error ('Error fetching upload page'); + } + + $upfiles = MT_upfile($upload_host, $upload_port, $upload_time, $chomik_id, $upload_key, $lfile, $lname, $_GET["uproxy"], $pauth) + +?> + + 0) ? CookiesToStr($cookie) : 0; + else $cookies = trim($cookie); + } + if ($scheme == 'https://') { + if (!extension_loaded('openssl')) return html_error('You need to install/enable PHP\'s OpenSSL extension to support uploading via HTTPS.'); + $scheme = 'tls://'; + if ($port == 0 || $port == 80) $port = 443; + } else if ($port == 0) $port = 80; + if (!empty($referer) && ($pos = strpos("\r\n", $referer)) !== 0) { + $origin = parse_url($pos ? substr($referer, 0, $pos) : $referer); + $origin = strtolower($origin['scheme']) . '://' . strtolower($origin['host']) . (!empty($origin['port']) && $origin['port'] != defport(array('scheme' => $origin['scheme'])) ? ':' . $origin['port'] : ''); + } else $origin = ($scheme == 'tls://' ? 'https://' : $scheme) . $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : ''); + if ($proxy) { + list($proxyHost, $proxyPort) = explode(':', $proxy, 2); + if ($scheme != 'tls://') { + $host = $host . ($port != 80 && $port != 443 ? ":$port" : ''); + $url = "$scheme$host$url"; + } + } + if ($scheme != 'tls://') $scheme = ''; + $cHeaders = readCustomHeaders($referer); + $request = array(); + $request[''] = 'POST ' . str_replace(' ', '%20', $url) . ' HTTP/1.1'; + + $request['Content-Type'] = "multipart/mixed; boundary=!CHB$time"; + $request['Connection'] = 'Keep-Alive'; + $request['User-Agent'] = $upagent; + $request['Pragma'] = 'no-cache'; + $request['Cache-Control'] = 'no-cache'; + $request['Host'] = $host.':'.$port; + $request['Connection'] = 'Keep-Alive'; + + if (!empty($pauth) && !$scheme) $request['proxy-authorization'] = "Basic $pauth"; + $request['content-length'] = (strlen($postdata) + strlen($nn . "--" . $bound . "--" . $nn) + $fileSize); + $request = headers2request(array_merge($request, $cHeaders), $postdata); + $errno = 0; + $errstr = ''; + if ($scheme == 'tls://') { + $hosts = (!empty($proxyHost) ? $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port); + if ($proxy) $url = "https://$host$url"; // For the 'connected to' message + } else $hosts = (!empty($proxyHost) ? $scheme . $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port); + $fp = @stream_socket_client($hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT); + if (!$fp) { + if (!function_exists('stream_socket_client')) return html_error('[ERROR] stream_socket_client() is disabled.'); + $dis_host = !empty($proxyHost) ? $proxyHost : $host; + $dis_port = !empty($proxyPort) ? $proxyPort : $port; + return html_error(sprintf(lang(88), $dis_host, $dis_port)); + } + if ($errno || $errstr) { + $lastError = $errstr; + return false; + } + if ($proxy) echo '

' . sprintf(lang(89), $proxyHost, $proxyPort) . '
UPLOAD: ' . htmlspecialchars($url) . "...
\n"; + else echo '

'.sprintf(lang(90), $host, $port).'

'; + if ($scheme == 'tls://' && $proxy) { + $connRequest = array(); + $connRequest[''] = "CONNECT $host:$port HTTP/1.1"; + if (!empty($pauth)) $connRequest['proxy-authorization'] = "Basic $pauth"; + $connRequest['proxy-connection'] = 'Close'; + $connRequest = headers2request($connRequest); + fwrite($fp, $connRequest); + fflush($fp); + $llen = 0; + $header = ''; + do { + $header .= fgets($fp, 16384); + $len = strlen($header); + if (!$header || $len == $llen) { + $lastError = 'No response from proxy after CONNECT.'; + stream_socket_shutdown($fp, STREAM_SHUT_RDWR); + fclose($fp); + return false; + } + $llen = $len; + } while (strpos($header, $nn . $nn) === false); + $status = intval(substr($header, 9, 3)); + if ($status != 200) { + return html_error("Proxy returned $status after CONNECT."); + } + // Start TLS. + if (!stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) return html_error('TLS Startup Error.'); + } + echo(lang(104) . ' ' . htmlspecialchars($filename) . ', ' . lang(56) . ' ' . bytesToKbOrMbOrGb($fileSize) . '...
'); + $GLOBALS['id'] = md5(time() * rand(0, 10)); + require (TEMPLATE_DIR . '/uploadui.php'); + flush(); + fwrite($fp, $request); + fflush($fp); + $timeStart = microtime(true); + $chunkSize = GetChunkSize($fileSize); + $fs = fopen($file, 'r'); + $totalsend = $time = $lastChunkTime = 0; + while (!feof($fs) && !$errno && !$errstr) { + $data = fread($fs, $chunkSize); + if ($data === false) { + fclose($fs); + fclose($fp); + return html_error(lang(112)); + } + $sendbyte = @fwrite($fp, $data); + fflush($fp); + if ($sendbyte === false || strlen($data) > $sendbyte) { + fclose($fs); + fclose($fp); + return html_error(lang(113)); + } + $totalsend += $sendbyte; + $time = microtime(true) - $timeStart; + $chunkTime = $time - $lastChunkTime; + $chunkTime = $chunkTime ? $chunkTime : 1; + $chunkTime = ($chunkTime > 0) ? $chunkTime : 1; + $lastChunkTime = $time; + $speed = round($sendbyte / 1024 / $chunkTime, 2); + $percent = round($totalsend / $fileSize * 100, 2); + echo "\n"; + flush(); + } + if ($errno || $errstr) { + $lastError = $errstr; + return false; + } + fclose($fs); + fwrite($fp, $nn . "--" . $bound . "--" . $nn); + fflush($fp); + $llen = 0; + $header = ''; + do { + $header .= fgets($fp, 16384); + $len = strlen($header); + if (!$header || $len == $llen) { + $lastError = lang(91); + stream_socket_shutdown($fp, STREAM_SHUT_RDWR); + fclose($fp); + return false; + } + $llen = $len; + } while (strpos($header, $nn . $nn) === false); + // Array for active stream filters + $sFilters = array(); + if (stripos($header, "\nTransfer-Encoding: chunked") !== false && in_array('dechunk', stream_get_filters())) $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ); // Add built-in dechunk filter + $length = trim(cut_str($header, "\nContent-Length: ", "\n")); + if (!$length || !is_numeric($length)) $length = -1; + $page = stream_get_contents($fp, $length); + stream_socket_shutdown($fp, STREAM_SHUT_RDWR); + fclose($fp); + if (empty($sFilters['dechunk']) && stripos($header, "\nTransfer-Encoding: chunked") !== false && function_exists('http_chunked_decode')) { + $dechunked = http_chunked_decode($page); + if ($dechunked !== false) $page = $dechunked; + unset($dechunked); + } + if (stripos($header, "\nContent-Encoding: gzip") !== false) { + $decompressed = gzinflate(substr($page, 10)); + if ($decompressed !== false) $page = $decompressed; + unset($decompressed); + } else if (stripos($header, "\nContent-Encoding: deflate") !== false) { + $decompressed = gzinflate(in_array(substr($page, 0, 2), array("x\x01", "x\x9C", "x\xDA")) ? substr($page, 2) : $page); + if ($decompressed !== false) $page = $decompressed; + unset($decompressed); + } + $page = $header.$page; + return $page; +} + + +// tech - Written in 26/11/2016 +?> From 5d4b2e81f66185949bd0c5da13158d72371931c1 Mon Sep 17 00:00:00 2001 From: techdealer Date: Sun, 27 Nov 2016 17:50:24 +0000 Subject: [PATCH 2/4] Removed "Keep-alive" header; Added download_link --- hosts/upload/minhateca.com.br_box.php | 61 ++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/hosts/upload/minhateca.com.br_box.php b/hosts/upload/minhateca.com.br_box.php index 1e114ce..8e8ad75 100644 --- a/hosts/upload/minhateca.com.br_box.php +++ b/hosts/upload/minhateca.com.br_box.php @@ -56,7 +56,7 @@ '' . ''; - $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/Auth\r\nContent-Type: text/xml;charset=utf-8\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); + $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/Auth\r\nContent-Type: text/xml;charset=utf-8\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); is_page($page); @@ -93,7 +93,7 @@ '' . ''; - $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/UploadToken\r\nContent-Type: text/xml;charset=utf-8\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); + $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/UploadToken\r\nContent-Type: text/xml;charset=utf-8\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); is_page($page); preg_match('/\(.*?)\<\/a:key\>/', $page, $temp); @@ -130,12 +130,65 @@ is_page($upfiles); is_notpresent($upfiles, 'HTTP/1.1 200', 'Upload error'); - $pos = strpos($upfiles, '' . + '' . + '' . + '' . + '' . $auth_token . '' . + '' . + '' . rand(0,25000) . '' . + '0' . + '1' . + '' . + 'download' . + '' . + '' . + '' . $fileid . '' . + '' . + '' . + '' . + '' . + ''; + + $page = geturl($host, 80, "/services/ChomikBoxService.svc", "http://".$host."/\r\nSOAPAction: http://chomikuj.pl/IChomikBoxService/Download\r\nContent-Type: text/xml;charset=utf-8\r\nUser-Agent: Mozilla/5.0", 0, $post, 0, $_GET["uproxy"], $pauth); + is_page($page); + + $dl = array(); + preg_match('/\(.*?)\<\/globalId\>/', $page, $temp); + if($temp) + { + $dl['globalId'] = $temp[1]; + } else { + html_error ('Error retrive download link!'); + } + + preg_match_all('/\(.*?)\<\/name\>/', $page, $temp); + if($temp) + { + $dl['name'] = $temp[1][1]; + $dl['filename'] = pathinfo($dl['name'], PATHINFO_FILENAME); + $dl['extension'] = pathinfo($dl['name'], PATHINFO_EXTENSION); + } else { + html_error ('Error retrive download link!'); + } + + $download_link = 'http://minhateca.com.br'.$dl['globalId'].'/'.$dl['filename'].','.$fileid.'.'.$dl['extension']; + } @@ -223,12 +276,10 @@ function MT_upfile($host, $port, $time, $chomik_id, $key, $file, $filename, $pro $request[''] = 'POST ' . str_replace(' ', '%20', $url) . ' HTTP/1.1'; $request['Content-Type'] = "multipart/mixed; boundary=!CHB$time"; - $request['Connection'] = 'Keep-Alive'; $request['User-Agent'] = $upagent; $request['Pragma'] = 'no-cache'; $request['Cache-Control'] = 'no-cache'; $request['Host'] = $host.':'.$port; - $request['Connection'] = 'Keep-Alive'; if (!empty($pauth) && !$scheme) $request['proxy-authorization'] = "Basic $pauth"; $request['content-length'] = (strlen($postdata) + strlen($nn . "--" . $bound . "--" . $nn) + $fileSize); From a902aae3622ecd84d5596edfd081e84688b5f87c Mon Sep 17 00:00:00 2001 From: techdealer Date: Sun, 27 Nov 2016 18:22:25 +0000 Subject: [PATCH 3/4] Small update --- hosts/upload/minhateca.com.br_box.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts/upload/minhateca.com.br_box.php b/hosts/upload/minhateca.com.br_box.php index 8e8ad75..42a278d 100644 --- a/hosts/upload/minhateca.com.br_box.php +++ b/hosts/upload/minhateca.com.br_box.php @@ -275,7 +275,7 @@ function MT_upfile($host, $port, $time, $chomik_id, $key, $file, $filename, $pro $request = array(); $request[''] = 'POST ' . str_replace(' ', '%20', $url) . ' HTTP/1.1'; - $request['Content-Type'] = "multipart/mixed; boundary=!CHB$time"; + $request['Content-Type'] = "multipart/mixed; boundary=$bound"; $request['User-Agent'] = $upagent; $request['Pragma'] = 'no-cache'; $request['Cache-Control'] = 'no-cache'; From 12a0b39ac84a1361004c83c33528772761bdc4f2 Mon Sep 17 00:00:00 2001 From: techdealer Date: Sun, 27 Nov 2016 19:35:49 +0000 Subject: [PATCH 4/4] Minhateca: Use default upfile function --- hosts/upload/minhateca.com.br_box.php | 230 +------------------------- 1 file changed, 7 insertions(+), 223 deletions(-) diff --git a/hosts/upload/minhateca.com.br_box.php b/hosts/upload/minhateca.com.br_box.php index 42a278d..9e1dabf 100644 --- a/hosts/upload/minhateca.com.br_box.php +++ b/hosts/upload/minhateca.com.br_box.php @@ -122,8 +122,14 @@ html_error ('Error fetching upload page'); } - $upfiles = MT_upfile($upload_host, $upload_port, $upload_time, $chomik_id, $upload_key, $lfile, $lname, $_GET["uproxy"], $pauth) + $uploadPost['chomik_id'] = $chomik_id; + $uploadPost['folder_id'] = '0'; + $uploadPost['key'] = $upload_key; + $uploadPost['time'] = $upload_time; + $uploadPost['client'] = 'MinhaBox.br-2.0.8.1'; + $uploadPost['locale'] = 'BR'; + $upfiles = upfile($upload_host, $upload_port, '/file/', 0, 0, $uploadPost, $lfile, $lname, "file", "", $_GET["uproxy"], $pauth, 'Mozilla/5.0'); ?> 0) ? CookiesToStr($cookie) : 0; - else $cookies = trim($cookie); - } - if ($scheme == 'https://') { - if (!extension_loaded('openssl')) return html_error('You need to install/enable PHP\'s OpenSSL extension to support uploading via HTTPS.'); - $scheme = 'tls://'; - if ($port == 0 || $port == 80) $port = 443; - } else if ($port == 0) $port = 80; - if (!empty($referer) && ($pos = strpos("\r\n", $referer)) !== 0) { - $origin = parse_url($pos ? substr($referer, 0, $pos) : $referer); - $origin = strtolower($origin['scheme']) . '://' . strtolower($origin['host']) . (!empty($origin['port']) && $origin['port'] != defport(array('scheme' => $origin['scheme'])) ? ':' . $origin['port'] : ''); - } else $origin = ($scheme == 'tls://' ? 'https://' : $scheme) . $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : ''); - if ($proxy) { - list($proxyHost, $proxyPort) = explode(':', $proxy, 2); - if ($scheme != 'tls://') { - $host = $host . ($port != 80 && $port != 443 ? ":$port" : ''); - $url = "$scheme$host$url"; - } - } - if ($scheme != 'tls://') $scheme = ''; - $cHeaders = readCustomHeaders($referer); - $request = array(); - $request[''] = 'POST ' . str_replace(' ', '%20', $url) . ' HTTP/1.1'; - - $request['Content-Type'] = "multipart/mixed; boundary=$bound"; - $request['User-Agent'] = $upagent; - $request['Pragma'] = 'no-cache'; - $request['Cache-Control'] = 'no-cache'; - $request['Host'] = $host.':'.$port; - - if (!empty($pauth) && !$scheme) $request['proxy-authorization'] = "Basic $pauth"; - $request['content-length'] = (strlen($postdata) + strlen($nn . "--" . $bound . "--" . $nn) + $fileSize); - $request = headers2request(array_merge($request, $cHeaders), $postdata); - $errno = 0; - $errstr = ''; - if ($scheme == 'tls://') { - $hosts = (!empty($proxyHost) ? $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port); - if ($proxy) $url = "https://$host$url"; // For the 'connected to' message - } else $hosts = (!empty($proxyHost) ? $scheme . $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port); - $fp = @stream_socket_client($hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT); - if (!$fp) { - if (!function_exists('stream_socket_client')) return html_error('[ERROR] stream_socket_client() is disabled.'); - $dis_host = !empty($proxyHost) ? $proxyHost : $host; - $dis_port = !empty($proxyPort) ? $proxyPort : $port; - return html_error(sprintf(lang(88), $dis_host, $dis_port)); - } - if ($errno || $errstr) { - $lastError = $errstr; - return false; - } - if ($proxy) echo '

' . sprintf(lang(89), $proxyHost, $proxyPort) . '
UPLOAD: ' . htmlspecialchars($url) . "...
\n"; - else echo '

'.sprintf(lang(90), $host, $port).'

'; - if ($scheme == 'tls://' && $proxy) { - $connRequest = array(); - $connRequest[''] = "CONNECT $host:$port HTTP/1.1"; - if (!empty($pauth)) $connRequest['proxy-authorization'] = "Basic $pauth"; - $connRequest['proxy-connection'] = 'Close'; - $connRequest = headers2request($connRequest); - fwrite($fp, $connRequest); - fflush($fp); - $llen = 0; - $header = ''; - do { - $header .= fgets($fp, 16384); - $len = strlen($header); - if (!$header || $len == $llen) { - $lastError = 'No response from proxy after CONNECT.'; - stream_socket_shutdown($fp, STREAM_SHUT_RDWR); - fclose($fp); - return false; - } - $llen = $len; - } while (strpos($header, $nn . $nn) === false); - $status = intval(substr($header, 9, 3)); - if ($status != 200) { - return html_error("Proxy returned $status after CONNECT."); - } - // Start TLS. - if (!stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) return html_error('TLS Startup Error.'); - } - echo(lang(104) . ' ' . htmlspecialchars($filename) . ', ' . lang(56) . ' ' . bytesToKbOrMbOrGb($fileSize) . '...
'); - $GLOBALS['id'] = md5(time() * rand(0, 10)); - require (TEMPLATE_DIR . '/uploadui.php'); - flush(); - fwrite($fp, $request); - fflush($fp); - $timeStart = microtime(true); - $chunkSize = GetChunkSize($fileSize); - $fs = fopen($file, 'r'); - $totalsend = $time = $lastChunkTime = 0; - while (!feof($fs) && !$errno && !$errstr) { - $data = fread($fs, $chunkSize); - if ($data === false) { - fclose($fs); - fclose($fp); - return html_error(lang(112)); - } - $sendbyte = @fwrite($fp, $data); - fflush($fp); - if ($sendbyte === false || strlen($data) > $sendbyte) { - fclose($fs); - fclose($fp); - return html_error(lang(113)); - } - $totalsend += $sendbyte; - $time = microtime(true) - $timeStart; - $chunkTime = $time - $lastChunkTime; - $chunkTime = $chunkTime ? $chunkTime : 1; - $chunkTime = ($chunkTime > 0) ? $chunkTime : 1; - $lastChunkTime = $time; - $speed = round($sendbyte / 1024 / $chunkTime, 2); - $percent = round($totalsend / $fileSize * 100, 2); - echo "\n"; - flush(); - } - if ($errno || $errstr) { - $lastError = $errstr; - return false; - } - fclose($fs); - fwrite($fp, $nn . "--" . $bound . "--" . $nn); - fflush($fp); - $llen = 0; - $header = ''; - do { - $header .= fgets($fp, 16384); - $len = strlen($header); - if (!$header || $len == $llen) { - $lastError = lang(91); - stream_socket_shutdown($fp, STREAM_SHUT_RDWR); - fclose($fp); - return false; - } - $llen = $len; - } while (strpos($header, $nn . $nn) === false); - // Array for active stream filters - $sFilters = array(); - if (stripos($header, "\nTransfer-Encoding: chunked") !== false && in_array('dechunk', stream_get_filters())) $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ); // Add built-in dechunk filter - $length = trim(cut_str($header, "\nContent-Length: ", "\n")); - if (!$length || !is_numeric($length)) $length = -1; - $page = stream_get_contents($fp, $length); - stream_socket_shutdown($fp, STREAM_SHUT_RDWR); - fclose($fp); - if (empty($sFilters['dechunk']) && stripos($header, "\nTransfer-Encoding: chunked") !== false && function_exists('http_chunked_decode')) { - $dechunked = http_chunked_decode($page); - if ($dechunked !== false) $page = $dechunked; - unset($dechunked); - } - if (stripos($header, "\nContent-Encoding: gzip") !== false) { - $decompressed = gzinflate(substr($page, 10)); - if ($decompressed !== false) $page = $decompressed; - unset($decompressed); - } else if (stripos($header, "\nContent-Encoding: deflate") !== false) { - $decompressed = gzinflate(in_array(substr($page, 0, 2), array("x\x01", "x\x9C", "x\xDA")) ? substr($page, 2) : $page); - if ($decompressed !== false) $page = $decompressed; - unset($decompressed); - } - $page = $header.$page; - return $page; -} - - // tech - Written in 26/11/2016 ?>