Sorry for my bad english! I'm russian!
You're excused, but try to get the word patches correct the next time, not' pathces --EvenHolen
This patch made your 'Tavi fast loading for viewers.
For gzip encoding you need make change:
$gzip_encoding = 1; // 1 enable gzip encoding, 0 disable;
in begin of script add:
require_once('lib/gzip.php');
then find:
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();
and replace with:
$contents = ob_get_contents();
ob_end_clean();
gzip_encode($contents);
<?php
function gzip_encode($page){
global $gzip_encoding;
if ($gzip_encoding==1){
if(phpversion() >= '4.0.4p11' && extension_loaded('zlib')){
ob_start("ob_gzhandler");
echo $page;
ob_end_flush();
}
else{
#####
# gzip encoding, this code from PWiki ( http://wiki.2gn.com/ )
global $HTTP_SERVER_VARS;
$HTTP_ACCEPT_ENCODING=$HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'];
if(function_exists(gzcompress)){
$pos=strpos ($HTTP_ACCEPT_ENCODING, 'gzip');
if ( $pos === false ){
$size=strlen($page);
header("Content-Length: $size");
echo $page;
return;
}
$pos=strpos ($HTTP_ACCEPT_ENCODING, 'x-gzip');
if ( $pos === false ) {
$encoding="gzip";
} else {
$encoding="x-gzip";
}
$gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
#####################################################################
$page .= '<!-- gziped -->'; // << you may remove this line. it's for debug info only.
#####################################################################
$size=strlen ($page);
$gzdata .= gzcompress ($page,5);
$crc = crc32($page);
$gzdata = substr($gzdata,0,strlen($gzdata) -4);
$gzdata .= pack("V",$crc).pack("V",$size);
Header('Content-Encoding: ' . $encoding);
Header('Content-Length: ' . strlen($gzdata));
echo $gzdata;
}
else{
$size=strlen($page);
header("Content-Length: $size");
echo $page;
}
#
#####
}
}
else{
$size=strlen($page);
header("Content-Length: $size");
echo $page;
}
}
That's all folks!
return to TaviPatches