<?phpclass Lcache {
var $bufferFileName;
var $en;
var $content;
var $limitTime; function Lcache($LimitTime="600") {
$this->bufferFileName = basename($_SERVER['PHP_SELF'],".php").".buf";
$this->limitTime = $LimitTime;
} function Start() {
if (!file_exists($this->bufferFileName) || (int)date(time()-@filemtime($this->bufferFileName))>$this->limitTime) {
$this->en = true; // 尚未缓存或已超时
ob_start();
} else {
$this->readBuf();
$this->out();
exit;
}
} function readBuf() {
$fp = fopen($this->bufferFileName,"r");
$this->content = fread($fp,filesize($this->bufferFileName));
} function get() {
$this->content = ob_get_contents();
ob_clean();
} function bufferTo() {
$fp = fopen($this->bufferFileName,"w");
fputs($fp,$this->content);
fclose($fp);
} function out() {
if ($this->en) {
$this->get();
$this->bufferTo();
}
echo $this->content;
}
}
?>
var $bufferFileName;
var $en;
var $content;
var $limitTime; function Lcache($LimitTime="600") {
$this->bufferFileName = basename($_SERVER['PHP_SELF'],".php").".buf";
$this->limitTime = $LimitTime;
} function Start() {
if (!file_exists($this->bufferFileName) || (int)date(time()-@filemtime($this->bufferFileName))>$this->limitTime) {
$this->en = true; // 尚未缓存或已超时
ob_start();
} else {
$this->readBuf();
$this->out();
exit;
}
} function readBuf() {
$fp = fopen($this->bufferFileName,"r");
$this->content = fread($fp,filesize($this->bufferFileName));
} function get() {
$this->content = ob_get_contents();
ob_clean();
} function bufferTo() {
$fp = fopen($this->bufferFileName,"w");
fputs($fp,$this->content);
fclose($fp);
} function out() {
if ($this->en) {
$this->get();
$this->bufferTo();
}
echo $this->content;
}
}
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货