Source for file OutputCompression.php
Documentation is available at OutputCompression.php 
// +----------------------------------------------------------------------+  
// +----------------------------------------------------------------------+  
// | Copyright (c) 1997-2003 The PHP Group                                |  
// +----------------------------------------------------------------------+  
// | This source file is subject to version 2.0 of the PHP license,       |  
// | that is bundled with this package in the file LICENSE, and is        |  
// | available at through the world-wide-web at                           |  
// | http://www.php.net/license/2_02.txt.                                 |  
// | If you did not receive a copy of the PHP license and are unable to   |  
// | obtain it through the world-wide-web, please send a note to          |  
// | license@php.net so we can mail you a copy immediately.               |  
// +----------------------------------------------------------------------+  
// | Authors: Ulf Wendel <ulf.wendel@phpdoc.de>                           |  
// |          Christian Stocker <chregu@phant.ch>                         |  
// +----------------------------------------------------------------------+  
require_once 'Cache/Output.php';   
* Cache using Output Buffering and contnet (gz) compression.  
*  // place this somewhere in a central config file  
*  define(CACHE_STORAGE_CLASS, 'file');  
*  // file storage needs a dir to put the cache files  
*  define(CACHE_DIR, '/var/tmp/');  
*  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array('cache_dir' => CACHE_DIR));  
*  if (!($content = $cache->start($cache->generateID($REQUEST_URI)))) {  
*    $cache->endPrint(+1000);  
*    $cache->printContent();  
*  if (($content = $cache->start($cache->generateID($REQUEST_URI)))) {  
*    $cache->printContent();  
*    $cache->endPrint(+1000);  
* Based upon a case study from Christian Stocker and inspired by jpcache.  
* @version  $Id: OutputCompression.php,v 1.9 2005/01/26 09:47:28 dufuz Exp $  
* @author   Ulf Wendel <ulf.wendel@phpdoc.de>, Christian Stocker <chregu@phant.ch>  
    * Encoding, what the user (its browser) of your website accepts  
    * "auto" stands for test using $_SERVER['HTTP_ACCEPT_ENCODING']($HTTP_ACCEPT_ENCODING).  
    * @see  Cache_OutputCompression(), setEncoding()  
    * Method used for compression  
    * Sets the storage details and the content encoding used (if not autodetection)  
    * @param    string  Name of container class  
    * @param    array   Array with container class options  
    * @param    string  content encoding mode - auto => test which encoding the user accepts  
        $this->Cache($container, $container_options);   
    * Call parent deconstructor.  
    function get($id, $group)  
            $this->content =  $this->load($id, $group);   
    * Stops the output buffering, saves it to the cache and returns the _compressed_ content.  
    * If you need the uncompressed content for further procession before  
    * it's saved in the cache use endGet(). endGet() does _not compress_.  
    function end($expire = 0 , $userdata =  '')  
    function endPrint($expire = 0 , $userdata =  '')  
    * Saves the given data to the cache.  
    function extSave($id, $cachedata, $userdata, $expires = 0 , $group =  'default')  
            $crc =  crc32($cachedata);   
            $this->content =  $cachedata;   
        return $this->container->save ($id, $this->content, $expires, $group, $userdata);   
    * Sends the compressed data to the user.  
        $server =  &$this->_importGlobalVariable ("server");   
            $etag =  '"PEAR-Cache-' .  md5(substr($content, -40 )) . '"';   
            if (isset ($server['HTTP_IF_NONE_MATCH']) &&  strstr(stripslashes($server['HTTP_IF_NONE_MATCH']), $etag)) {  
                // client acceppts some encoding - send headers & data  
                header('Vary: Accept-Encoding');  
                print "\x1f\x8b\x08\x00\x00\x00\x00\x00";  
    } // end func printContent  
    * Returns the encoding method of the current dataset.   
    * @return   string  Empty string (which evaluates to false) means no compression  
    } // end func isCompressed  
    * Sets the encoding to be used.  
    * @param    string  "auto" means autodetect for every client  
    function setEncoding($encoding = 'auto')  
    } // end func setEncoding  
    * Returns the encoding to be used for the data transmission to the client.  
        $server = &$this->_importGlobalVariable("server");  
        // check what the client accepts  
        if (false !== strpos($server['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {  
        if (false !== strpos($server['HTTP_ACCEPT_ENCODING'], 'gzip')) {  
    } // end func getEncoding  
    // {{{ _importGlobalVariable()  
     * Import variables from special namespaces.  
     * @param string Type of variable (server, session, post)  
    function &_importGlobalVariable($variable)   
                    $var = &$GLOBALS['HTTP_SERVER_VARS'];  
                    $var = &$GLOBALS['HTTP_SESSION_VARS'];  
                    $var = &$GLOBALS['HTTP_POST_VARS'];  
} // end class OutputCompression  
 
 
        
		    
 
		    Documentation generated on Mon, 11 Mar 2019 15:25:50 -0400 by  phpDocumentor 1.4.4. PEAR Logo Copyright ©  PHP Group 2004.
	        
       |