asp 由动态网页转变为静态网页的实现代码(3)
大陆区地址:浙江省义乌市经济开发区石鱼路123号8栋(稠江中学旁) 大陆区电话:0579-89960888 免费热线:4006-888048 <br />
</td>
</tr>
</tbody>
</table>
<!-- footer结束 -->
<span style="visibility: hidden;"><a href="http://www.51aiyaya.com" target="_blank"><strong>哎呀呀</strong></a>
<a href="http://www.51aiyaya.com" target="_blank">哎呀呀加盟</a>
<a href="http://www.51aiyaya.com" target="_blank">哎呀呀饰品</a> <script src="http://s23.cnzz.com/stat.php?id=1117055&web_id=1117055" language="JavaScript" charset="gb2312"></script></span>
</body>
</html>
2.处理的文件(asp)
复制代码 代码如下:
<!--#include file="conn.asp"-->
<%Server.ScriptTimeOut=99999999%>
<%
dim action,id,news
Layout="news"
id=request.QueryString("id")
action=request.QueryString("action")
select case action
case "add"
%>
<%
'全部生成html
case "htmlall"
set rs=server.CreateObject("adodb.recordset")
Sql = "Select id from news order by id"
rs.open sql,conn,1,1
do while not rs.eof
FsoFile "news",rs("id")
response.write"<div style='color:#003333;' align='center'>"&rs("id")&"新闻生成HTML成功!</div>"
rs.movenext
loop
rs.close
response.write"<div style='color:#FF0000;' align='center'>全部新闻生成HTML成功!</div></br>"
end select
%>
<%
'生成中文html
Function FsoFile(Layout,ID)
Dim Fso,FilePath,FsoF,FsoH,FsoRs,CreateFilePath
FSOCreateDIR "..\news\" & ID & ""
CreateFilePath = "..\news\" & ID & "" 'HTML所在文件夹
FilePath=Server.Mappath(CreateFilePath) & "\index.html" '定义生成html文件名
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set FsoH=Fso.OpenTextFile(Server.Mappath("..\templates\news_show.html"),1,true) '读取模版
Content = FsoH.ReadAll
Set FsoRs = Conn.Execute("select * from news where id="&id)
title=FsoRs("title")
demo=FsoRs("demo")
Content = Replace(Content,"{id}",FsoRs("id"))
Content = Replace(Content,"{title}",FsoRs("title"))
Content = Replace(Content,"{demo}",FsoRs("demo"))
Content = Replace(Content,"{webname}",webname)
Content = Replace(Content,"{icp}",icp)
Content = Replace(Content,"{dianhua}",dianhua)
Content = Replace(Content,"{dizhi}",dizhi)
Content = Replace(Content,"{qq}",qq)
Content = Replace(Content,"{alibaba}",alibaba)
Content = Replace(Content,"{tongji}",tongji)
FsoRs.Close
Set FsoRs=Nothing
set stm = server.createobject("ADODB.Stream")
stm.Charset = "gb2312" '定义编码
stm.Open
stm.WriteText content
stm.SaveToFile FilePath, 2
set stm = nothing
End Function
%>
<%
内容版权声明:除非注明,否则皆为本站原创文章。