<%
sub asp2htm()
’定义Recordset对象
Set rs=Server.CreateObject("ADODB.Recordset")
’设置rs的ActiveConnection属性,绑定到连接
Set rs.ActiveConnection = Conn
’设置游标类型
rs.CursorType = 3
sql="select * from article where title=’"&title&"’"
rs.open sql
do while not rs.eof
ArticleID=rs("ArticleID")
title=rs("title")
author=rs("Author")
copyfrom=rs("copyfrom")
hits=rs("hits")
updatetime=rs("updatetime")
editor=rs("editor")
content=rs("content")
Key=rs("key")
content = replace(content,"../UploadFiles/","../../UploadFiles/") ’解决图片路径问题
’title = Request("title") ’获取标题
’content = Request("content") ’获取内容
’path = Server.MapPath("html") ’保存路径
tnow = now()
fname = year(tnow)&FormatNumber(month(tnow)/100,2,Flase)&FormatNumber(day(tnow)/100,2,Flase)&FormatDateTime(tnow,3)&ArticleID
fname = replace(fname,".","")
fname = replace(fname,":","")
fname = fname & ".htm" ’生成HTML文件的文件名
Set fso = CreateObject("Scripting.FileSystemObject")
Set ftemp = fso.OpenTextFile(Server.MapPath("asp2htm/templates.txt"), 1)
TempData = ftemp.ReadAll ’读取模板内容
ftemp.Close
TempData = Replace(TempData,"#title#",title) ’写入标题
TempData = Replace(TempData,"#content#",content) ’写入内容
TempData = Replace(TempData,"happig",author)
TempData = Replace(TempData,"本站原创",copyfrom)
’TempData = Replace(TempData,"#click#",hits)
TempData = Replace(TempData,"2006-11-9 15:56:13",updatetime)
TempData = Replace(TempData,"admin",editor)
TempData = Replace(TempData,"7744",articleid)
TempData = Replace(TempData,"|asp,自动生成,html,优化|",Key)
TempData = Replace(TempData,"7744",ArticleID)
Set fhtml = fso.CreateTextFile(path&"\"&fname)
fhtml.WriteLine TempData ’保存文件
fhtml.Close
Set fso = nothing
sql="update Article set content=’"&fname&"’ where articleid="&cint(articleid)
cmd(sql)
rs.movenext
response.Write("添加"&title&"成功<br>")
response.Clear()
Response.Flush()
loop
call cdb(rs)
’将信息存入数据库略。
end sub
%> |