PHP generates static page fopen fwrite

Source: Internet
Author: User

function makehtml ($msgContent, $filePath, $fileName) {//Generate HTML file


if (!is_dir ($filePath)) {@mkdir ($filePath);}


$handle = fopen (str_replace (' \ ', '). /', $filePath. $fileName), ' w+ ') or Die ("can ' t create file! $fileName");


Fwrite ($handle, $msgContent);


Fclose ($handle);


}

function Md5_filename ($fileid, $fileztype, $fileuid) {//File encryption method
return MD5 ($fileid. $fileztype. $fileuid). HTM ';
}

function GetSQL () {//How many generation HTM files at a time
Global $limit, $start, $id;
$sysType = ';
if (!empty ($id)) {
$sysType = "and Systype = $id";
}
$sql = "SELECT * from filecontent where siteindex=1 $sysType limit $start, $limit";
$result = mysql_query ($sql) or Die (' query error ');
while ($rs = Mysql_fetch_array ($result)) {
$fileName =md5_filename ($rs [0], $rs [' Z_type '], $rs [' Filesendid ']);
$path = Get_path ($rs [' Systype ']). $rs [' Z_type ']. ' /';
$parent = substr (GETCWD (), 0,strrpos (GETCWD (), ' \ ');
$filePath = $parent. ' \ '. $path;
makehtml ($rs [' content '], $filePath, $fileName);
}
Mysql_free_result ($result);
}

$info = "<script language=" javascript
   var pgo =0;
   function Jumpurl () {    
    document.write (' generated file <a href=make_html.php?id= $id &start= $start &limit= $limit &end= $end > If the browser does not respond please click here </a> ');
    location= ' make_html.php?id= $id &start= $start &limit= $limit &end= $end '; &NBSP;&NBSP;&NBSP;&NBSP
   }
   settimeout (' Jumpurl () ');
    </script> ";
 
  if ($start > $end) {
   die (' Complete all build tasks! ');
  } else {
   getsql ();  
   echo $info;   
  .}

Related Article

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.