专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »PHP教程 » php生成静态页:静态新闻列表自动生成PHP程序 »正文

php生成静态页:静态新闻列表自动生成PHP程序

来源: 发布时间:星期四, 2009年2月12日 浏览:469次 评论:0




function CreateShtml

{

ob_start(.gif' />(\"callback_CreateShtml\",\"callback_GoToShtml\"));

}



function callback_CreateShtml($buffer)

{

$page = val(@$_REQUEST[\"page\"]);

$fileName = $_SERVER[\'DOCUMENT_ROOT\'] . dirname($_SERVER[\'PHP_SELF\']) . \"/\" . basename($_SERVER[\'PHP_SELF\'],\".php\") . ($page0 ? \"\" : \"_\" . strval($page)) . \".htm\";

$fp = fopen($fileName,\"wb\");

fwrite($fp,$buffer);

fclose($fp);

$buffer;

}



function callback_GoToShtml($buffer)

{

$page = val(@$_REQUEST[\"page\"]);

$fileName = basename($_SERVER[\'PHP_SELF\'],\".php\") . ($page0 ? \"\" : \"_\" . strval($page)) . \".htm\";

header(\"location:\" . $fileName);

$buffer;

}



function GoToShtml

{

$page =

val(@$_REQUEST[\"page\"]);

$fileName = basename($_SERVER[\'PHP_SELF\'],\".php\") . ($page0 ? \"\" : \"_\" . strval($page)) . \".htm\";

(file_exists($fileName))

header(\"location:\" . $fileName);

}



function DeleteShtml($fileName=NULL)

{

(is_null($fileName))

$fileName = $_SERVER[\'DOCUMENT_ROOT\'] . $_SERVER[\'PHP_SELF\'];



($fileName[0]\"/\")

$fileName = $_SERVER[\'DOCUMENT_ROOT\'] . $fileName;



$path = dirname($fileName);

$dir = dir($path);

$patten = \"/^\" . basename($fileName, \".php\") . \"(_[0-9]+)?.htm/\";

while(($entry = $dir->read)!false)

{

(is_file($path . \"/\" .$entry) && preg_match($patten,$entry))

unlink ($path .

\"/\" . $entry);

}

}

2

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: