php 生成html文件方法

php 生成html文件方法

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;
    var $rootdir;
    var $name;
    var $dirname;
    var $url;
    var $time;
    var $dirtype;
    var $nametype;

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

    function html($nametype=’name’,$dirtype=’year’,$rootdir=’html’)
    {
        $this->setvar($nametype,$dirtype,$rootdir);
    }

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

    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;

    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]美高梅59599,.’/’;
if (!is_dir($cur_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;

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;
    }

return $this->dir;
}

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

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

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

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

    function geturlquery($url=”)
    {
        $this->url=$url?$url:$this->url;

case ‘nametime’:
$this->name=$this->dir.’/’.$this->geturlname().’-‘.$this->time.’.htm’;
break;

        $durl=parse_url($this->url);
        $durl=explode(“&”,$durl[query]);
        foreach($durl as $surl)
        {
          $gurl=explode(“=”,$surl);
          $eurl[]=$gurl[1];
        }
        return join(“_”,$eurl);
    }

admin

网站地图xml地图