<!--#include file="conn.asp"-->
<%if session("ad_admin")="" then
response.redirect "login.asp"
end if

dim sql,rs
keyword=replace(trim(request.form("keyword")),"'","")
if keyword <>"" then
sql="select * from message where ( messagename like '%" & keyword & "%' or  messagelxfs like '%" & keyword & "%' or messagetext like '%" & keyword & "%' ) order by id desc"
else
sql="select * from message order by id desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1%>
<div align="center"> 
                 <table border="0" width="100%"  cellspacing="0" cellpadding="0">
                   <tr>
                     <td width="100%"><div align="center">
                         <table border="1" width="700" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0" bgcolor="#F3F3F3" style="word-break:break-all">
                           <tr bgcolor="#CAE2F8">
                             <td width="30" align="center"><p align="center">编号</p></td>
                             <td width="60" align="center" bgcolor="#CAE2F8">留&nbsp; 言&nbsp; 人</td>
                             <td width="130" align="center">联系方式</td>
                             <td width="325" bgcolor="#CAE2F8"><p align="center">留言内容</td>
                             <td width="20" align="center">IP</td>
                             <td width="35" align="center">来源</td>
                             <td width="70" bgcolor="#CAE2F8"><p align="center">留言日期</td>
                             <td width="28" align="center" bgcolor="#CAE2F8">管理</td>
                           </tr>
                           <%if rs.eof or rs.bof then
response.write"<tr><td colspan='8' bgcolor='#ffffff'><p align='center'><font color='red'>暂无留言！</font></p></td></tr><br>"
else
const maxperpage=10
dim currentpage
rs.pagesize=maxperpage
currentpage=request.querystring("pageid")
if isnumeric(currentpage)=false then
response.write "<script>alert('参数错误，关闭窗口！');window.close();</script>"
response.end
end if
if currentpage="" then
currentpage=1
elseif currentpage<1 then
currentpage=1
else
currentpage=clng(currentpage)
	if currentpage > rs.pagecount then
	currentpage=rs.pagecount
	end if
end if

dim totalput,n
totalput=rs.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
rs.move(currentpage-1)*maxperpage
i=0
do while i< maxperpage and not rs.eof%>
                           <tr>
                             <td><p align="center"><%=i+currentpage*maxperpage-maxperpage+1%></td>
                             <td valign="top"><%=rs("messagename")%> </td>
                             <td valign="top"><%=rs("messagelxfs")%></td>
                             <td valign="top"><%=rs("messagetext")%></td>
                             <td align="center" valign="top"><a href="http://www.ip138.com/ips.asp?ip=<%=rs("ip")%>" target="_blank">查</a></td>
                             <td align="center" valign="top"><a href="../show.asp?id=<%=rs("adid")%>" target="_blank">查看</a></td>
                             <td><p align="center"><font color="999999"><%=rs("messagedate")%></font></td>
                             <td align="center"><a href="delmessage.asp?id=<%=rs("id")%>" onClick="return confirm('确定要删除吗？\n\n该操作不可恢复！')"><font color="red">删除</font></a></td>
                           </tr>
                           <%i=i+1                     
    rs.movenext                                                               
    loop    
    rs.close  
    set rs=nothing                                                                                     
    conn.close   
    set conn=nothing                                                                                        
    end if%>
                       </table>
                     </div></td>
                   </tr>
                 </table>
                 <table border="0" width="100%" cellspacing="0" cellpadding="0">
                   <tr>
                     <td height="30"><p align="center">页数：<%=currentpage%>/<%=n%>
                             <%k=currentpage                                                                                         
   	if k<>1 then%>
                             <a href="?pageid=1">首页</a> <a href="?pageid=<%=k-1%>">上一页</a>
                             <%else%>
        首页&nbsp;上一页
        <%end if%>
        <%if k<>n then%>
        <a href="?pageid=<%=k+1%>">下一页</a> <a href="?pageid=<%=n%>">尾页</a>
        <%else%>
        下一页&nbsp;尾页
        <%end if%>
        共有 <%=totalput%> 条广告</p></td>
                   </tr>
                   <tr>
                     <td><form action="" method="post" name="search">
                         <p align="center"><font style="font-size:14px">关键字 </font>
                             <input  maxLength="20" name="keyword" onfocus="this.value=''" size="18"  value="<%=keyword%>">
                             <input  type="submit" value="搜索" style="font-size: 12px" name="search">
                       </form></td>
                   </tr>
                 </table> 
          </div>
