100高分请教了!!!解决后马上给分!!!急!!!
神鹰 2002-02-23 07:02:10 我这段加速页面传输的PHP代码,执行后为什么总是出现文件下载?解决后马上给分
<?
ob_start();
ob_implicit_flush (0);
function CompressPage () { //页面压缩
global $HTTP_ACCEPT_ENCODING;
if (strpos(' '.$HTTP_ACCEPT_ENCODING, 'gzip') && function_exists('gzcompress')) {
if (strpos(' '.$HTTP_ACCEPT_ENCODING, 'x-gzip')) {
$ENCODING = 'x-gzip';
} else $ENCODING = 'gzip';
} else $ENCODING = 0;
if ($ENCODING) {
print '<!-- CompressPage '.$ENCODING.' -->';
$contents = ob_get_contents(); ob_end_clean();
header("Content-Encoding: $ENCODING");
$size = strlen($contents);
$crc = crc32($contents);
$contents = gzcompress ($contents);
$contents = substr($contents, 0, strlen($contents)-4);
print pack('cccccccc',0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00); //print "\x1f\x8b\x08\x00\x00\x00\x00\x00";
print $contents;
print pack('V',$crc);
print pack('V',$size);
} else ob_end_flush();
}
print "<html>
<head>
<title>Test</title>
<META http-equiv=Content-Type content='text/html; charset=gb2312'>
</head>
<body>
OK!
</body>
</html>";
CompressPage();
?>