欢迎来到山村网

PHP动态网页实现静态HTML技术的方法

2019-03-28 23:17:28浏览:384 来源:山村网   
核心摘要:?phpif ($make_html){$buffer = ob_get_flush();if ($go_html)//是否直接转到HTML文件显示还是PHP读得内容输出(0:php读内容输出1

<?php


if ($make_html)
{
$buffer = ob_get_flush();
if ($go_html)//是否直接转到HTML文件显示还是PHP读得内容输出(0:php读内容输出1:直接转)
{

$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);

}
$fp = fopen(HTML_FILE, "w");
if ($fp)
{
fwrite($fp, $buffer);
fclose($fp);
}
}

?>
<?php
ob_start();

$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);
}
}
}

?>
<?php
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;
}

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;

require("woods-bhtml.php");//生成HTML处理尾
?>
(责任编辑:豆豆)
下一篇:

PHP生成静态HTML文章发布系统

上一篇:

XML与HTML的区别

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com