php代码
XYCMS(PHP版)企业建站系统是XYCMS工作室推出的一套通用的企业建站软件系统。XYCMS企业建站系统是专业从事企业网站制作与设计服务,已有四年工作经验,网站系统方便、简洁、容易上手。所设计的版本分为动态版和静态版,比起市场上同类系统,性价比还是很高的,在企业网站建设行业里拥有丰富的经验,并在业界取得好评。 更新日志:1.后台简单特殊字符替换XYCMS(PHP版) 软件的安装:1. 上传 u
0
cache_root=dirname(__FILE__).'/../cache';//缓存存放目录
$this->file_dir=$file_dir;
$this->cache_time=$cache_time;
$this->file_two=$file_two;
$this->file_fix=$file_fix;
$this->file_name=md5($_SERVER['REQUEST_URI']).$this->file_fix;//缓存文件名
$this->cache_file=$this->cache_dir=$this->cache_root.'/'.$this->file_dir;//缓存的二级文件夹
if($this->file_two==1)$this->cache_dir=$this->cache_root.'/'.$this->file_dir.'/'.substr($this->file_name,0,2);//缓存的最终文件夹
$this->cache_url=$this->cache_dir.'/'.$this->file_name;//文件存放的完整路径
//GET方式请求才缓存,POST之后一般都希望看到最新的结果
if($_SERVER['REQUEST_METHOD']=='GET'){
//如果缓存文件存在,并且没有过期,就把它读出来。
if(file_exists($this->cache_url) && time()-filemtime($this->cache_url)cache_time){
$fp=fopen($this->cache_url,'rb');
fpassthru($fp);
fclose($fp);
exit;
}elseif(!file_exists($this->cache_dir)){//判断文件夹是否存在,不存在则创建
if(!file_exists($this->cache_file)){
if(!file_exists($this->cache_root)){
mkdir($this->cache_root,0777);
chmod($this->cache_root,0777);
}
mkdir($this->cache_file,0777);
chmod($this->cache_file,0777);
if($this->file_two==1){
mkdir($this->cache_dir,0777);
chmod($this->cache_dir,0777);
}
}
}
//回调函数 AutoCache
//ob_start("AutoCache");
ob_start(array($this, "AutoCache"));
}else{
//不是GET的请求就删除缓存文件
if(file_exists($this->cache_url))unlink($this->cache_url);
}
}
function AutoCache($contents){
$fp=fopen($this->cache_url,'wb');
fwrite($fp,$contents);
fclose($fp);
chmod($this->cache_url,0777);
//生成新缓存的同时,自动删除所有的老缓存,以节约空间,可忽略。
$this->DelOldCache();
return $contents;
}
function DelOldCache(){
chdir($this->cache_root);
foreach (glob("*/*".$this->file_fix) as $file){
if(time()-filemtime($file)>$this->cache_time)unlink($file);
}
}
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号