复制代码 代码如下:<?php
class html
{
var $dir; //dir for the htmls(without/)
var $rootdir; //root of html files(without/):html
var $name; //html文件存放路径
var $dirname; //指定的文件夹名称
var $url; //获取html文件信息的来源网页地址
var $time; //html文件信息填加时的时间
var $dirtype; //目录存放方式:year,month,,,,
var $nametype; //html文件命名方式:name
function html($nametype='name',$dirtype='year',$rootdir='html')
{
$this->setvar($nametype,$dirtype,$rootdir);
}
function setvar($nametype='name',$dirtype='year',$rootdir='html')
{
$this->rootdir=$rootdir;
$this->dirtype=$dirtype;
$this->nametype=$nametype;
}
function createdir($dir='')
{
$this->dir=$dir?$dir:$this->dir;
if (!is_dir($this->dir))
{
$temp = explode('/',$this->dir);
$cur_dir = '';
for($i=0;$i<count($temp);$i++)
{
$cur_dir .= $temp[$i].'/';
if (!is_dir($cur_dir))
{
@mkdir($cur_dir,0777);
}
}
}
}
function getdir($dirname='',$time=0)
{
$this->time=$time?$time:$this->time;
$this->dirname=$dirname?$dirname:$this->dirname;
switch($this->dirtype)
{
case 'name':
if(empty($this->dirname))
$this->dir=$this->rootdir;
else
$this->dir=$this->rootdir.'/'.$this->dirname;
break;
case 'year':
$this->dir=$this->rootdir.'/'.date("Y",$this->time);
break;
case 'month':
$this->dir=$this->rootdir.'/'.date("Y-m",$this->time);
break;
case 'day':
$this->dir=$this->rootdir.'/'.date("Y-m-d",$this->time);
break;
}
$this->createdir();
return $this->dir;
}
function geturlname($url='')
{
$this->url=$url?$url:$this->url;
$filename=basename($this->url);
$filename=explode(".",$filename);
return $filename[0];
}
function geturlquery($url='')
{
$this->url=$url?$url:$this->url;
$durl=parse_url($this->url);
$durl=explode("&",$durl[query]);
foreach($durl as $surl)
{
$gurl=explode("=",$surl);
$eurl[]=$gurl[1];
}
return join("_",$eurl);
}
function getname($url='',$time=0,$dirname='')
{
$this->url=$url?$url:$this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
$this->getdir();
switch($this->nametype)
{
case 'name':
$filename=$this->geturlname().'.htm';
$this->name=$this->dir.'/'.$filename;
break;
case 'time':
$this->name=$this->dir.'/'.$this->time.'.htm';
break;
case 'query':
$this->name=$this->dir.'/'.$this->geturlquery().'.htm';
break;
case 'namequery':
$this->name=$this->dir.'/'.$this->geturlname().'-'.$this->geturlquery().'.htm';
break;
case 'nametime':
$this->name=$this->dir.'/'.$this->geturlname().'-'.$this->time.'.htm';
break;
}
return $this->name;
}
function createhtml($url='',$time=0,$dirname='',$htmlname='')
{
$this->url=$url?$url:$this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
//上面保证不重复地把变量赋予该类成员
if(empty($htmlname))
$this->getname();
else
$this->name=$dirname.'/'.$htmlname; //得到name
$content=file($this->url) or die("Failed to open the url ".$this->url." !");;
///////////////关键步---用file读取$this->url
$content=join("",$content);
$fp=@fopen($this->name,"w") or die("Failed to open the file ".$this->name." !");
if(@fwrite($fp,$content))
return true;
else
return false;
fclose($fp);
}
/////////////////以name为名字生成html
function deletehtml($url='',$time=0,$dirname='')
{
$this->url=$url?$url:$this->url;
$this->time=$time?$time:$this->time;
$this->getname();
if(@unlink($this->name))
return true;
else
return false;
}
/**
* function::deletedir()
* 删除目录
* @param $file 目录名(不带/)
* @return
*/
function deletedir($file)
{
if(file_exists($file))
{
if(is_dir($file))
{
$handle =opendir($file);
while(false!==($filename=readdir($handle)))
{
if($filename!="."&&$filename!="..")
$this->deletedir($file."/".$filename);
}
closedir($handle);
rmdir($file);
return true;
}else{
unlink($file);
}
}
}
}
?>
生成静态页面的PHP类
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 南合文斗.2007-陪君醉笑三千尘鸟人唱片】【FLAC+CUE】
- 群星《我们的歌第六季 第1期》[320K/MP3][90.72MB]
- 群星《我们的歌第六季 第1期》[FLAC/分轨][456.01MB]
- 李雨寰《Break Free》[320K/MP3][98.39MB]
- 草蜢.2001-《真经典》环球唱片[WAV+CUE]
- 群星.2009-第4届2008十大发烧唱片精选[FLAC+CUE]
- 丁红《女儿情》[DTS-WAV]
- 陈惠婷.2017-Voyager3【亚神音乐】【FLAC分轨】
- 群星.2001-华纳歌声魅影【华纳】【WAV+CUE】
- 张雨生.2016-雨后星空2CD【丰华】【WAV+CUE】
- 李雨寰《Break Free》[FLAC/分轨][533MB]
- 廖也欧《面朝大海》[320K/MP3][18.35MB]
- 廖也欧《面朝大海》[Hi-Res][24bit 48kHz][FLAC/分轨][170.14MB]
- s13T1夺冠五人名单都有谁 s13T1夺冠五人名单一览
- 英雄联盟T1战队队长都有谁 T1战队所有队长介绍