Discuz教程网

PHP生成静态页面的类

[复制链接]
authicon dly 发表于 2011-3-28 19:11:35 | 显示全部楼层 |阅读模式
  1. <?php

  2. /**
  3. * Displays : 生成静态页
  4. * Author : phpox
  5. * Date : Fri Sep 28 10:50:32 CST 2007
  6. */

  7. defined('PHPOX') or die(header("HTTP/1.1 403 Not Forbidden"));

  8. class include_createstatic
  9. {

  10. private $htmlPath = '';
  11. private $path = '';
  12. public $monthPath = '';
  13. private $listPath = '';
  14. private $content = '';
  15. private $filename = '';
  16. private $extname = '.html';

  17. public function createHtml($type,$desName,$content)
  18. {
  19. $this->htmlPath = getAppInf('htmlPath');
  20. if (!file_exists($this->htmlPath))
  21. {
  22. @mkdir($this->htmlPath);
  23. }
  24. $this->path = $this->htmlPath.$this->monthPath.'/';
  25. if (!file_exists($this->path))
  26. {
  27. @mkdir($this->path);
  28. }
  29. $this->listPath = $this->htmlPath.'list/';
  30. if (!file_exists($this->listPath))
  31. {
  32. @mkdir($this->listPath);
  33. }
  34. switch ($type)
  35. {
  36. case 'index':
  37. $this->filename = $desName;
  38. break;
  39. case 'list':
  40. $this->filename = $this->listPath.$desName;
  41. break;
  42. case 'view':
  43. $this->filename = $this->path.$desName;
  44. break;
  45. }
  46. $this->filename .= $this->extname;
  47. $this->content = $content;
  48. }

  49. public function write()
  50. {
  51. $fp=fopen($this->filename,'wb');
  52. if (!is_writable($this->filename))
  53. {
  54. return false;
  55. }
  56. if (!fwrite($fp,$this->content))
  57. {
  58. return false;
  59. }
  60. fclose($fp);
  61. return $this->filename;
  62. }
  63. }
  64. ?>

复制代码






上一篇:PHP生成缩略图类
下一篇:保存url中的图片文件到本地的imges文件夹的PHP函数
authicon 月之海洋 发表于 2011-5-14 07:59:41 | 显示全部楼层
楼主真强大
authicon cutiemimi 发表于 2011-6-21 14:59:58 | 显示全部楼层
真的有意思!
authicon summmer 发表于 2011-6-25 07:59:51 | 显示全部楼层
好东西,要下来看看
authicon fantuanzi 发表于 2011-6-26 12:59:31 | 显示全部楼层
哈哈,支持了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-3 07:28

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表