请选择 进入手机版 | 继续访问电脑版
绿茶科技社区
  1. function CreateShtml()  
  2. {  
  3. ob_start(array("callback_CreateShtml","callback_GoToShtml"));  
  4. }  

  5. function callback_CreateShtml($buffer)  
  6. {  
  7. $page = intval(@$_REQUEST["page"]);  
  8. $fileName = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";  
  9. $fp = fopen($fileName,"wb");  
  10. fwrite($fp,$buffer);  
  11. fclose($fp);  
  12. return $buffer;  
  13. }  

  14. function callback_GoToShtml($buffer)  
  15. {  
  16. $page = intval(@$_REQUEST["page"]);  
  17. $fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";  
  18. header("location:" . $fileName);  
  19. return $buffer;  
  20. }  

  21. function GoToShtml()  
  22. {  
  23. $page = intval(@$_REQUEST["page"]);  
  24. $fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";  
  25. if(file_exists($fileName))  
  26. header("location:" . $fileName);  
  27. }  

  28. function DeleteShtml($fileName=NULL)  
  29. {  
  30. if(is_null($fileName))  
  31. $fileName = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];  

  32. if($fileName[0]=="/")  
  33. $fileName = $_SERVER['DOCUMENT_ROOT'] . $fileName;  

  34. $path = dirname($fileName);  
  35. $dir = dir($path);  
  36. $patten = "/^" . basename($fileName, ".php") . "(_[0-9]+)?.htm/";  
  37. while(($entry = $dir->read())!==false)  
  38. {  
  39. if(is_file($path . "/" .$entry) && preg_match($patten,$entry))  
  40. unlink ($path . "/" . $entry);  
  41. }  
  42. }  

复制代码


分享到 :
0 人收藏

1 个回复

倒序浏览
旁观者  高级会员 | 7 天前
秀起来~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

举报|Archiver|手机版|小黑屋|Lvchakeji Inc.  

Powered by Discuz! X3.3 © 2001-2016 Comsenz Inc.

返回顶部