用PHP实现的生成静态HTML速度快类库


Posted in PHP onMarch 31, 2007
<?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静态类
Nov 25 PHP
How do I change MySQL timezone?
Mar 26 PHP
PHPMYADMIN 简明安装教程 推荐
Mar 07 PHP
php使用GeoIP库实例
Jun 27 PHP
destoon实现调用热门关键字的方法
Jul 15 PHP
php实现在限定区域里自动调整字体大小的类实例
Apr 02 PHP
PHP实现导出excel数据的类库用法示例
Oct 15 PHP
PHP读取文件的常见几种方法
Nov 03 PHP
thinkPHP批量删除的实现方法分析
Nov 09 PHP
深入讲解PHP的对象注入(Object Injection)
Mar 01 PHP
thinkphp集成前端脚手架Vue-cli的教程图解
Aug 30 PHP
PHP随机生成中文段落示例【测试网站内容时使用】
Apr 26 PHP
解决dede生成静态页和动态页转换的一些问题,及火车采集入库生成动态的办法
Mar 29 #PHP
实现dedecms全站URL静态化改造的代码
Mar 29 #PHP
PHP中动态显示签名和ip原理
Mar 28 #PHP
收集的PHP中与数组相关的函数
Mar 22 #PHP
用PHP写的MySQL数据库用户认证系统代码
Mar 22 #PHP
人尽可用的Windows技巧小贴士之下篇
Mar 22 #PHP
加速XP搜索功能堪比vista
Mar 22 #PHP
You might like
PHP5.0正式发布 不完全兼容PHP4 新增多项功能
2006/10/09 PHP
实现dedecms全站URL静态化改造的代码
2007/03/29 PHP
CodeIgniter php mvc框架 中国网站
2008/05/26 PHP
PHP Memcached应用实现代码
2010/02/08 PHP
php多文件上传下载示例分享
2014/02/20 PHP
PHP常用编译参数中文说明
2014/09/27 PHP
PHP在同一域名下两个不同的项目做独立登录机制详解
2017/09/22 PHP
php实现微信和支付宝支付的示例代码
2020/08/11 PHP
PHP并发场景的三种解决方案代码实例
2021/02/27 PHP
深入理解JavaScript系列(11) 执行上下文(Execution Contexts)
2012/01/15 Javascript
纯js网页画板(Graphics)类简介及实现代码
2012/12/24 Javascript
JavaScript将字符串转换为整数的方法
2015/04/14 Javascript
详解Node.Js如何处理post数据
2016/09/19 Javascript
javascript面向对象三大特征之多态实例详解
2019/07/24 Javascript
Angular8路由守卫原理和使用方法
2019/08/29 Javascript
基于node+vue实现简单的WebSocket聊天功能
2020/02/01 Javascript
Vue 修改网站图标的方法
2020/12/31 Vue.js
[51:52]Liquid vs Secret 2019国际邀请赛淘汰赛 败者组 BO3 第二场 8.24
2019/09/10 DOTA
python解析xml文件实例分享
2013/12/04 Python
Python文件与文件夹常见基本操作总结
2016/09/19 Python
Python3实现抓取javascript动态生成的html网页功能示例
2017/08/22 Python
python递归法实现简易连连看小游戏
2020/03/25 Python
Tensorflow实现酸奶销量预测分析
2019/07/19 Python
Python中顺序表原理与实现方法详解
2019/12/03 Python
Python selenium 自动化脚本打包成一个exe文件(推荐)
2020/01/14 Python
使用python检查yaml配置文件是否符合要求
2020/04/09 Python
Python和Bash结合在一起的方法
2020/11/13 Python
Python爬虫逆向分析某云音乐加密参数的实例分析
2020/12/04 Python
工程预算与管理应届生求职信
2013/10/06 职场文书
小学校长汇报材料
2014/08/20 职场文书
毕业实习证明(4篇)
2014/10/28 职场文书
工作失职检讨书
2015/01/26 职场文书
2015年安康杯竞赛活动总结
2015/03/26 职场文书
2015年大学社团工作总结
2015/04/09 职场文书
2016暑期社会实践新闻稿
2015/11/25 职场文书
2019年七夕情人节浪漫祝福语大全!
2019/08/08 职场文书