复制代码 代码如下:<?php
class Shtml
{
var $Templet;
var $DataSource;
var $Dir;
var $fileName;
var $mod;
var $handle;
function Shtml($fileName="")
{
$this->fileName=$fileName;
$this->mod="wb";
$this->handle=false;
$this->Templet = "";
$this->DataSource = array();
$this->Dir = "";
}
/// <描述>
/// 绑定数据源,参数为一数组。
/// </描述>
function BindData($arr)
{
$this->DataSource = $arr;
}
/// <描述>
/// 设置文件存放路径。
/// </描述>
function SetDir($dir)
{
$this->Dir = $dir;
}
function SetFileName($fileName)
{
return $this->fileName=$fileName;
}
function GetMod()
{
return $this->mod;
}
function SetMod($mod)
{
return $this->mod=$mod;
}
function Open()
{
if(substr($this->fileName,0,1)=="/")
$this->fileName = $_SERVER['DOCUMENT_ROOT'] . $this->fileName;
if($this->handle=fopen($this->fileName, $this->mod))
return $this->handle;
else
return false;
}
function Close()
{
return fclose($this->handle);
}
function Write($content)
{
return fwrite($this->handle,$content);
}
function MkDir($pathname)
{
$currentPath="";
str_replace("\","/",$pathname);
$pathArr = split("/",$pathname);
if($pathArr[0] == "") //使用绝对路径
{
$currentPath = $_SERVER['DOCUMENT_ROOT'];
}
else
{
$currentPath = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']);
}
for($i=0; $i<count($pathArr); $i++)
{
if($pathArr[$i]=="")
continue;
else
if(is_dir($currentPath . "/" . $pathArr[$i]))
$currentPath = $currentPath . "/" . $pathArr[$i];
else
mkdir($currentPath = $currentPath . "/" . $pathArr[$i]);
}
}
/// <描述>
/// 生成静态文件。
/// </描述>
function Create()
{
$tmp = $this->Templet;
foreach($this->DataSource as $key=>$value)
{
$tmp = str_replace("<FIELD_" . $key . ">", $value, $tmp);
}
$this->MkDir(dirname($this->fileName));
$this->Open();
$this->Write($tmp);
$this->Close();
}
}
function CreateShtml()
{
ob_start("callback_CteateShtml");
}
function callback_CteateShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$shtml = new Shtml();
$shtml->SetFileName($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm");
$shtml->Templet = $buffer;
$shtml->Create();
return $buffer;
}
?>
PHP静态类
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 周华健.2015-水浒三部曲原创音乐选辑【滚石】【FLAC分轨】
- 钟志刚《为爱而歌DSD》[WAV+CUE]
- 孙露《情人的眼泪》[低速原抓WAV+CUE]
- 【雨果唱片】刘明源《胡琴专辑》1993[WAV+CUE]
- 黄莺莺《25周年纪念金曲专辑》[WAV+CUE][1.1G]
- 刘德丽《刘德丽新曲+精选》2023[WAV+CUE][1G]
- 潘美辰《鹰与月》双语专辑[WAV+CUE][1G]
- 梁咏琪.2007-女色新曲+精选2CD【华纳】【WAV+CUE】
- 黎亚.2006-我不在巴黎【星外星】【FLAC分轨】
- 陈洁仪.1994-心痛【立得唱片】【WAV+CUE】
- 车载必备专用超级选曲《劲爆中文DJ》2CD[WAV+CUE]
- 群星《民歌流淌60年(黑胶CD)》2CD[WAV+分轨]
- 群星《美丽时光》紫银合金AQCD[WAV+CUE]
- 群星《12大巨星畅销精选集》[WAV分轨][1.1G]
- 华语排行冠军曲《百事音乐风云榜》[WAV+CUE][1G]