Generate static HTML speed class library _php instance with PHP

Source: Internet
Author: User
Tags abstract documentation flush reserved

Copy Code code as follows:

Ob_start (); #开启服务器缓存
Include_once ' index.php ';
$ctx =ob_get_contents (); # get Cache
Ob_end_clean (); #清空缓存
$FH =fopen ("index.html", "w+");
Fwrite ($FH, $ctx); # write HTML, generate HTML
Fclose ($FH);

1, Flush: Refresh the contents of the buffer, output.
function format: Flush ()
Description: This function is frequently used and highly efficient.
2, Ob_start: Open the output buffer
function format: void Ob_start (void)
Note: When the buffer is activated, all non-file header information from the PHP program is not sent, but is saved in the internal buffer. To output the contents of the buffer, you can use Ob_end_flush () or flush () to output the contents of the buffer.
3, Ob_get_contents: Return the contents of the internal buffer.
Use
function Format: string ob_get_contents (void)
Description: This function returns the contents of the current buffer and FALSE if the output buffer is not active.
4, Ob_get_length: Returns the length of the internal buffer.
How to use: int ob_get_length (void)
Description: This function returns the length of the current buffer, as ob_get_contents if the output buffer is not active. Returns FALSE.
5, Ob_end_flush: Send the contents of the internal buffer to the browser, and turn off the output buffer.
Usage method: void Ob_end_flush (void)
Description: This function sends the contents of the output buffer (if any).
6, Ob_end_clean: Delete the contents of the internal buffer, and close the internal buffer
Usage method: void Ob_end_clean (void)
Description: This function does not output the contents of the internal buffer but deletes it!
7. Ob_implicit_flush: Turn absolute refresh on or off
How to use: void Ob_implicit_flush ([int flag])
Copy Code code as follows:

<?php
///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module name:woods-bhtml.php
Abstract: Generate static HTML handler tail end
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
//
Copyright 1001-1006, All rights reserved by Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use this software must place a copy of the
Above copyright notice. By the Software Huijia Studio
Maintenance, if you are have any queries please contact us.
Thank you.
//
This software is free software that allows the use, copying, modification and distribution of the software and its documentation.
Any copies of the above copyright notices will be available wherever this software is used. This software is provided by the
Hui Jia Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
This file can only be loaded at the end of the program
/*________________ Generate HTML file ______________________beign________________________________*/
if ($make _html)
{
$buffer = Ob_get_flush ();
if ($go _html)//whether directly to the HTML file display or PHP read content output (0:php read content Output 1: Direct turn)
{
/*__________ handles the problem of the seed path caused by generating HTML files ____________________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);
/*__________ handles the problem of the seed path caused by generating HTML files ____________________end_______________*/
}

$fp = fopen (html_file, "w");
if ($FP)
{
Fwrite ($fp, $buffer);
Fclose ($FP);
}
}
/*________________ Generate HTML file ______________________beign________________________________*/
?>

<?php
///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module name:woods-thtml.php
Abstract: Generating static HTML handler headers
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
//
Copyright 1001-1006, All rights reserved by Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use this software must place a copy of the
Above copyright notice. By the Software Huijia Studio
Maintenance, if you are have any queries please contact us.
Thank you.
//
This software is free software that allows the use, copying, modification and distribution of the software and its documentation.
Any copies of the above copyright notices will be available wherever this software is used. This software is provided by the
Hui Jia Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
This file can only be loaded at the beginning of the program
Ob_start ();
/*___________ determines whether an HTML file has been generated, and jumps to an HTML page if it is generated ___________begin__________*/
$qstring = Isset ($_server["query_string"])? $_server["Query_string"]: "";
if ($qstring)//program adds a GET request processing
{
$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 ())//To determine whether the last generation of HTML file in the past 1 times, if not to output directly the contents of the file
{
if ($show _html)//is displayed in an HTML static page (0 does not show HTML display 1 with HTML display)
{
if ($go _html)//whether directly to the HTML file display or PHP read content output (0:php read content Output 1: Direct turn)
{
Header ("Location:"). html_file);/Direct turn
}
Else
{
Echo (file_get_contents (html_file));//Read exhibited
}
Exit (0);
}
}
}
/*___________ determines whether an HTML file has been generated, and jumps to an HTML page if it is generated ___________end__________*/
?>

<?php
///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module Name:index.php
Abstract: Home Information
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
//
Copyright 2001-2006, All rights reserved by Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use this software must place a copy of the
Above copyright notice. By the Software Huijia Studio
Maintenance, if you are have any queries please contact us.
Thank you.
//
This software is free software that allows the use, copying, modification and distribution of the software and its documentation.
Any copies of the above copyright notices will be available wherever this software is used. This software is provided by the
Hui Jia Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
Require ("woods-thtml.php");//Generate HTML Processing headers
if (count ($_get) < 1 && count ($_post) < 1) {require ("woods-thtml.php"); Generate HTML Processing headers

Require ("{$exec _file}");//Register language definition file
foreach ($lang as $key => $value)
{
$ATPL [Strtoupper ($key). " _lang "] = $value;
}
/*____________________________________ list Common sense go up the item __________________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;
/*________________ Template Operations _________________________end___________________________________*/
Require ("woods-bhtml.php");//Generate HTML processing tail
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.