<?php
header("Content-Type:text/html;charset=gbk");
require ("inc/function.php");
date_default_timezone_set('PRC');
$id=$_GET["id"];
axing_connect();
$sql="select * from base where id='$id'";
$result=mysql_query($sql);
$myrow=mysql_fetch_assoc($result);
?>
<?php
$title=FSubstr(($myrow[title]),0,10)."- 内容预览 - ".$webtitle;
$site_title=FSubstr(($myrow[title]),0,40);
if ($myrow[title]=='')
{
$site_title_else=FSubstr($myrow[url],0,24)."...";
}
else
{
$site_title_else=FSubstr($myrow[title],0,12)."...";
}
$site_url="<a href=".$myrow[url]." target=_blank>".$myrow[url]."</a>";
$site_keywords=$myrow[keywords];
$site_description=$myrow[description];
$site_content=$myrow[content];
$site_addtime=$myrow[addtime];
$site_id=$myrow[id];
$c_time=date("Y-m-d H:i:s");

$filemodel="template/site.html";                 #模板地址
$file=fopen($filemodel,"rb");                 #打开模板，得到文件指针
$temp=fread($file,filesize($filemodel));         #得到模板文件html代码



$temp=str_replace("{title}",$title,$temp);
$temp=str_replace("{site_title}",$site_title,$temp);
$temp=str_replace("{site_title_else}",$site_title_else,$temp);
$temp=str_replace("{site_url}",$site_url,$temp);
$temp=str_replace("{site_keywords}",$site_keywords,$temp);
$temp=str_replace("{site_description}",$site_description,$temp);
$temp=str_replace("{site_content}",$site_content,$temp);
$temp=str_replace("{site_addtime}",$site_addtime,$temp);
$temp=str_replace("{site_id}",$site_id,$temp);
$temp=str_replace("{c_time}",$c_time,$temp);


$filename="html/".$myrow[id].".htm";
fwrite(fopen("$filename","wb"),$temp);#$filename是静态页面的文件名
echo ("生成成功！<a href=html/".$myrow[id].".htm target=_blank>点击访问</a>");

mysql_free_result($result);
mysql_close();
?>