用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面试题附答案
Jan 07 PHP
PHP在字符断点处截断文字的实现代码
Apr 21 PHP
PHP删除数组中特定元素的两种方法
Jul 02 PHP
ThinkPHP之M方法实例详解
Jun 20 PHP
全面解读PHP的人气开发框架Laravel
Oct 15 PHP
PHP中使用substr()截取字符串出现中文乱码问题该怎么办
Oct 21 PHP
CI框架入门之MVC简单示例
Nov 21 PHP
PHP那些琐碎的知识点(整理)
May 20 PHP
详解php中的implements 使用
Jun 13 PHP
弹出模态框modal的实现方法及实例
Sep 19 PHP
浅谈PHP中pack、unpack的详细用法
Mar 12 PHP
Yii框架操作cookie与session的方法实例详解
Sep 04 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
隐藏你的.php文件的实现方法
2007/03/19 PHP
php读取文件内容的方法汇总
2015/01/24 PHP
基于CakePHP实现的简单博客系统实例
2015/06/28 PHP
PHP+Ajax简单get验证操作示例
2019/03/02 PHP
Javascript实现的鼠标经过时播放声音
2010/05/18 Javascript
js String对象中常用方法小结(字符串操作)
2012/01/27 Javascript
jQuery.validate 常用方法及需要注意的问题
2013/03/20 Javascript
js控制容器隐藏出现防止样式变化的两种方法
2014/04/25 Javascript
jQuery实现点击行选中或取消CheckBox的方法
2016/08/01 Javascript
实例详解jQuery的无new构建
2016/08/02 Javascript
JavaScript表单验证完美代码
2017/03/02 Javascript
详解Vue方法与事件
2017/03/09 Javascript
JavaScript数据结构之双向链表和双向循环链表的实现
2017/11/28 Javascript
EasyUI的DataGrid绑定Json数据源的示例代码
2017/12/16 Javascript
微信小程序模板(template)使用详解
2018/01/31 Javascript
vue-cli的build的文件夹下没有dev-server.js文件配置mock数据的方法
2019/04/17 Javascript
jQuery+ThinkPHP实现图片上传
2020/07/23 jQuery
Python实现的生成自我描述脚本分享(很有意思的程序)
2014/07/18 Python
Python 迭代器工具包【推荐】
2016/05/06 Python
Python实现繁?转为简体的方法示例
2018/12/18 Python
解决Pycharm后台indexing导致不能run的问题
2019/06/27 Python
使用SimpleITK读取和保存NIfTI/DICOM文件实例
2020/07/01 Python
联想新加坡官方网站:Lenovo Singapore
2017/10/24 全球购物
金融专业个人的自我评价
2013/10/18 职场文书
应届生船舶驾驶求职信
2013/10/19 职场文书
编辑硕士自荐信范文
2013/11/27 职场文书
学习2014年全国两会心得体会
2014/03/12 职场文书
机电一体化毕业生自荐信
2014/06/19 职场文书
个人授权委托书
2014/09/15 职场文书
2014党员民主评议个人思想剖析发言
2014/09/19 职场文书
民主生活会对照检查材料范文
2014/10/01 职场文书
2015年幼儿园新年寄语
2014/12/08 职场文书
超市采购员岗位职责
2015/04/07 职场文书
Go语言 go程释放操作(退出/销毁)
2021/04/30 Golang
vue-cli4.5.x快速搭建项目
2021/05/30 Vue.js
纯html+css实现打字效果
2021/08/02 HTML / CSS