⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xyp_webcache.inc.php

📁 音乐小偷,免维护版,,, ,,,功能强大
💻 PHP
字号:
<?
/*
	** 网页缓存类
	** 主要功能:1、把页面生成相html文件!
	2、可以设定缓存时间,辨断是否生成页面还是直接转到想应的html页面!
				 
	** coder by Yiping QQ:31996798 
	** 最后更新 2005-10-31 广州
*/
class XYP_WebCache
{
    var  $webHost; 
	var $FName;
	var $cacheTime; 		//默认缓存时间300秒,	
	# system set
	var $In_End = '_Out.php?';
	var $Ou_End = '.xml';	
	var $Cache_dir;			//cache的目录
	var $VarOrd1 =0;
	var $VarOrd2 =0;
	var $subDir=true;
	# system var
	var $FDate;
	var $In_FName;
	var $Out_FName;		
	
	function XYP_WebCache($webHost,$FName,$Cache_dir='cache/',$subDir=true,$cacheTime =156400)//156400
	{
		$this->webHost 		= $webHost;
		$this->In_FName 	= $FName;
		$this->cacheTime	= $cacheTime;
		$this->Cache_dir	= $Cache_dir;
		$this->subDir		= $subDir;
		$this->In_FName   	= $FName.$this->In_End.$this->GetSystemVar(1);
		$this->Out_FName   	= $FName.$this->GetSystemVar(0).$this->Ou_End;
		$this->GetOut_FName();
		$this->XYP_WebCache_start();
	}
	function XYP_ChkFolder($dir)
	{
		if(!file_exists($dir))
		{
			@mkdir($dir,0777);
		}
	}
	function GetVarOrd($str)
	{
		for ($i = 0; $i<strlen($str); $i++)
		{
			$this->VarOrd1 += ord($str{$i})*$i;  
			$this->VarOrd2 += ord($str{$i})*($i*2+1);			
		}	
		$this->VarOrd1 %= 30;	
		$this->VarOrd2 %= 30;		
		return str_replace("/","",base64_encode($str));
	}
	
	function GetOut_FName()
	{
		if($this->subDir)
		{
			$this->Cache_dir.=$this->VarOrd1;
			$this->XYP_ChkFolder($this->Cache_dir);
			$this->Cache_dir.='/'.$this->VarOrd2;
			$this->XYP_ChkFolder($this->Cache_dir);
			$this->Cache_dir.='/';
		}
		$this->Out_FName   	= $this->Cache_dir.$subDir_tmp.$this->Out_FName;
		return $this->Out_FName;
	}
	function GetSystemVar($oi)
	{
		foreach($_GET as $key => $value)
		{
			if($value)
			{
				$value2 =explode('@',$value);
				if(count($value2)>1)
				{
					$value2=$value2[1];
				}else
				{
					$value2=$value;
				}
				$C_SystemVar.=$oi?$key.'='.urlencode($value).'&':'K.'.$key.'_V.'.$this->GetVarOrd($value2);
			}
		}
		return $C_SystemVar;
	}
	function GetHtmlFile()
	{
		$this->FDate=@file_get_contents('http://'.$this->webHost.'/'.$this->In_FName);
		return $this->FDate;
	}	
	function writeToFile()
	{
		$fd=fopen($this->Out_FName.'.tmp','w');
		$this->FDate?'':$this->GetHtmlFile();
		//echo $this->FDate;
		fwrite($fd,$this->FDate);
		fclose($fd);
		
		//更新
		@unlink($this->Out_FName);
		rename($this->Out_FName.'.tmp' , $this->Out_FName);
	}
	function XYP_WebCache_start()
	{
		$fileMTime =@filemtime($this->Out_FName);
		$fileMSize =@filesize($this->Out_FName);
		$fileIs	   =file_exists($this->Out_FName.'.tmp');
		if($fileIs)
		{
			$fileIsMtime=filemtime($this->Out_FName.'.tmp');
			if($fileIsMtime<(time()-60) or  $fileIsMtime>time())
			{
				$fileIs =false;
			}
		}
		
		if(($fileMTime<(time()-$this->cacheTime) or $fileMSize<1024*5 or $fileMTime>time()) and !$fileIs)
		{
			$this->writeToFile();
		}
		//if(!$this->subDir)header("Location: ".$this->Out_FName);
		header("Location: ".$this->Out_FName);
		exit();
	}
}
//
//你的网址是什么就改什么  如我是http://123.com/mp3  不要http:// 我只要改成 ”http://123.com/mp3“就可以啦
$CHost  = 'http://www.qooqu.com/mp3';
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -