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.

109 lines
3.6 KiB

​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. class GZ{
  3. var $URL;
  4. var $CachePath;
  5. var $isCached=false;
  6. var $Prefetch;
  7. function __construct($cache_path=''){
  8. $this->SetCacheDir($cache_path);
  9. if($this->isCached){
  10. $this->URL=$_SERVER['REQUEST_URI'];
  11. $UMD5=md5($this->URL);
  12. $this->Prefetch=$this->CachePath.'/obchache_'.$UMD5;
  13. 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/'){
  14. if ( (time()- filemtime($this->Prefetch))<360){
  15. $HTTP_ACCEPT_ENCODING=apache_getenv('HTTP_ACCEPT_ENCODING');
  16. if( headers_sent() ){
  17. $encoding = false;
  18. }elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
  19. $encoding = 'x-gzip';
  20. }elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
  21. $encoding = 'gzip';
  22. }else{
  23. $encoding = false;
  24. };
  25. $FData=file_get_contents($this->Prefetch);
  26. $contents = unserialize($FData);
  27. if( $encoding ){
  28. header('Content-Encoding: '.$encoding);
  29. print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
  30. print($contents);
  31. } else print(gzuncompress($contents));
  32. exit();
  33. } else unlink($this->Prefeth);
  34. };
  35. };
  36. ob_start();
  37. ob_implicit_flush(false);
  38. }
  39. function OUTPUT() {
  40. $HTTP_ACCEPT_ENCODING=apache_getenv('HTTP_ACCEPT_ENCODING');
  41. if( headers_sent() ){
  42. $encoding = false;
  43. }elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
  44. $encoding = 'x-gzip';
  45. }elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
  46. $encoding = 'gzip';
  47. }else{
  48. $encoding = false;
  49. }
  50. if( $encoding ){
  51. $contents = ob_get_contents();
  52. ob_end_clean();
  53. header('Content-Encoding: '.$encoding);
  54. print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
  55. //echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
  56. $size = strlen($contents);
  57. $Ocontents = gzcompress($contents, 9);
  58. //$contents = substr($contents, 0, $size);
  59. print($Ocontents);
  60. } else {
  61. $contents = ob_get_contents();
  62. ob_end_flush();
  63. };
  64. if ($this->isCached){
  65. $Zcontents=gzcompress($contents, 9);
  66. $FData=serialize($Zcontents);
  67. $FD=fopen($this->Prefetch,'w');
  68. fwrite($FD,$FData);
  69. fclose($FD);
  70. };
  71. exit();
  72. }
  73. function CleanUpCache(){
  74. if ($DD=@opendir($this->CachePath)){
  75. while($FN=readdir($DD)){
  76. $CF=$this->CachePath.'/'.$FN;
  77. if (is_file($CF)){
  78. if ( strstr($FN,'dbchache_') && (time()-filemtime($CF))>360){
  79. @unlink($CF);
  80. };
  81. };
  82. };
  83. closedir($DD);
  84. } else $this->isCached=false;
  85. }
  86. function ResetCache(){
  87. if ($DD=@opendir($this->CachePath)){
  88. while($FN=readdir($DD)){
  89. $CF=$this->CachePath.'/'.$FN;
  90. if (is_file($CF)){
  91. if ( strstr($FN,'obchache_')){
  92. @unlink($CF);
  93. };
  94. };
  95. };
  96. closedir($DD);
  97. } else $this->isCached=false;
  98. }
  99. function SetCacheDir($Path){
  100. if ($Path!=''){
  101. $this->CachePath = $Path;
  102. $this->isCached = is_dir($this->CachePath) && is_writable($this->CachePath);
  103. if ($this->isCached) $this->CleanUpCache();
  104. };
  105. }
  106. };
  107. ?>