Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php生成html静态页面的方法参考

php生成html静态页面的方法参考

发布时间:2015-06-04   编辑:www.jquerycn.cn
php生成html静态页面的方法参考,有需要的朋友可以参考下。

php生成html静态页面的方法参考,有需要的朋友可以参考下。
 

复制代码 代码如下:

<?php
////////
//
// 张树林 - 慧佳工作室
//
// Module Name: woods-bhtml.php
// Abstract: 生成静态HTML处理程序尾底
// Version: 2.0
// 版权 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
// 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
//
// 版权 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页面静态化的小例子
有关smarty模板引擎生成静态页的关键代码
PHP实现页面静态化、纯静态化及伪静态化
PHP中使用smarty生成静态文件的例子
php定时生成静态html的代码分享
php 伪静态(url重写)的写法
PHP生成静态页面
php模版生成html的小例子
php怎么做页面静态化

关键词: 生成html  生成静态   
[关闭]