php静态文件生成类
发布:smiling 来源: PHP粉丝网 添加日期:2014-09-09 15:27:15 浏览: 评论:
- class include_createstatic
- {
-
- private $htmlpath = '';
- private $path = '';
- public $monthpath = '';
- private $listpath = '';
- private $content = '';
- private $filename = '';
- private $extname = '.html';
-
- public function createhtml($type,$desname,$content)
- {
- $this->htmlpath = getappinf('htmlpath');
- if (!file_exists($this->htmlpath))
- {
- @mkdir($this->htmlpath);
- }
- $this->path = $this->htmlpath.$this->monthpath.'/';
- if (!file_exists($this->path))
- {
- @mkdir($this->path);
- }
- $this->listpath = $this->htmlpath.'list/';
- if (!file_exists($this->listpath))
- {
- @mkdir($this->listpath);
- }
- switch ($type)
- {
- case 'index':
- $this->filename = $desname;
- break;
- case 'list':
- $this->filename = $this->listpath.$desname;
- break;
- case 'view':
- $this->filename = $this->path.$desname;
- break;
- }
- $this->filename .= $this->extname;
- $this->content = $content;
- }
-
- public function write()
- {
- $fp=fopen($this->filename,'wb');
- if (!is_writable($this->filename))
- {
- return false;
- }
- if (!fwrite($fp,$this->content))
- {
- return false;
- }
- fclose($fp);
- return $this->filename;
- }
- }
-
-
-
- if(file_exists("./index.htm"))
- {
- $time=time();
-
- if(time-filemtime("./index.htm")< 600)
- {
- header("location:classhtml/main.htm");
- }
- }
-
- ob_start();
-
-
- $temp=ob_get_contents();
- ob_end_clean();
-
- $fp=fopen("./index.htm",'w');
- fwrite(fp,temp) or die('写文件错误');
分享到:
相关文章
- ·php静态文件生成类(2014-08-16)
- ·PHP静态文件生成类实例(2021-05-01)
- ·php静态文件生成类实例分析(2021-05-05)
- ·PHP生成RSS文件类实例(2021-05-02)