欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

http://www.kaqima.com/index.ht PHP静态新闻列表自动生成代码

程序员文章站 2022-05-31 16:03:53
...
function CreateShtml()
{
ob_start(array("callback_CreateShtml","callback_GoToShtml"));
}
function callback_CreateShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
$fp = fopen($fileName,"wb");
fwrite($fp,$buffer);
fclose($fp);
return $buffer;
}
function callback_GoToShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
header("location:" . $fileName);
return $buffer;
}
function GoToShtml()
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
if(file_exists($fileName))
header("location:" . $fileName);
}
function DeleteShtml($fileName=NULL)
{
if(is_null($fileName))
$fileName = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
if($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)
{
if(is_file($path . "/" .$entry) && preg_match($patten,$entry))
unlink ($path . "/" . $entry);
}
}

以上就介绍了http://www.kaqima.com/index.ht PHP静态新闻列表自动生成代码,包括了http://www.kaqima.com/index.ht方面的内容,希望对PHP教程有兴趣的朋友有所帮助。