<!--#include file="../conn.asp" -->
<%
if session("admin")="" then
Response.Write("<script language=JavaScript>alert('对不起,您没有权限使用该功能!!');history.back();</script>")
response.end
end if%>
<%
Dim cnt:cnt = 1 '本轮循环计数器初始化
start = request("start") '获取本轮指针的开始位置
If IsNumeric(start) Then start = CLng(start) Else start=1
If start=0 Then start = 1 '如果start
'读取要生成的记录表
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from diary order by diaryid desc"
rs.open sql,conn,1,1
do While Not rs.eof And cnt<=50 '30是设定一次请求生成页面的循环次数，根据实际情况修改，如果太高了，记录集很多的时候会出现超时错误
'rs.absoluteposition=N 将记录指针移到数据表第N行
rs.AbsolutePosition = start '最关键的一步,将指针指向start，start通过参数动态获得

'此处写你生成静态文件的处理代码
userid=rs("userid")
title=rs("title")
content=rs("content")
xq=rs("xq")
mtype=rs("mtype")
bg=rs("bg")
tq=rs("tq")
diarytime=rs("diarytime")
typeid=rs("typeid")
display=rs("display")
did=rs("diaryid")
Set r = Server.CreateObject("ADODB.Recordset")
  sql="select * from diaryuser where userid="&userid
   r.open sql,conn,1,3
   bookname=r("bookname")
   user=r("username")
   r.close
if mtype="5" then 
bg=replace(bg,"play/jd/5","")
bg=replace(bg,".jpg","")
mtype=mtype&bg
screenww=(Request.Cookies("screenw")-1024)/2
end if
File = diarydir&"m\riji"&mtype&".htm"
rijibody=LoadFile(File)

Set r = Server.CreateObject("ADODB.Recordset")
  sql="select * from diarytype where id="&typeid
   r.open sql,conn,1,1
typeidname=r("type")
r.close

Set rx = Server.CreateObject("ADODB.Recordset")
  sql="select * from xqlist where xqorder="&CInt(xq)
   rx.open sql,conn,3,2
   xq=rx("xqcontent")
   rx.update
   rx.close

'rijibody=rijire(rijibody)
rijibody=replace(rijibody,"{title}",title)
rijibody=replace(rijibody,"{emot}",xq)
rijibody=replace(rijibody,"{weather}",tq)
rijibody=replace(rijibody,"{class}","<a target=_blank href='../?i="&userid&"&fid="&typeid&"'>"&typeidname&"</a>")
rijibody=replace(rijibody,"{diaryname}",bookname)
rijibody=replace(rijibody,"{writer}",user)
rijibody=replace(rijibody,"{time}",diarytime)
rijibody=replace(rijibody,"{content}",content)
rijibody=replace(rijibody,"{diarynameid}",userid)
rijibody=replace(rijibody,"{diaryid}",did)
rijibody=replace(rijibody,"{topbg}",bg)
rijibody=replace(rijibody,"{diarybg}",diarybg)
rijibody=replace(rijibody,"{diarydir}",diarydir)
booklistbnav="<span id='navi'><a href='"&diarydir&"index.asp'>首页</a>　<a href='"&diarydir&sitelistdir&"/NewList.htm'>最新日记</a> <a href='"&diarydir&sitelistdir&"/goodList.htm'>佳作推荐</a> <a href='"&diarydir&sitelistdir&"/Newbook.htm'>最新日记本</a> <a href='"&diarydir&sitelistdir&"/BookOrder.htm'>日记本排行</a> <a href='"&diarydir&"u/search.asp'>日记搜索</a> <a href='/mybook.asp'>管理日记</a> <a href='/?i=128' target='_blank'>服务中心</a></span>"
rijibody=replace(rijibody,"{bnav}",booklistbnav)
'response.write rijibody
if mtype="5" then rijibody=replace(rijibody,"{screenww}",screenww)
FileName = "riji"&did&".htm"
FilePath = diarydir&htmldir&"\"&FileName
SaveToFile rijibody,FilePath

cnt = cnt + 1 '计数器加1
start = start + 1 '指针变量递增
rs.movenext
loop

If Not rs.eof Then '通过刷新的方式进行下一轮请求,并将指针变量start传递到下一轮
response.write "<meta http-equiv='refresh' content='0;URL=?start="&start&"'>"
response.write "已生成"&start-1&"个页面！"
Else
response.write "全部生成完毕！共生成"&start-1&"个页面！"
End if
rs.close
set rs=nothing

conn.close
set conn=nothing
%>




