复制代码
代码如下:setvar($nametype,$dirtype,$rootdir); }
functionsetvar($nametype=’name’,$dirtype=’year’,$rootdir=’html’) {
$this->rootdir=$rootdir; $this->dirtype=$dirtype;
$this->nametype=$nametype; } functioncreatedir {
$this->dir=$dir?$dir:$this->dir; if { $temp=explode; $cur_dir=”;
for;$i++) { $cur_dir.=$temp[$i].’/’; if { @mkdir; } } } }
functiongetdir { $this->time=$time?$time:$this->time;
$this->dirname=$dirname?$dirname:$this->dirname; switch {
case’name’: if) $this->dir=$this->rootdir; else
$this->dir=$this->rootdir.’/’.$this->dirname; break;
case’year’: $this->dir=$this->rootdir.’/’.date; break;
case’month’: $this->dir=$this->rootdir.’/’.date; break; case’day’:
$this->dir=$this->rootdir.’/’.date; break; }
$this->createdir(); return$this->dir; } functiongeturlname {
$this->url=$url?$url:$this->url; $filename=basename;
$filename=explode; return$filename[0]; } functiongeturlquery {
$this->url=$url?$url:$this->url; $durl=parse_url; $durl=explode;
foreach { $gurl=explode; $eurl[]=$gurl[1]; } returnjoin; }
functiongetname($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 {
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; }
functioncreatehtml($url=”,$time=0,$dirname=”,$htmlname=”) {
$this->url=$url?$url:$this->url;
$this->dirname=$dirname?$dirname:$this->dirname;
$this->time=$time?$time:$this->time;
//上面保证不重复地把变量赋予该类成员 if $this->getname(); else
$this->name=$dirname.’/’.$htmlname;//得到name
$content=fileordie(“Failedtoopentheurl”.$this->url.”!”);;
///////////////关键步—用file读取$this->url $content=join;
$fp=@fopenordie(“Failedtoopenthefile”.$this->name.”!”); if)
returntrue; else returnfalse; fclose; }
/////////////////以name为名字生成html
functiondeletehtml($url=”,$time=0,$dirname=”) {
$this->url=$url?$url:$this->url;
$this->time=$time?$time:$this->time; $this->getname(); if
returntrue; else returnfalse; } /** *function::deletedir() *删除目录
*新澳门31999,@param$file目录名 *@return */ functiondeletedir { if { if {
$handle=opendir; while(false!==($filename=readdir {
if($filename!=”.”&&$filename!=”..”) $this->deletedir; } closedir;
rmdir; returntrue; }else{ unlink; } } } } ?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注