📄 gzip_compression.php
字号:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license@zen-cart.com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: gzip_compression.php 1969 2005-09-13 06:57:21Z drbyte $
//
function zen_check_gzip() {
if (headers_sent() || connection_aborted()) {
return false;
}
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) return 'x-gzip';
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false) return 'gzip';
return false;
}
/* $level = compression level 0-9, 0=none, 9=max */
function zen_gzip_output($level = GZIP_LEVEL) {
if ($encoding = zen_check_gzip()) {
$contents = ob_get_contents();
ob_end_clean();
header('Content-Encoding: ' . $encoding);
$size = strlen($contents);
$crc = crc32($contents);
$contents = gzcompress($contents, $level);
$contents = substr($contents, 0, strlen($contents) - 4);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $contents;
echo pack('V', $crc);
echo pack('V', $size);
} else {
ob_end_flush();
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -