<!--#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
'读取要生成的记录表

File = diarydir&"m\newlist.htm"
rijibody=LoadFile(File)
set rslist=server.CreateObject("adodb.recordset")
sql="select * from diary order by diaryid desc"
rslist.open sql,conn,1,1

booktotal=rslist.recordcount
pageno=Int(booktotal/diarylistno)
If pageno=0 Then pageno=1
rb=booktotal Mod diarylistno
If rb<>0 Then pageno=pageno+1
If requeset("page")="" then
k=pageno+1
else
k=requeset("page")
End if
Do While Not rslist.eof And cnt<=(diarylistno*30)'30是设定一次请求生成页面的循环次数，根据实际情况修改，如果太高了，记录集很多的时候会出现超时错误
rs.AbsolutePosition = start'最关键的一步,将指针指向start，start通过参数动态获得
j=0
booklistmmm=rijibody
For i=1 To diarylistno
booklistm="<table width='272' border='0' cellpadding='0' cellspacing='0'  id='table11'><tr bordercolor='DDE7AB'><td width='2'></td><td width='53'>{xq}</td><td width='170'><font color='#51300C'><a target='_blank' title='{title}' href='{diarydir}{htmldir}/riji{diaryid}.htm'>{title}</a></font></td><td width='26'><img src='{diarydir}diary/{tq}' border='0' align='middle'></td><td width='23'><a title='{time}' href='#'><img border='0' src='{diarydir}diary/TIME.gif' width='24' height='20'></a></td></tr></table>"
booklistm=replace(booklistm,"{title}",rslist("title"))
booklistm=replace(booklistm,"{diarydir}",diarydir)
booklistm=replace(booklistm,"{htmldir}",htmldir)
booklistm=replace(booklistm,"{tq}",rslist("tq"))
booklistm=replace(booklistm,"{time}",rslist("diarytime"))
Set rx = Server.CreateObject("ADODB.Recordset")
  sql="select * from xqlist where xqorder="&CInt(rslist("xq"))
   rx.open sql,conn,3,2
   xq=rx("xqcontent")
   rx.update
   rx.close
booklistm=replace(booklistm,"{xq}",xq)
booklistm=replace(booklistm,"{diaryid}",rslist("diaryid"))
booklistall=booklistall&booklistm
j=j+1
rslist.movenext
If rslist.eof Then Exit for
If j=diarylistno Then Exit For
Next

If booktotal<=diarylistno Then
Else
If j<>diarylistno Then
Randomize
set rslist1=server.CreateObject("adodb.recordset")
sqlrdn="select top "&(diarylistno-j)&" * from diary order by Rnd("&Rnd()&"-diaryid)"
rslist1.open sqlrdn,conn,1,1
Do While Not rslist1.eof
booklistm="<table width='272' border='0' cellpadding='0' cellspacing='0'  id='table11'><tr bordercolor='DDE7AB'><td width='2'></td><td width='53'>{xq}</td><td width='170'><font color='#51300C'><a target='_blank' title='{title}' href='{diarydir}{htmldir}/riji{diaryid}.htm'>{title}</a></font></td><td width='26'><img src='{diarydir}diary/{tq}' border='0' align='middle'></td><td width='23'><a title='{time}' href='#'><img border='0' src='{diarydir}diary/TIME.gif' width='24' height='20'></a></td></tr></table>"
booklistm=replace(booklistm,"{title}",gottopic(rslist1("title"),24))
booklistm=replace(booklistm,"{diarydir}",diarydir)
booklistm=replace(booklistm,"{htmldir}",htmldir)
booklistm=replace(booklistm,"{tq}",rslist1("tq"))
booklistm=replace(booklistm,"{time}",rslist1("diarytime"))
Set rx = Server.CreateObject("ADODB.Recordset")
  sql="select * from xqlist where xqorder="&CInt(rslist1("xq"))
   rx.open sql,conn,3,2
   xq=rx("xqcontent")
   rx.update
   rx.close
booklistm=replace(booklistm,"{xq}",xq)
booklistm=replace(booklistm,"{diaryid}",rslist1("diaryid"))
booklistall=booklistall&booklistm
rslist1.movenext
Loop
rslist1.close
Set rslist1=Nothing
End if
End If

k=k-1

maxpage=pageno
page=k
'if page="" or page=0 then page=1
'if page>maxpage then page=maxpage

if cint(page)=cint(maxpage) then
booklistp="<font color=#808080>首页&nbsp;上页&nbsp;</font>"
else
if page=maxpage then
booklistp="<a href='newlist.htm'> <font color='#5690BE'>首页</font></a> <a href='newlist.htm'><font color='#5690BE'>上页</font></a>"
else
booklistp="<a href='newlist.htm'> <font color='#5690BE'>首页</font></a> <a href='newlist_"&(page+1)&".htm'><font color='#5690BE'>上页</font></a>"
end if
end if

if cint(page)=1 then
booklistp=booklistp&" <font color='#808080'>下页</font> <font color='#808080'>尾页</font>"
else
if cint(page)<>cint(maxpage) then
booklistp=booklistp&" <a href='newlist_"&(page-1)&".htm'><font color='#5690BE'>下页</font></a> <a href='newlist_1.htm'><font color='#5690BE'>尾页</font></a>"
Else
booklistp=booklistp&" <a href='newlist_"&(page-1)&".htm'><font color='#5690BE'>下页</font></a> <a href='newlist_1.htm'><font color='#5690BE'>尾页</font></a>"
end if
end if
booklistp=booklistp&"<font color='#5690BE'> 当前页:"&(maxpage-page+1)&" 总页数:"

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>"
booklistmmm=replace(booklistmmm,"{bnav}",booklistbnav)
booklistmmm=replace(booklistmmm,"{rijibenlist}",booklistall)
booklistmmm=replace(booklistmmm,"{rijibenlistpage}",booklistp)
booklistmmm=replace(booklistmmm,"{jiazuono}",booktotal)

booklistall=""
If booktotal<=diarylistno Then
FilePath = diarydir&sitelistdir&"\"&"newlist.htm"
SaveToFile booklistmmm,FilePath
Else
booklistmmm=replace(booklistmmm,"{rijibenlistpage}",booklistp)
FilePath = diarydir&sitelistdir&"\"&"newlist_"&k&".htm"
SaveToFile booklistmmm,FilePath
If k=pageno Then
FilePath = diarydir&sitelistdir&"\"&"newlist.htm"
SaveToFile booklistmmm,FilePath
End If

End if
response.write "已生成第"&k&"页<br>"

cnt = cnt + 1 '计数器加1
start = start + 1 '指针变量递增
Loop

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

conn.close
set conn=nothing
%>




