function makeHtml($msgContent,$filePath,$fileName){//生成html文件
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){//文件加密方法
return md5($fileid.$fileztype.$fileuid).'.htm';
}
function getSql(){//一次多少生成htm文件
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('己生成文件<a href=make_html.php?id=$id&start=$start&limit=$limit&end=$end>如果浏覽器無反應請點擊這裡</a>');
location='make_html.php?id=$id&start=$start&limit=$limit&end=$end';
}
setTimeout('JumpUrl()',100);
</script>";
if($start>$end){
die('完成所有生成任務!');
} else {
getSql();
echo $info;
}