选择显示字体大小

使用 php 4 加速 web 传输


   <?
/***************************************
** title.........: php4 http compression speeds up the web
** version.......: 1.10
** author........: catoc <catoc@163.net>
** 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) <catoc@163.net>
**                 most newer browsers since 1998/1999 have
**                 been equipped to support the http 1.1
**                 standard known as &quot;content-encoding.&quot;
**                 essentially the browser indicates to the
**                 server that it can accept &quot;content encoding&quot;
**                 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 &#39;<?&#39; tag.
**                 ------------start of file----------
**                 <?
**                  include(&#39;gzdoc.php&#39;);
**                  print &quot;start output !!&quot;;
**                 ?>
**                 <html>
**                 ... the page ...
**                 </html>
**                 <?
**                  gzdocout();
**                 ?>
**                 -------------end of file-----------
***************************************/
ob_start();
ob_implicit_flush(0);
function getheader(){
    &#36;headers = getallheaders();
    while (list(&#36;header, &#36;value) = each(&#36;headers)) {
        &#36;message .= &quot;&#36;header: &#36;value<br>\n&quot;;
    }
    return &#36;message;
}
function checkcangzip(){
    global &#36;http_accept_encoding, &#36;php_self, &#36;wget, &#36;remote_addr, &#36;s_username;
    if (connection_timeout() connection_aborted()){
        return 0;
    }
    if ((strpos(&#39;catoc&#39;.&#36;http_accept_encoding, &#39;gzip&#39;)) &#36;wget == &#39;y&#39;){
        if (strpos(&#39;catoc&#39;.&#36;http_accept_encoding, &#39;x-gzip&#39;)){
            &#36;encoding = &quot;x-gzip&quot;;
            &#36;error_msg = str_replace(&#39;<br>&#39;,&#39;&#39;,getheader());
            &#36;error_msg .= &quot;time: &quot;.date(&quot;y-m-d h:i:s&quot;).&quot;\n&quot;;
            &#36;error_msg .= &quot;remote-address: &quot;.&#36;remote_addr.&quot;\n&quot;;
            //mail(&#39;your@none.net&#39;, &quot;user have x-gzip output in file &#36;php_self!!!&quot;, &#36;error_msg);
        }else{
            &#36;encoding = &quot;gzip&quot;;
        }
        return &#36;encoding;
    }else{
        return 0;
    }
}
function gzdocout(){
    global &#36;php_self, &#36;catocgz, &#36;remote_addr, &#36;s_username;
    &#36;encoding = checkcangzip();
    if (&#36;encoding){
        print &quot;\n<!-- use compress &#36;encoding -->\n&quot;;
        &#36;contents = ob_get_contents();
        ob_end_clean();
        if (&#36;catocgz == &#39;y&#39;){
            print &quot;not compress lenth: &quot;.strlen(&#36;contents).&quot;<br>&quot;;
            print &quot;compressed lenth: &quot;.strlen(gzcompress(&#36;contents)).&quot;<br>&quot;;
            exit;
        }else{
            header(&quot;content-encoding: &#36;encoding&quot;);
        }
        print pack(&#39;cccccccc&#39;,0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00);
        &#36;size = strlen(&#36;contents);
        &#36;crc = crc32(&#36;contents);
        &#36;contents = gzcompress(&#36;contents);
        &#36;contents = substr(&#36;contents, 0, strlen(&#36;contents) - 4);
        print &#36;contents;
        print pack(&#39;v&#39;,&#36;crc);
        print pack(&#39;v&#39;,&#36;size);
        exit;
    }else{
        ob_end_flush();
        &#36;error_msg = str_replace(&#39;<br>&#39;,&#39;&#39;,getheader());
        &#36;error_msg .= &quot;time: &quot;.date(&quot;y-m-d h:i:s&quot;).&quot;\n&quot;;
        &#36;error_msg .= &quot;remote-address: &quot;.&#36;remote_addr.&quot;\n&quot;;
        //mail(&#39;your@none.net&#39;, &quot;user can not use gzip output in file &#36;php_self!!!&quot;, &#36;error_msg);
        exit;
    }
}
?> 


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons