Php method reference for generating HTML static pages

Source: Internet
Author: User
Tags apache php
  1. ////////

  2. //
  3. Zhangshulin-Hui Jia Studio
  4. //
  5. Module name:woods-bhtml.php
  6. Abstract: Generating a static HTML handler end
  7. version:2.0
  8. Copyright 1001-1006, All rights reserved for Hui Jia Studio

  9. The software for free software, allowing use, copy,

  10. Modify and distribute the software and files. Any
  11. Use of this software must place a copy of the The
  12. Above copyright notice. By the Software Huijia Studio
  13. Maintenance, if you have a queries please contact us.
  14. Thank.
  15. //
  16. This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
  17. All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
  18. HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
  19. //
  20. /////////////
  21. This file can only be loaded at the end of the program
  22. /*--__ Generating HTML files----beign----____*/
  23. if ($make _html)
  24. {
  25. $buffer = Ob_get_flush ();
  26. if ($go _html)//whether to go directly to the HTML file display or PHP read the content output (0:php read Output 1: Direct turn)
  27. {
  28. /*--__ handles the problem of seed size resulting from the creation of HTML files--______begin--_*/
  29. $search = Array (
  30. "/(src=|action=|href=|ajaxread\ () \"/ie ",
  31. "/\.\.\./e",
  32. "/\.\/\./e",
  33. "/\.\.\/http:\/\//ies",
  34. "/\.\.\/#/",
  35. "/\ ' \.\ '/E",
  36. "/\.\.\/javascript:/ies");

  37. $replace = Array (

  38. "' \\1\". /'",
  39. "'..'",
  40. "'.'",
  41. "'/http '",
  42. "#",
  43. "'\'.. \''",
  44. "' javascript: '");
  45. $buffer = Preg_replace ($search, $replace, $buffer);
  46. /*--__ handles the problem of seed size resulting from the creation of HTML files--______end--_*/
  47. }

  48. $fp = fopen (html_file, "w");

  49. if ($FP)
  50. {
  51. Fwrite ($fp, $buffer);
  52. Fclose ($FP);
  53. }
  54. }
  55. /*--__ Generating HTML files----beign----____*/
  56. ?>

Copy Code
  1. ///////////////////////////////////////////////////////////////////////////////

  2. //
  3. Zhangshulin-Hui Jia Studio
  4. //
  5. Module name:woods-thtml.php
  6. Abstract: Generating a static HTML handler header
  7. version:2.0
  8. Date 1006-11-25
  9. Copyright 1001-1006, Hoojar studio All rights Reserved
  10. //
  11. Copyright 1001-1006, All rights reserved for Hui Jia Studio

  12. The software for free software, allowing use, copy,

  13. Modify and distribute the software and files. Any
  14. Use of this software must place a copy of the The
  15. Above copyright notice. By the Software Huijia Studio
  16. Maintenance, if you have a queries please contact us.
  17. Thank.
  18. //
  19. This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
  20. All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
  21. HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
  22. //
  23. ///////////////////////////////////////////////////////////////////////////////
  24. This file can only be loaded at the beginning of the program
  25. Ob_start ();
  26. /*--determines if an HTML file has been generated and jumps to the HTML page if it is generated--begin--__*/
  27. $qstring = Isset ($_server["query_string"])? $_server["Query_string"]: "";
  28. if ($qstring)//program adds handle to get request
  29. {
  30. $qstring = str_replace ("=", "", $qstring);
  31. Define ("Html_file", "./h/{$efilename}-{$qstring}.html");
  32. }
  33. Else
  34. {
  35. Define ("Html_file", "./h/{$efilename}.html");
  36. }
  37. if (file_exists (html_file))
  38. {
  39. $LCFT = Filemtime (html_file);//last Create FILE time
  40. if ($LCFT + 3600) > Time ())//Determine if the last HTML file was generated in the past 1 times, if not directly output the file contents
  41. {
  42. if ($show _html)//whether to display in HTML static page (0 is not displayed in HTML display 1 in HTML display)
  43. {
  44. if ($go _html)//whether to go directly to the HTML file display or PHP read the content output (0:php read Output 1: Direct turn)
  45. {
  46. Header ("Location:".) html_file);//Direct turn
  47. }
  48. Else
  49. {
  50. Echo (file_get_contents (html_file));//Read display
  51. }
  52. Exit (0);
  53. }
  54. }
  55. }
  56. /*--determines if an HTML file has been generated and jumps to the HTML page if it is generated--end--__*/
  57. ?>

Copy Code
  1. ///////////////////////////////////////////////////////////////////////////////

  2. //
  3. Zhangshulin-Hui Jia Studio
  4. //
  5. Module Name:index.php
  6. Abstract: Home Information
  7. version:1.0
  8. Date 2006-11-7
  9. //
  10. Copyright 2001-2006, All rights reserved for Hui Jia Studio

  11. The software for free software, allowing use, copy,

  12. Modify and distribute the software and files. Any
  13. Use of this software must place a copy of the The
  14. Above copyright notice. By the Software Huijia Studio
  15. Maintenance, if you have a queries please contact us.
  16. Thank.
  17. //
  18. This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
  19. All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
  20. HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
  21. //
  22. ///////////////////////////////////////////////////////////////////////////////
  23. Require ("woods-thtml.php");//Generate HTML processing header
  24. if (count ($_get) < 1 && count ($_post) < 1) {require ("woods-thtml.php");} Generating an HTML processing header

  25. Require ("{$exec _file}");//Registry language definition file

  26. foreach ($lang as $key = $value)
  27. {
  28. $ATPL [Strtoupper ($key). " _lang "] = $value;
  29. }
  30. /*------List Common sense go up items--end---*/
  31. Include ("woods-templates.php");
  32. $TPL = new Woodstpl ("./templates/");
  33. $tpl->require_tpl ("header.html");
  34. $tpl->set_file ();
  35. $tpl->block ("Ebcorp", $scorp);
  36. $tpl->block ("NEWS", $news);

  37. $tpl->block ("PRODUCT", $product);

  38. $tpl->block ("Ebpname_msg", $spname);

  39. $tpl->block ("lore", $lore);

  40. $tpl->require_tpl ("footer.html");
  41. $tpl->parse ($ATPL, true);
  42. $TPL = NULL;
  43. /*--__ template operation----END----*/
  44. Require ("woods-bhtml.php");//Generate HTML processing tail
  45. ?>

Copy Code

you may be interested in the article:three ways to generate static pages in PHP and the code in detail PHP generates static page functions (php2html) example PHP method for generating static pages (three functions) PHP writes a static page generated by a class that generates HTML static pages for all content in the database to generate static pages on a regular basis. PHP generates a static page in a detailed tutorial on how to generate a pseudo-static page in Apache PHP writes about the static page of the spider Crawling record code smarty generated static Page method PHP generates a static page method Apache cannot access pseudo-static page solutions

  • 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.