国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

使用php4加速網絡傳輸

2024-05-04 23:00:58
字體:
來源:轉載
供稿:網友

商業源碼熱門下載www.html.org.cn

標 題: 使用php4加速網絡傳輸。

<?
/***************************************
** title.........: php4 http compression speeds up the web
** version.......: 1.10
** author........: catoc <[email protected]>
** filename......: gzdoc.php
** last changed..: 25/08/2000
** requirments...: php4 >= 4.0.1
**                 php was configured with --with-zlib[=dir]
** notes.........: dynamic content acceleration compresses
**                 the data transmission data on the fly
**                 code by sun jin hu (catoc) <[email protected]>
**                 most newer browsers since 1998/1999 have
**                 been equipped to support the http 1.1
**                 standard known as "content-encoding."
**                 essentially the browser indicates to the
**                 server that it can accept "content encoding"
**                 and if the server is capable it will then
**                 compress the data and transmit it. the
**                 browser decompresses it and then renders
**                 the page.
** useage........:
**                 no space before the beginning of the first '<?' tag
.
**                 ------------start of file----------
**                 |<?
**                 | include('gzdoc.php');
**                 | print "start output !!";
**                 |?>
**                 |<html>
**                 |... the page ...
**                 |</html>
**                 |<?
**                 | gzdocout();
**                 |?>
**                 -------------end of file-----------
***************************************/
ob_start();
ob_implicit_flush(0);
function getheader(){
        $headers = getallheaders();
        while (list($header, $value) = each($headers)) {
                $message .= "$header: $value<br> ";
        }
        return $message;
}
function checkcangzip(){
        global $http_accept_encoding, $php_self, $wget, $remote_addr,  
$s_username;
        if (connection_timeout() || connection_aborted()){
                return 0;
        }
        if ((strpos('catoc'.$http_accept_encoding, 'gzip')) || $wget =
= 'y'){
                if (strpos('catoc'.$http_accept_encoding, 'x-gzip')){

                        $encoding = "x-gzip";
                        $error_msg = str_replace('<br>','',getheader()
);
                        $error_msg .= "time: ".date("y-m-d h:i:s")."
";
                        $error_msg .= "remote-address: ".$remote_addr.
" ";
                        //mail('[email protected]', "user have x-gzip outp
ut in file $php_self!!!", $error_msg);
                }else{
                        $encoding = "gzip";
                }
                return $encoding;
        }else{
                return 0;
        }
}
function gzdocout(){
        global $php_self, $catocgz, $remote_addr, $s_username;
        $encoding = checkcangzip();
        if ($encoding){
                print " <!-- use compress $encoding --> ";
                $contents = ob_get_contents();
                ob_end_clean();
                if ($catocgz == 'y'){
                        print "not compress lenth: ".strlen($contents)
."<br>";
                        print "compressed lenth: ".strlen(gzcompress($
contents))."<br>";
                        exit;
                }else{
                        header("content-encoding: $encoding");
                }
                print pack('cccccccc',0x1f,0x8b,0x08,0x00,0x00,0x00,0x
00,0x00);
                $size = strlen($contents);
                $crc = crc32($contents);
                $contents = gzcompress($contents);
                $contents = substr($contents, 0, strlen($contents) - 4
);
                print $contents;
                print pack('v',$crc);
                print pack('v',$size);
                exit;
        }else{
                ob_end_flush();
                $error_msg = str_replace('<br>','',getheader());
                $error_msg .= "time: ".date("y-m-d h:i:s")." ";
                $error_msg .= "remote-address: ".$remote_addr." ";
                //mail('[email protected]', "user can not use gzip output  
in file $php_self!!!", $error_msg);
                exit;
        }
}
?>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和田县| 宁明县| 运城市| 靖远县| 陈巴尔虎旗| 松阳县| 青田县| 介休市| 若尔盖县| 铁岭市| 乌兰浩特市| 兰考县| 永康市| 中宁县| 徐汇区| 阿瓦提县| 柞水县| 九江县| 伊金霍洛旗| 铜陵市| 繁峙县| 基隆市| 安仁县| 莒南县| 宝山区| 胶南市| 邛崃市| 金湖县| 彭水| 樟树市| 儋州市| 东兴市| 大庆市| 宣汉县| 白山市| 江达县| 惠安县| 凉山| 土默特右旗| 东至县| 绵阳市|