首页 > php教程 > php手册 > 正文

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

php中文网
发布: 2016-06-21 09:01:00
原创
1171人浏览过

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________*/
?>

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_____*/
?>

require("woods-thtml.php");//生成HTML处理头
//if (count($_GET)

ViiTor实时翻译
ViiTor实时翻译

AI实时多语言翻译专家!强大的语音识别、AR翻译功能。

ViiTor实时翻译 116
查看详情 ViiTor实时翻译

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速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号