Bug #16772 » 0004623_v2_w.patch
t3lib/class.gzip_encode.php (Arbeitskopie) | ||
---|---|---|
*
|
||
* Changes compared to the upstream version:
|
||
*
|
||
* 2007-03-27 Oliver Hader <oh@inpublica.de>
|
||
* - Fixed bug #4623: Content encoding with x-gzip not allowed
|
||
* - Fixed missing comments and line formats (cleaner)
|
||
* 2005-12-09 Peter Niederlag <peter@niederlag.de>
|
||
* - Fixed bug #1976: PHP5 type-conversion of string 'true' and boolean
|
||
*
|
||
... | ... | |
*
|
||
* @author Sandy McArthur, Jr. <leknor@leknor.com>
|
||
*/
|
||
/**
|
||
* [CLASS/FUNCTION INDEX of SCRIPT]
|
||
*
|
||
*
|
||
*
|
||
* 53: class gzip_encode
|
||
* 193: function gzip_encode($level = 3, $debug=false, $outputCompressedSizes=false)
|
||
* 268: function gzip_accepted()
|
||
* 317: function get_complevel()
|
||
* 342: function linux_loadavg()
|
||
* 363: function freebsd_loadavg()
|
||
*
|
||
* TOTAL FUNCTIONS: 5
|
||
* (This index is automatically created/updated by the extension "extdeveval")
|
||
*
|
||
*/
|
||
/**
|
||
* gzip_encode - a class to gzip encode php output
|
||
*
|
||
* @author Sandy McArthur, Jr. <Leknor@Leknor.com>
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
class gzip_encode {
|
||
/*
|
||
/**
|
||
* gzip_encode - a class to gzip encode php output
|
||
*
|
||
* By Sandy McArthur, Jr. <Leknor@Leknor.com>
|
||
... | ... | |
var $size; // size of the uncompressed content
|
||
var $gzsize; // size of the compressed content
|
||
/*
|
||
/**
|
||
* gzip_encode constructor - gzip encodes the current output buffer
|
||
* if the browser supports it.
|
||
*
|
||
... | ... | |
* You can specify one of the following for the second argument:
|
||
* true: Don't actully output the compressed form but run as if it
|
||
* had. Used for debugging.
|
||
*
|
||
* @param integer $level: Define the level of compression between 0 (none) and 9 (best compression)
|
||
* @param boolean $debug: If true, no data will be outputted (default: false)
|
||
* @param boolean $outputCompressedSizes: If true, the original and compressed size appended as HTML (default: false)
|
||
* @return void
|
||
*/
|
||
function gzip_encode($level = 3, $debug = false, $outputCompressedSizes=0) {
|
||
function gzip_encode($level = 3, $debug=false, $outputCompressedSizes=false) {
|
||
if (!function_exists('gzcompress')) {
|
||
trigger_error('gzcompress not found, ' .
|
||
'zlib needs to be installed for gzip_encode',
|
||
... | ... | |
}
|
||
/*
|
||
/**
|
||
* gzip_accepted() - Test headers for Accept-Encoding: gzip
|
||
*
|
||
* Returns: if proper headers aren't found: false
|
||
* if proper headers are found: 'gzip' or 'x-gzip'
|
||
*
|
||
... | ... | |
* }
|
||
* note the double colon syntax, I don't know where it is documented but
|
||
* somehow it got in my brain.
|
||
*
|
||
* @return mixed Returns 'gzip' if the client browser accepts gzip encoding, otherwise false
|
||
*/
|
||
function gzip_accepted() {
|
||
if (strpos(getenv("HTTP_ACCEPT_ENCODING"), 'gzip') === false) return false;
|
||
if (strpos(getenv("HTTP_ACCEPT_ENCODING"), 'x-gzip') === false) {
|
||
// Checks, if the accepted encoding supports gzip or x-gzip.
|
||
// Furthermore a qvalue check is done. "gzip;q=0" means to gzip accepted at all.
|
||
$acceptEncoding = $GLOBALS['_SERVER']['HTTP_ACCEPT_ENCODING'];
|
||
if (preg_match('/(^|,\s*)(x-)?gzip(;q=(\d(\.\d+)?))?(,|$)/', $acceptEncoding, $match) && ($match[4] === '' || $match[4] > 0)) {
|
||
$encoding = 'gzip';
|
||
} else {
|
||
$encoding = 'x-gzip';
|
||
return false;
|
||
}
|
||
// Test file type. I wish I could get HTTP response headers.
|
||
... | ... | |
return $encoding;
|
||
}
|
||
/*
|
||
/**
|
||
* get_complevel() - The level of compression we should use.
|
||
*
|
||
* Returns an int between 0 and 9 inclusive.
|
||
... | ... | |
*
|
||
* Help: if you use an OS other then linux please send me code to make
|
||
* this work with your OS - Thanks
|
||
*
|
||
* @return integer Suggests a level of compression (0..9) for the current situation
|
||
*/
|
||
function get_complevel() {
|
||
$uname = posix_uname();
|
||
... | ... | |
return $level;
|
||
}
|
||
/*
|
||
/**
|
||
* linux_loadavg() - Gets the max() system load average from /proc/loadavg
|
||
*
|
||
* The max() Load Average will be returned
|
||
*
|
||
* @return float Returns the current load average
|
||
*/
|
||
function linux_loadavg() {
|
||
$buffer = "0 0 0";
|
||
... | ... | |
return max((float)$load[0], (float)$load[1], (float)$load[2]);
|
||
}
|
||
/*
|
||
/**
|
||
* freebsd_loadavg() - Gets the max() system load average from uname(1)
|
||
*
|
||
* The max() Load Average will be returned
|
||
*
|
||
* I've been told the code below will work on solaris too, anyone wanna
|
||
* test it?
|
||
*
|
||
* @return float Returns the current load average
|
||
*/
|
||
function freebsd_loadavg() {
|
||
$buffer= `uptime`;
|
- « Previous
- 1
- 2
- 3
- 4
- Next »