用PHP实现的生成静态HTML速度快类库
2023-06-13 09:13:55 时间
<?php
///////////////////////////////////////////////////////////////////////////////
//
// 张树林 - 慧佳工作室
//
// Module Name: woods-bhtml.php
// Abstract: 生成静态HTML处理程序尾底
// Version: 2.0
// Date 1006-11-25
// Author: woods·zhang
// Website: http://www.hoojar.com/
// Email: hoojar@53.com
// MSN: hoojar@hotmail.com
// Copyright 1001-1006, Hoojar studio All Rights Reserved
//
// 版权 1001-1006,慧佳工作室所有版权保护
//The software for free software, allowing use, copy,
//modify and distribute the software and files. Any
//use of this software must place a copy of all the
//above copyright notice. By the software Huijia studio
//maintenance, if you have any queries please contact us.
//Thank you.
//
//此软件为自由软件,允许使用、拷贝、修改、分发本软件及其文档。
//任何使用此软件的地方都得出现以上版权通告所有副本。此软件由
//慧佳工作室维护,如果您有什么疑问请与我们联系。谢谢使用。
//
///////////////////////////////////////////////////////////////////////////////
//此文件只能加载在程序的最尾
/*________________生成HTML文件______________________beign________________________________*/
if ($make_html)
{
$buffer = ob_get_flush();
if ($go_html)//是否直接转到HTML文件显示还是PHP读得内容输出(0:php读内容输出1:直接转)
{
/*__________处理因生成了HTML文件而产生的种径问题____________________begin_______________*/
$search = array(
"/(src=|action=|href=|ajaxRead\()\"/ie",
"/\.\.\./e",
"/\.\/\./e",
"/\.\.\/http:\/\//ies",
"/\.\.\/#/",
"/\"\.\"/e",
"/\.\.\/javascript:/ies");
$replace = array(
""\\1\"../"",
"".."",
""."",
""http://"",
"#",
""\"..\""",
""javascript:"");
$buffer = preg_replace($search, $replace, $buffer);
/*__________处理因生成了HTML文件而产生的种径问题____________________end_______________*/
}
$fp = fopen(HTML_FILE, "w");
if ($fp)
{
fwrite($fp, $buffer);
fclose($fp);
}
}
/*________________生成HTML文件______________________beign________________________________*/
?>
<?php
///////////////////////////////////////////////////////////////////////////////
//
// 张树林 - 慧佳工作室
//
// Module Name: woods-thtml.php
// Abstract: 生成静态HTML处理程序头
// Version: 2.0
// Date 1006-11-25
// Author: woods·zhang
// Website: http://www.hoojar.com/
// Email: hoojar@53.com
// MSN: hoojar@hotmail.com
// Copyright 1001-1006, Hoojar studio All Rights Reserved
//
// 版权 1001-1006,慧佳工作室所有版权保护
//The software for free software, allowing use, copy,
//modify and distribute the software and files. Any
//use of this software must place a copy of all the
//above copyright notice. By the software Huijia studio
//maintenance, if you have any queries please contact us.
//Thank you.
//
//此软件为自由软件,允许使用、拷贝、修改、分发本软件及其文档。
//任何使用此软件的地方都得出现以上版权通告所有副本。此软件由
//慧佳工作室维护,如果您有什么疑问请与我们联系。谢谢使用。
//
///////////////////////////////////////////////////////////////////////////////
//此文件只能加载在程序的开头
ob_start();
/*___________判断是否已生成了HTML文件,若生成了则跳转到HTML页面___________begin__________*/
$qstring = isset($_SERVER["QUERY_STRING"]) ? $_SERVER["QUERY_STRING"] : "";
if ($qstring)//程序加了GET请求的处理
{
$qstring = str_replace("=", "", $qstring);
define("HTML_FILE", "./h/{$efilename}-{$qstring}.html");
}
else
{
define("HTML_FILE", "./h/{$efilename}.html");
}
if (file_exists(HTML_FILE))
{
$lcft = filemtime(HTML_FILE);//last create file time
if (($lcft + 3600) > time())//判断上次生成HTML文件是否以过去1时间,若没有才直接输出文件内容
{
if ($show_html)//是否以HTML静态页面展示(0不以HTML展显1以html展显)
{
if ($go_html)//是否直接转到HTML文件显示还是PHP读得内容输出(0:php读内容输出1:直接转)
{
header("Location: " . HTML_FILE);//直接转
}
else
{
echo(file_get_contents(HTML_FILE));//读出展显
}
exit(0);
}
}
}
/*___________判断是否已生成了HTML文件,若生成了则跳转到HTML页面___________end__________*/
?>
<?php
///////////////////////////////////////////////////////////////////////////////
//
// 张树林 - 慧佳工作室
//
// Module Name: index.php
// Abstract: 首页信息
// Version: 1.0
// Date 2006-11-7
// Author: woods·zhang
// Website: http://www.hoojar.com/
// Cemail: hoojar@163.com
// MSN: hoojar@hotmail.com
// Copyright 2001-2006, Hoojar studio All Rights Reserved
//
// 版权 2001-2006,慧佳工作室所有版权保护
//The software for free software, allowing use, copy,
//modify and distribute the software and files. Any
//use of this software must place a copy of all the
//above copyright notice. By the software Huijia studio
//maintenance, if you have any queries please contact us.
//Thank you.
//
//此软件为自由软件,允许使用、拷贝、修改、分发本软件及其文档。
//任何使用此软件的地方都得出现以上版权通告所有副本。此软件由
//慧佳工作室维护,如果您有什么疑问请与我们联系。谢谢使用。
//
///////////////////////////////////////////////////////////////////////////////
require("woods-thtml.php");//生成HTML处理头
//if (count($_GET) < 1 && count($_POST) < 1){require("woods-thtml.php");}//生成HTML处理头
require("{$exec_file}");//注册语言定义文件
foreach ($lang as $key => $value)
{
$atpl[strtoupper($key) ."_LANG"] = $value;
}
/*____________________________________列表常识向上走的项__________________end_____________________*/
include("woods-templates.php");
$tpl = new WoodsTpl("./templates/");
$tpl->require_tpl("header.html");
$tpl->set_file();
$tpl->block("EBCORP", $scorp);
$tpl->block("NEWS", $news);
$tpl->block("PRODUCT", $product);
$tpl->block("EBPNAME_MSG", $spname);
$tpl->block("LORE", $lore);
$tpl->require_tpl("footer.html");
$tpl->parse($atpl, true);
$tpl = NULL;
/*________________模板操作_________________________end___________________________________*/
require("woods-bhtml.php");//生成HTML处理尾
?>
相关文章
- PHP动态模式和静态模式区别
- PHP连接linux并执行命令,php实现ssh远程连接服务器并操作服务器,PHP跨服务器执行shell脚本
- typecho开启伪静态,去掉那个讨厌的index.php
- 开发环境配置Linux实现PHP开发环境(linux配置php)
- Linux快速部署配置PHP服务器环境(linux部署php环境)
- PHP和Linux技术结合的灵活力量(php和linux)
- 器使用Linux快速启动PHP服务器(linux启动php服务)
- PHP开启Redis之路 正确的开启方式(php开启redis)
- 数据库快速学会:用PHP建立MySQL数据库(php建立mysql)
- PHP与MySQL的网站搭建指南(php和mysql搭建)
- PHP快速获取MySQL数据库信息(php获取mysql信息)
- PHP文件快速导入MySQL数据库(php文件导入mysql)
- 如何在PHP中启用MSSQL数据库连接(php开启mssql)
- PHP连接Microsoft SQL Server数据库技巧(php 连 mssql)
- php操作MSSQL变量的简易应用(php mssql 变量)
- 在PHP中操作MSSQL数据库:事务处理技巧(php mssql 事务)
- PHP与MySQL的关联技术(php关联mysql)
- MSSQL 数据库在PHP中的登录实现(mssql登录php)
- PHP生成HTML静态页面实例代码
- PHP字符串==比较运算符的副作用
- 通用PHP动态生成静态HTML网页的代码
- PHP定时自动生成静态HTML的实现代码
- php压缩HTML函数轻松实现压缩html/js/Css及注意事项
- Eclipse中php插件安装及Xdebug配置的使用详解
- PHP获取远程文件大小的3种解决方法
- 浅析php中三个等号(===)和两个等号(==)的区别
- php内核解析:PHP中的哈希表
- php获取表单中多个同名input元素的值
- PHP中批量生成静态html(命令行下运行PHP)
- PHP批量生成静态HTML的简单原理和方法
- php使用ob_start()实现图片存入变量的方法
- js+php实现静态页面实时调用用户登陆状态的方法
- 在ASP中不用模板生成HTML静态页直接生成.html页面