00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2010 Dmitry Dulepov <dmitry@typo3.org> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * This class contains compression functions for the TYPO3 Frontend. It can be 00027 * used only in EXT:cms/tslib/index_ts.php 00028 * 00029 * $Id: class.tslib_fecompression.php 7905 2010-06-13 14:42:33Z ohader $ 00030 * 00031 * @author Dmitry Dulepov <dmitry@typo3.org> 00032 * @package TYPO3 00033 * @subpackage tx_cms 00034 */ 00035 class tslib_fecompression implements t3lib_Singleton { 00036 00037 /** 00038 * Accumulates content length for the compressed content. It is necessary to 00039 * replace the Content-length HTTP header after compression if it was added 00040 * by TYPO3 before compression. 00041 * 00042 * @var int 00043 */ 00044 protected $contentLength = 0; 00045 00046 /** 00047 * Corrects HTTP "Content-length" header if it was sent by TYPO3 and compression 00048 * is enabled. 00049 * 00050 * @param string $outputBuffer Output buffer to compress 00051 * @param int $mode One of PHP_OUTPUT_HANDLER_xxx contants 00052 * @return string Compressed string 00053 * @see ob_start() 00054 * @see ob_gzhandler() 00055 */ 00056 function compressionOutputHandler($outputBuffer, $mode) { 00057 // Compress the content 00058 $outputBuffer = ob_gzhandler($outputBuffer, $mode); 00059 if ($outputBuffer !== false) { 00060 // Save compressed size 00061 $this->contentLength += strlen($outputBuffer); 00062 00063 // Check if this was the last content chunk 00064 if (0 != ($mode & PHP_OUTPUT_HANDLER_END)) { 00065 // Check if we have content-length header 00066 foreach (headers_list() as $header) { 00067 if (0 == strncasecmp('Content-length:', $header, 15)) { 00068 header('Content-length: ' . $this->contentLength); 00069 break; 00070 } 00071 } 00072 } 00073 } 00074 return $outputBuffer; 00075 } 00076 } 00077 00078 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/tslib/class.tslib_fecompression.php']) { 00079 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/tslib/class.tslib_fecompression.php']); 00080 } 00081 00082 ?>
1.4.7