中国站长下载-为中国站长提供最好最全的建站资源! 首 页发布资源有事留言繁體中文
设为首页
加入收藏
联系我们
 
您当前的位置:中国站长下载 -> 文章中心 -> 网页编程 -> PHP编程 -> 文章内容  虚拟主机 域名注册 退出登录 用户管理
栏目导航
· ASP编程 · .NET编程
· PHP编程 · JSP编程
· CGI 专区
热门文章
· sndvol32 - sndvol3...
· [组图] FLASH:《大话李白》...
· 个人网站到底能赚多...
· [图文] Rundll.exe是病毒吗...
· [组图] Flash:制作MV
· 价值12万元的网站SE...
· 网站创业者,你需要...
· 一个成功的网站设计...
· [图文] FLASH:韩国导航条解...
· 中国网站的赚钱模式...
相关文章
· BS结构中使用PHP访问...
· 使用PHP 5.0 轻松解...
· 使用PHP 5.0 轻松解...
· 使用PHP 5.0 轻松解...
· 使用PHP 5.0 轻松解...
· 使用PHP编写基于Web...
· 使用PHP批量生成随机...
· 使用PHP往Windows系...
· 使用php重新实现PHP...
· 使用php重新实现PHP...
使用php4加速网络传输
作者:不详  来源:不详  发布时间:2006-8-14 11:06:37  发布人:chinazhan

 减小字体 增大字体

    
   来源:catoc
  
   <?
  /***************************************
  ** 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 "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('your@none.net', "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('your@none.net', "User can not use gzip output
  in file $PHP_SELF!!!", $Error_Msg);
  exit;
  }
  }
  ?>
  
  
  
  
    做人要厚道,请注明转自chinazhan中国站长(www.ChinaZhan.com)。

 
[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
中国站长下载
中国站长下载

本页只接受PR>=4 IT类站点连接,申请连接,谢谢您们的支持!希望我们的下载站能够真正帮到中国的站长们!
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图
Copyright © 2005-2006 ChinaZhan.Net. All Rights Reserved .