PHP静态新闻列表自动生成代码
作者:bea
functionCreateShtml() { ob_start(array("callback_CreateShtml","callback_GoToShtml")); } functioncallback_CreateShtml($buffer) { $page=intval(@$_REQUEST["page"]); $fileName=$_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/".basename
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);
}
}
有用 | 无用
{
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);
}
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 真正的ZIP文件操作类(php)
- php 用sock技术发送邮件的函数
- php中ob(Output Buffer 输出缓冲)函数使用方法
- 在普通HTTP上安全地传输密码
- 发布一个迷你php+AJAX聊天程序[聊天室]提供下载
- PHP+FLASH实现上传文件进度条相关文件 下载
- Discuz5.5.0代码高亮显示+运行代码框合成插件 下载
- 一段php加密解密的代码
- php下一个阿拉伯数字转中文数字的函数
- php+mysql开源XNA 聚合程序发布 下载
- PHP 优化配置——加速你的VBB,phpwind,Discuz,IPB,MolyX
- PHP如何编写易读的代码
- php为什么选mysql作为数据库? Mysql 创建用户方法
- PHP 中的批处理的实现
- 关于在php.ini中添加extension=php_mysqli.dll指令的说明
- 用PHP实现维护文件代码
- 用PHP实现的随机广告显示代码
- PHP生成月历代码
- 用PHP实现图象锐化代码