All pastes #37482 Raw Edit

Unnamed

public php v1 · immutable
#37482 ·published 2006-01-19 22:42 UTC
rendered paste body
<?php    // {{{ compressText($output)    /**     * Fetch gzipped output     *     * @author Koistya Navin <navin@php.net>     * @author David Coallier <davidc@php.net>     * @author Marek Kuziel <marek@kuziel.info>     * @param  string     * @access private     */    private function compressText($output)    {        $encoding = false;        if (function_exists('crc32') && function_exists('gzcompress')) {            if (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) {                $encoding = 'x-gzip';            }            if (strpos(' ' . $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {                $encoding = 'gzip';            }            if ($encoding) {                @header('Content-Encoding: ' . $encoding);                if (function_exists('gzencode')) {                    $output = gzencode($output, intval($this->gzip));                } else {                    $output = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff" .                              substr(gzcompress($output, $level), 2, -4) .                              pack('V', crc32($output)) . pack('V', strlen($output));                }            }        } else {            return new XML_Feed_Writer_Exception("Error: compress methods (crc32, gzcompress) are not available!");        }        return $output;    }    // }}}    // -- then later..    try {        $object->compressText(...);    } catch (XML_Feed_Writer_Exception $e) {        XML_Feed_Writer_Exception::raiseError($e->getMessage());    }?>