<?PHP
require_once('../fun.inc.php');
$filename=lstree("../workimg/","jpg");
//print_r($filename);
$nums=count($filename); //这里是统计共有多少个文件
//print_r($nums)
for($i=0;$i<$nums;$i++)
{ //下面的15是../workimg/ + jpg 的字符长度
$img=substr($filename[$i],11,strlen($filename[$i])-15);
//print_r($img);
$len=strlen($img);
$toseries=substr($img,0,$len-1);
$row=substr($img,$len-1,$len)-1;
$seriesDetail = getDetailBySeriesId($toseries,'seriesDetail');
$str="<strong>P".$toseries." ".($row+1)."-".$seriesDetail[$row]->name."</strong>";
//读取模板文件
$tmpfile="temp.html";
$fp = fopen ($tmpfile,"r");
$content = fread ($fp,filesize ($tmpfile));
$content = str_replace ('<{$str}>',$str,$content);
$content = str_replace ('<{$img}>',$img,$content);
fclose($fp);
//print_r($content);
$tofile = $img.".htm";
$handle = fopen ($tofile,"w"); //打开文件指针,创建文件
// //////// 检查文件是否被创建且可写
//
if (!is_writable ($tofile)){
die ("File:".$tofile."can not write!");
}
if (!fwrite ($handle,$content)){ //将信息写入文件
die ("Create File".$tofile."Lost!");
}
fclose ($handle); //关闭指针
echo $filename[$i] ." to ".$img.".htm ===> OK !"."<br>";
}
?>
|