<%@language=vbscript codepage=936 %>
<%
response.buffer=true	
Const PurviewLevel=2
%>
<!--#include file="inc/conn1.asp"-->
<!--#include file="inc/Conn_User.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/ubbcode.asp"-->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>留言管理</title>


<style type="text/css">
BODY {
	margin-left: 8px;
	margin-top: 0px;
	margin-right: 8px;
	margin-bottom: 8px;
}
</style>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled==false)
       e.checked = form.chkAll.checked;
    }
  }
function ConfirmDel()
{
   if(confirm("确定要删除吗？一旦删除将不能恢复！"))
     return true;
   else
     return false;
	 
}

</SCRIPT>
<link href="new/css.CSS" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="1" bgcolor="#D6D5D9"></td>
    <td height="34" align=left bgcolor="#F8F8F9"><table width="100%">
      <tr>
        <td width="80"><strong>&nbsp;&nbsp;管理导航：</strong></td>
        <td><a href="admin_guest.asp">留言管理</a></td>
      </tr>
    </table></td>
    <td width="1" bgcolor="#D6D5D9"></td>
  </tr>
  <tr>
    <td width="1" bgcolor="#F8F8F9"></td>
    <td height="1" bgcolor="#D6D5D9" ></td>
    <td width="1" bgcolor="#F8F8F9"></td>
  </tr>
</table>
<table width="100%" height="8" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<%
myPagesize=10
set rs=server.createobject("adodb.recordset")
rs.open "select * from usercomment  order by CommentID desc",conn,1,1
call myPages(rs,myPagesize)
%><%if rs.recordcount=0 then%>
<table width="100%" cellpadding="5" cellspacing="1" bgcolor="bcbcbc">
	<tr>
	  <Td align=center bgcolor=ffffff><br>
      暂时没有任何留言<br>
      <br></Td>
	</tr></table><%else%>
 <%line=myPagesize
do while not rs.eof and line>0
%><table width="100%" cellpadding="7" cellspacing="1" bgcolor="bcbcbc">
<tr><td bgcolor="#f2f2f2" colspan="2"><%
set userrs=server.createobject("adodb.recordset")
sql="select * from [user] where UserName='"&rs("username")&"' order by userid desc"
userrs.open sql,Conn_User,1,1

%>
    <%if rs("usertype")=1 then%>
&nbsp;会员：【<b><a href=user.asp?userid=<%=userrs("userid")%>&mdid=indexd&htm=indexs.asp?userid=<%=userrs("userid")%> target=_blank><%=rs("username")%></a></b>】
<% else %>
&nbsp;游客：【<B><span title="姓名：<%= rs("UserName")&vbcrlf%>信箱：<%=  rs("Email")&vbcrlf%>OICQ：<%=  rs("oicq")&vbcrlf%>主页：<%=rs("homepage")%>"  style=cursor:hand><%=rs("username")%></span></b>】
<%end if%>
于<%=year(rs("WriteTime"))%>-<%=month(rs("WriteTime"))%>-<%=day(rs("WriteTime"))%>留言</Td>
  <td width="60" align="center" bgcolor="#f2f2f2"><a href="admin_guestdel.asp?CommentID=<%=rs("CommentID")%>">删除留言</a></Td>
</tr><Tr>
  <td colspan="2" bgcolor="ffffff">&nbsp;内容：  <%=ubbcode(dvHTMLEncode(rs("Content")))%></td>
    <td align="center" bgcolor="ffffff"><a href="admin_usergbook.asp?CommentID=<%=rs("CommentID")%>&userid=<%=rs("GuserID")%>">修改内容</a></td>
    </Tr><%if rs("ReplyContent")<>"" then%>
            
      <Tr>
        <td height="26" colspan="2" bgcolor="ffffff">
            &nbsp;回复：  <%=rs("ReplyContent")%>        </td>
        <td height="26" align="center" bgcolor="ffffff"><a href="admin_usergbookh.asp?CommentID=<%=rs("CommentID")%>&userid=<%=rs("GuserID")%>">修改回复</a></td>
      </Tr><%else
		  end if%></table>
 <table width="100%" height="8" border="0" cellpadding="0" cellspacing="0">
   <tr>
     <td></td>
   </tr>
 </table>
  <%
  userrs.close
set userrs=nothing%>
 <%rs.movenext
   line=line-1
loop
  %>

 
 <%end if%>
 <%if rs.recordcount<>0 then%><center><%call listpages(mycondition)%></center><%end if%>
 <%

rs.close
set rs=nothing%>

<%sub listpages(mycondition)
	response.write "<table height=22  border=0 cellpadding=0 cellspacing=0><Tr><td><table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td height=3></td></tr></table>"
	if pages<1 then
		exit sub
	end if
	
	
	if p>0 then
		response.write	"<a href="&request.ServerVariables("script_name")&"?userid="&userid&"&currentpage=10&p="&p-1&mycondition&"><img src=user/prepre.gif alt=前十页 border=0></a>&nbsp;&nbsp;&nbsp;"
    else
	response.write	"<img src=user/prepre.gif alt=前十页 border=0>&nbsp;&nbsp;&nbsp;"
    end if
	'-------------------下面写出当前十个页码
	response.write "</td><td><img src=user/lined.gif border=0><img src=user/k.gif border=0 width=5>"
	for i=1 to 10
		if (p*10+i)>pages then exit for
		if currentpage=i then
		
			response.write "<b><a style='color:ff6600'"
		else
			response.write "<a"
		end if 
		response.write " href="&request.ServerVariables("script_name")&"?userid="&userid&"&currentpage="&i&"&p="&p&mycondition&"><font class=no >"&(p*10+i)&"</font></a></b>&nbsp;&nbsp;<img src=user/lined.gif border=0><img src=user/k.gif width=5 border=0>"	
     next
	 response.write "</td><td><table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td height=3></td></tr></table>"
	 '--------------------察看下十页的连接
    if (p*10+10)<pages then
		response.write "<img src=user/k.gif border=0><a href="&request.ServerVariables("script_name")&"?userid="&userid&"&currentpage=1&p="&p+1&mycondition&"><img src=user/nextnext.gif alt=后十页 border=0></a>&nbsp;&nbsp;" 
		else
		response.write "<img src=user/k.gif border=0><img src=user/nextnext.gif alt=后十页 border=0>&nbsp;&nbsp;"
	end if
	'-----------------------------------------------上下页导航
	response.write "&nbsp;</td>"
	

	  response.write "</tr></table>"
end sub

sub myPages(myRS,mysize)  '------mysize为内部变量（主页面没有定义），myRS为主页面传递过来的RS对象（地址传递）
	if myRS.eof and myRS.bof then str="没有纪录"
	if str="" then
		if mysize="" or NOT IsNumeric(mysize) then
			mysize=15
		end if
		myRS.PageSize=mysize
		pages=myRS.pagecount
		records=myRS.recordcount
		On Error Resume Next '取得数字
		currentPage=request("currentPage")
		if currentPage="" then
			currentPage=1
		end if
		currentPage=CInt(currentPage)
		if Err.Number <> 0 Then
			currentPage=1
			Err.Clear
		end if
		if currentPage<1 then
			currentPage=1
		elseIf currentPage>10 then
			currentPage=10
		end if
		'----------------处理p
		p=request("p")
		if p="" then
			p=0
		end if
		p=CLng(p)
		if Err.Number <> 0 Then
			p=0
			Err.Clear
		end if
		if p<0 then
			p=0
		end if
		'--判断是否出了页数范围
		nowPage=p*10+currentPage
		if nowPage>pages then
			p=(pages-1)\10
			currentPage=((pages-1) mod 10)+1
		end if
		myRS.absolutepage=p*10+currentPage
	else
	   currentPage=1
	   records=0
	   pages=1
	end if
end sub

dim pages,records,currentPage,p '--------定义变量，这些变量在主页面中，进行地址传递%>
</body>
</html>
