<!--#include file = "Startup.asp"-->
<!-- #include file="Function.asp" -->
<!-- #include file="char.inc" -->
<%

call adminer()
Call Header()
Call ComeUrl()
%>
<%
   const MaxPerPage=5   '单独页最大记录数 const 用来申明常量
   dim sql 
   dim rs
   dim totalPut   '总记录
   dim CurrentPage  '当前页次
   dim TotalPages   '总页数
   dim i
%>

<%
dim filename,id
set rs=server.createobject("adodb.recordset")
sql="select * from GuestBook order by id desc"
rs.open sql,oconn,1,1
%>
<script language="JavaScript1.2">
<!--
function confirm_delete(){
	if (confirm("你确定真的要这么做吗？")){
		return true;
	}
	return false;
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">



<!-- 判断是否有留言 -->
 <%
 if rs.eof and rs.bof then
 %>
 <style type="text/css">
<!--
.style1 {color: #FF0000}
-->
 </style>
<table width="100%"  border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td bgcolor="#FFFFFF"><div align="center">临时还没有任何留言！</div></td>
  </tr>
</table>
<%
response.end
end if
%>



<!-- 分页功能代码块,可独立使用 -->
<% 
 if not rs.eof then
  rs.MoveFirst  '注意放到前面来,否则到任何页总是在第一个记录上
  end if
  rs.pagesize=MaxPerPage  '设置每页最多显示多少条记录
  If trim(Request("Page"))<>"" then  '如果请求的页次不为空
	CurrentPage= CLng(request("Page"))   'clng是转换成长整型数据类型,并赋值到当前页次上
	If CurrentPage> rs.PageCount then  '如果当前页次大于总页数,则将最大页次赋值到当前页次上
		CurrentPage = rs.PageCount 
	End If 
Else 
	CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If 


 totalPut=rs.recordcount '将总记录赋值于TOTALPUT
	if CurrentPage<>1 then '如果当前页数不等于第一页
		if (currentPage-1)*MaxPerPage<totalPut then  '如果当前页减一乘以每页最大的记录数小于总记录的话
			rs.move(currentPage-1)*MaxPerPage  '相对当前记录数向后移动
			dim bookmark  '定义书签变量
			bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
		end if 
	end if

	dim n,k 
	if (totalPut mod MaxPerPage)=0 then  '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
		n= totalPut \ MaxPerPage
	else  
		n= totalPut \ MaxPerPage + 1  
	end if
%>
 



<!-- 将RS记录指针指向第一个记录，然后开始判断移动记录时，记录结尾是否为空，如果不为空接着移动指针，把所有数据都读取出来。直到结尾为空时，退出循环 -->
 <%
 id=(totalPut-MaxPerPage*(currentPage-1))+1 
i=0
Do While Not rs.EOF and i<MaxPerPage
id=id-1
%>
 
  <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
    <tr bgcolor="#F7F7F7">
      <td width="110"><div align="center">第<%=id%>位(<font color=red><%if rs("ispass")=True then response.write("通过") : else response.write("拒绝")%></font>)</td>
      <td><table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="15"><img src="images/posttime.gif" width="11" height="11"></td>
          <td>： <font color="#666666"><%=rs("DateTime")%></font> <div align="center"></div>
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"></div></td>
          <td><div align="right"><a href="mailto:<%=rs("Email")%>"><img src="images/MAIL.gif" width="18" height="18" border="0"></a></div></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td width="110" valign="top" bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><div align="center">[<span onClick='return confirm_delete()'><a href="guestbook_pass.asp?id=<%=rs("id")%>&amp;todo=pass">通过</a></span>]　[<span onClick='return confirm_delete()'><a href="guestbook_pass.asp?id=<%=rs("id")%>&amp;todo=nopass">拒绝</a></span>]</div></td>
        </tr>
        <tr>
          <td></td>
        </tr>
        <tr>
          <td height="35">
            <div align="center"><strong><%=rs("name")%></strong></div></td>
        </tr>
      </table>
      <div align="center">
        <%if session("username")<>"" and session("password")<>"" then%><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><div align="center">[<span onClick='return confirm_delete()'><a href="guestbook_del.asp?id=<%=rs("id")%>">删除</a></span>]　[<a href="GuestBook_Reply.asp?id=<%=rs("id")%>">回复</a>]</div></td>
          </tr>
        </table>
		<%end if%>
      </div></td>
      <td valign="top" bgcolor="#FFFFFF"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="table-layout:fixed;word-break:break-all">
        <tr>
          <td width="7%"><img src="images/9.gif"/></td>
          <td width="93%"><%=rs("title")%></td>
        </tr>
        <tr>
          <td colspan="2"><%=rs("content")%>
          </td>
        </tr>
      </table>
	  
	  <%
		if rs("reply")<>"" then%>
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="table-layout:fixed;word-break:break-all">
          <tr>
            <td><div align="center">
              <hr width="98%" size="1" noshade color="#cccccc">
             </div></td>
          </tr>
          <tr>
            <td><font color="#999999">站长回复：<%=htmlencode(rs("reply"))%></font></td>
          </tr>
        </table><%end if%>      </td>
    </tr>
  </table>
  
	  
	  
	  </td>
    </tr>
  </table>
  <br>
  <% i=i+1
  rs.movenext
  loop
  %>
  <br>
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><!-- 分页显示代码块 可独立使用,注意和上面分页功能代码配使用 -->
        <div align="center">当前第<font color="#ff0000"><%=currentpage%></font>页 总共<font color="#FF0000"><%=n%></font>页 共<font color="#FF0000"><%=rs.recordcount%></font>个留言 
          <%k=currentPage
		if k<>1 then
			response.write "[<b>"+"<a href='GuestBook.asp?page=1'>首页</a></b>] "
			response.write "[<b>"+"<a href='GuestBook.asp?page="&cstr(k-1)&"'>上一页</a></b>] "
		else
			Response.Write "[首页] [上一页]"
		end if
		if k<>n then
			response.write "[<b>"+"<a href='GuestBook.asp?page="&cstr(k+1)&"'>下一页</a></b>] "
			response.write "[<b>"+"<a href='GuestBook.asp?page="&cstr(n)&"'>尾页</a></b>] "
		else
			Response.Write "[下一页] [尾页]"
		end if
          
	%></td>
    </tr>
  </table>
<%
rs.close             
%>