首页 > 开发 > PHP > 正文

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

2024-05-04 23:03:12
字体:
来源:转载
供稿:网友

<?php
/*____生成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
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
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处理尾
?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表