生成html静态文件类程序与实例使用方法,Web开发

作者: 关于计算机  发布:2019-10-03

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

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')

function html($nametype='name',$dirtype='year',$rootdir='html')

function setvar($nametype='name',$dirtype='year',$rootdir='html')

function setvar($nametype='name',$dirtype='year',$rootdir='html')

function createdir($dir='')
{
$this->dir=$dir?$dir:$this->dir;

function createdir($dir='')
{
$this->dir=$dir?$dir:$this->dir;

if (!is_dir($this->dir))
{
$temp = explode('/',$this->dir);
$cur_dir = '';
for($i=0;$i {
$cur_dir .= $temp[$i].'/';
if (!is_dir($cur_dir))

if (!is_dir($this->dir))
{
$temp = explode('/',$this->dir);
$cur_dir = '';
for($i=0;$i {
$cur_dir .= $temp[$i].'/';
if (!is_dir($cur_dir))

}
}
}

}
}
}

function getdir($dirname='',$time=0)
{
$this->time=$time?$time:$this->time;
$this->dirname=$dirname?$dirname:$this->dirname;

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;

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 'month':
$this->dir=$this->rootdir.'/'.date("Y-m",$this->time);
break;

case 'day':
$this->dir=$this->rootdir.'/'.date("Y-m-d",$this->time);
break;
}

case 'day':
$this->dir=$this->rootdir.'/'.date("Y-m-d",$this->time);
break;
}

$this->createdir();

$this->createdir();

return $this->dir;
}

function geturlname($url='')
{
$this->url=$url?$url:$this->url;

$filename=basename($this->url);
$filename=explode(".",$filename);
return $filename[0];
}

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-%3Ename,%22w") 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)))

closedir($handle);
rmdir($file);
return true;
}else
}
}

}
?>

本文由王中王开奖结果发布于关于计算机,转载请注明出处:生成html静态文件类程序与实例使用方法,Web开发

关键词:

上一篇:用PHP完结验证码效能
下一篇:没有了