用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数据库抽象层 PDO
May 07 PHP
php自定义函数call_user_func和call_user_func_array详解
Jul 14 PHP
php入门之连接mysql数据库的一个类
Apr 21 PHP
PHP数据库万能引擎类adodb配置使用以及实例集锦
Jun 12 PHP
PHP使用DOMDocument类生成HTML实例(包含常见标签元素)
Jun 25 PHP
PHP开发框架laravel安装与配置教程
Mar 13 PHP
PHP中set error handler函数用法小结
Nov 11 PHP
详谈PHP中的密码安全性Password Hashing
Feb 04 PHP
thinkPHP5.0框架独立配置与动态配置方法
Mar 17 PHP
Laravel中任务调度console使用方法小结
May 07 PHP
解决laravel5.4下的group by报错的问题
Oct 16 PHP
在 Laravel 6 中缓存数据库查询结果的方法
Dec 11 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数学运算
2011/12/30 PHP
PHP中几种常见的超时处理全面总结
2012/09/11 PHP
php strrpos()与strripos()函数
2013/08/31 PHP
PHP使用mysql_fetch_object从查询结果中获取对象集的方法
2015/03/18 PHP
php一个解析字符串排列数组的方法
2015/05/12 PHP
thinkPHP简单调用函数与类库的方法
2017/03/15 PHP
JavaScript入门教程(12) js对象化编程
2009/01/31 Javascript
js 函数调用模式小结
2011/12/26 Javascript
js无刷新操作table的行和列
2014/03/27 Javascript
JavaScript实现重置表单(reset)的方法
2015/04/02 Javascript
js实现Select列表内容自动滚动效果代码
2015/08/20 Javascript
深入浅析JavaScript中对事件的三种监听方式
2015/09/29 Javascript
再谈Javascript中的基本类型和引用类型(推荐)
2016/07/01 Javascript
js常用DOM方法详解
2017/02/04 Javascript
seajs中最常用的7个功能、配置示例
2017/10/10 Javascript
nodejs 日志模块winston的使用方法
2018/05/02 NodeJs
Vue.js项目实战之多语种网站的功能实现(租车)
2019/08/07 Javascript
js前端传json后台接收‘‘被转为quot的问题解决
2020/11/12 Javascript
js实现筛选功能
2020/11/24 Javascript
python根据经纬度计算距离示例
2014/02/16 Python
Python自定义函数定义,参数,调用代码解析
2017/12/27 Python
python中format()函数的简单使用教程
2018/03/14 Python
基于Django框架的权限组件rbac实例讲解
2019/08/31 Python
Python unittest生成测试报告过程解析
2020/09/08 Python
美国汽车交易网站:Edmunds
2016/08/17 全球购物
当一个对象被当作参数传递到一个方法后,此方法可改变这个对象的属性,并可返回变化后的结果,那么这里到底是值传递还是引用传递?
2014/09/09 面试题
酒店保洁主管岗位职责
2013/11/28 职场文书
倡议书格式
2014/04/14 职场文书
快餐公司创业计划书
2014/04/29 职场文书
小学数学教学经验交流材料
2014/05/22 职场文书
安全先进个人材料
2014/12/29 职场文书
运动会三级跳加油稿
2015/07/21 职场文书
oracle DGMGRL ORA-16603报错的解决方法(DG Broker)
2021/04/06 Oracle
详解MySQL中的主键与事务
2021/05/27 MySQL
Java获取e.printStackTrace()打印的信息方式
2021/08/07 Java/Android
Redis 中使用 list,streams,pub/sub 几种方式实现消息队列的问题
2022/03/16 Redis