将分页生成静态页面的ASP代码
一、
<% if request.Cookies("uid")="" then%>
<!--#include file="conn.asp"-->
<script>window.status="HTML文件生成中……"</script>
<%dim starttime,endtime
starttime=Timer%>
<%
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
.ActiveConnection=conn
.CommandType=&H0004 '存储过程
.CommandText="guestbookpro"
End With
Dim resultRS, resultArray
Set resultRS = cmd.Execute(, Null)
endtime=Timer
session("timeit")=endtime-starttime
If Not resultRS.EOF Then
resultArray = resultRS.GetRows()
End If
Set resultRS = Nothing
Set cmd = Nothing
session("select")="fso"
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Filestart="bodyhtml"
folders=server.mappath("./bodyhtml")
if (fs.FolderExists(folders)) then'判断文件夹是否存在
else
fs.CreateFolder(folders)'不存在则创建文件夹
end if
user=session("uid")
htmtext="<script>function doo(){window.open('help.htm','newwin','toolbar=no,scrollbars=yes')}</script><div align=left> <table border=0><tr><td> <a href=add.asp><img src=img/editnew.gif border=0></a> </td><td><div id=pagebar2></div><td></table></div>"
n=UBound(resultArray,2)+1
pagesize=8
yushu=n mod pagesize
if yushu=0 then
totalpage=fix(n/pagesize)
else
totalpage=fix(n/pagesize)+1
End If
on error resume next
for q=1 to totalpage
files=server.mappath("bodyhtml/bodyhtml"&q&".htm")
fs.deleteFILE files
next
for p=1 to totalpage
frompage=(p-1)*pagesize
topage=frompage+pagesize-1
if yushu=0 then
frompage=(p-1)*pagesize
topage=frompage+pagesize-1
else
frompage=(p-1)*pagesize
topage=frompage+pagesize-1
If p=totalpage Then
frompage=(p-1)*pagesize
topage=frompage+yushu-1
End if
end If
printHTML="<font color=white>从第"&frompage+1&"条----到-----第"&topage+1&"条----余数:"&yushu&"---页数总"&totalpage&"---总记录数:"&n&" 耗时:0"&left(session("timeit"),4)&"秒</font>"
For i = frompage To topage
if user=resultArray(1,i) or user="fishbone" then
edit=" <a href=editgb.asp?newsid="&resultArray(0,i)&"><img src=img/edit.gif border=0 alt=修改></a> <img src=img/dellit.gif border=0 onclick=javascript:if(confirm('删除[确定]?/隐藏[取消]?')){window.location='delgb.asp?del=sure&newsid="&resultArray(0,i)&"'}else{window.location='delgb.asp?newsid="&resultArray(0,i)&"'} alt=删除 style='cursor:hand'>"
else
edit=""
end if
printHTML=printHTML&"<table width=500 border=0 bgcolor=#999999 align=center cellspacing=1 celalpadding=4>"
printHTML=printHTML&"<tr bgcolor=#90b0d0>"
if resultArray(1,i)="系统消息" or resultArray(1,i)="master" then
printHTML=printHTML&"<td width=150 class=my1 align=center><font color=#000000>系统消息</font>"
else
printHTML=printHTML&"<td width=150 class=my1 align=center>" & "<a target=_blank href=theinfo.asp?name=" &resultArray(1,i)& " title="&resultArray(15,i)&">" &resultArray(1,i)& "</a>"
end if
printHTML=printHTML&"<td rowspan=3 width=350 class=my1>" &resultArray(2,i)
printHTML=printHTML&"<tr bgcolor=#90b0d0>"
printHTML=printHTML&"<td width=150 class=my1 align=center>" &resultArray(3,i)&"<br>"
if resultArray(11,i)="无法得到所在地" then
if resultArray(9,i)<>"" then
printHTML=printHTML&"<font color=red>"&resultArray(9,i)&"</font><br>"
printHTML=printHTML&"<font color=red>未能确定位置</font>"
else
printHTML=printHTML&"<font color=red>无法得到IP</font>"
end if
else
printHTML=printHTML&"<font color=green>"&resultArray(9,i)&"</font><br>"
printHTML=printHTML&"<font color=green>"&resultArray(11,i)&"</font>"
end if
printHTML=printHTML&"<tr bgcolor=#90b0d0>"
printHTML=printHTML&"<td width=150 class=my1 align=center>" & edit
printHTML=printHTML&"</table>"
printHTML=printHTML&"<br>"
next
htmtext2="<table border=0 align=center><tr><td align=center valign=middle><div id=pagebar><p align=center><a href=index.asp?page=1>首页</a> <a href=index.asp?page="&p-1&">上一页</a> <a href=index.asp?page="&p+1&">下一页</a> <a href=index.asp?page="&totalpage&">尾页</a> 总页数:"&p&"/"&totalpage&"</div></td></tr></table><script>document.all.pagebar2.innerHTML=document.all.pagebar.innerHTML</script>"
files=Filestart&p&".txt"'本文件名称
filez=folders&""&files'文本文件路径
checkfile=server.mappath("bodyhtml"&Filestart&p&".htm")'检查htm文件是否已经存在,是则删除
Set f2 = fso.GetFile(checkfile)
if (fs.FileExists(checkfile)) then'检查htm文件是否已经存在,是则删除
f2.delete'册除文件
end if'判断结束
Dim ts'定义写入文件对象
set ts = fs.createtextfile(filez,true) '开启写入文件内容****
ts.write(htmtext&printHTML&htmtext2)
ts.close
set ts=nothing '释放对象
Dim EditFile'定义改写文件变量
Set EditFile = fs.GetFile(filez)'设置改写文件对象
EditFile.name= left(EditFile.name,len(EditFile.name)-4)&".htm" '
next
response.write "ok"
set EditFile=nothing '释放对象
set fs=nothing'释放对象
conn.close
set conn=Nothing
%>
<%else
session("select")="fso"
end if%>