You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.6 KiB
110 lines
3.6 KiB
<?php
|
|
class GZ{
|
|
var $URL;
|
|
var $CachePath;
|
|
var $isCached=false;
|
|
var $Prefetch;
|
|
function GZ($cache_path=''){
|
|
$this->SetCacheDir($cache_path);
|
|
if($this->isCached){
|
|
$this->URL=$_SERVER['REQUEST_URI'];
|
|
$UMD5=md5($this->URL);
|
|
$this->Prefetch=$this->CachePath.'/obchache_'.$UMD5;
|
|
if ( is_file($this->Prefetch) && $this->URL!=='/' && $this->URL!=='/index.php?logout=1' && $this->URL!=='/index.php' && $this->URL!=='/escorts-SO1!O-Page-1!P.html?ub=1&snc=1' && $this->URL!=='www.vicesisters.com/'){
|
|
if ( (time()- filemtime($this->Prefetch))<360){
|
|
$HTTP_ACCEPT_ENCODING=apache_getenv('HTTP_ACCEPT_ENCODING');
|
|
if( headers_sent() ){
|
|
$encoding = false;
|
|
}elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
|
|
$encoding = 'x-gzip';
|
|
}elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
|
|
$encoding = 'gzip';
|
|
}else{
|
|
$encoding = false;
|
|
};
|
|
$FData=file_get_contents($this->Prefetch);
|
|
$contents = unserialize($FData);
|
|
if( $encoding ){
|
|
header('Content-Encoding: '.$encoding);
|
|
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
|
|
print($contents);
|
|
} else print(gzuncompress($contents));
|
|
exit();
|
|
} else unlink($this->Prefeth);
|
|
};
|
|
};
|
|
ob_start();
|
|
ob_implicit_flush(false);
|
|
}
|
|
function OUTPUT() {
|
|
$HTTP_ACCEPT_ENCODING=apache_getenv('HTTP_ACCEPT_ENCODING');
|
|
if( headers_sent() ){
|
|
$encoding = false;
|
|
}elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
|
|
$encoding = 'x-gzip';
|
|
}elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
|
|
$encoding = 'gzip';
|
|
}else{
|
|
$encoding = false;
|
|
}
|
|
if( $encoding ){
|
|
$contents = ob_get_contents();
|
|
ob_end_clean();
|
|
header('Content-Encoding: '.$encoding);
|
|
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
|
|
//echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
|
|
|
|
$size = strlen($contents);
|
|
$Ocontents = gzcompress($contents, 9);
|
|
//$contents = substr($contents, 0, $size);
|
|
print($Ocontents);
|
|
} else {
|
|
$contents = ob_get_contents();
|
|
ob_end_flush();
|
|
};
|
|
if ($this->isCached){
|
|
$Zcontents=gzcompress($contents, 9);
|
|
$FData=serialize($Zcontents);
|
|
$FD=fopen($this->Prefetch,'w');
|
|
fwrite($FD,$FData);
|
|
fclose($FD);
|
|
};
|
|
exit();
|
|
}
|
|
function CleanUpCache(){
|
|
if ($DD=@opendir($this->CachePath)){
|
|
while($FN=readdir($DD)){
|
|
$CF=$this->CachePath.'/'.$FN;
|
|
if (is_file($CF)){
|
|
if ( strstr($FN,'dbchache_') && (time()-filemtime($CF))>360){
|
|
@unlink($CF);
|
|
};
|
|
};
|
|
};
|
|
closedir($DD);
|
|
} else $this->isCached=false;
|
|
}
|
|
function ResetCache(){
|
|
if ($DD=@opendir($this->CachePath)){
|
|
while($FN=readdir($DD)){
|
|
$CF=$this->CachePath.'/'.$FN;
|
|
if (is_file($CF)){
|
|
if ( strstr($FN,'obchache_')){
|
|
@unlink($CF);
|
|
};
|
|
};
|
|
};
|
|
closedir($DD);
|
|
} else $this->isCached=false;
|
|
}
|
|
function SetCacheDir($Path){
|
|
if ($Path!=''){
|
|
$this->CachePath = $Path;
|
|
$this->isCached = is_dir($this->CachePath) && is_writable($this->CachePath);
|
|
if ($this->isCached) $this->CleanUpCache();
|
|
};
|
|
}
|
|
};
|
|
|
|
|
|
?>
|