<%Option Explicit%>
<!--#include file="conn.asp"-->
<%Dim pageno,re,rc,totalrec,KeyWords,RightId,SerchType,mpage,SerchWhere,SerchMain,MainChecked
		KeyWords=replace(request("keywords"),"'","&#39;")
		SerchType=request("serchtype")
		SerchMain=request("serchmain")
    pageno=request.querystring("pageno")
    if SerchMain=1 then
    	SerchMain="SubMainNumber=0 and"
    	MainChecked="CHECKED"
    else
    	SerchMain=""
    	MainChecked=""
    end if
    Select Case SerchType
    Case 1
    SerchWhere="留言作者"
    SqlData="select id,SubMainNumber,istop,name,face,SubMain,writetime,report,counter,lastname,lasttime from Data where " & SerchMain & " name like '%" & KeyWords & "%' order by istop desc,lasttime desc"
    Case 2
    SerchWhere="留言主题"
    SqlData="select id,SubMainNumber,istop,name,face,SubMain,writetime,report,counter,lastname,lasttime from Data where " & SerchMain & " SubMain like '%" & KeyWords & "%' order by istop desc,lasttime desc"
    Case 3
    SerchWhere="留言内容"
    SqlData="select id,SubMainNumber,istop,name,face,SubMain,writetime,report,counter,lastname,lasttime from Data where " & SerchMain & " ly like '%" & KeyWords & "%' order by istop desc,lasttime desc"
    Case else
    SqlData="select id,SubMainNumber,istop,name,face,SubMain,writetime,report,counter,lastname,lasttime from Data where " & SerchMain & " (SubMain like '%" & KeyWords & "%' or ly like '%" & KeyWords & "%' or name like '%" & KeyWords & "%') order by istop desc,lasttime desc"
    End Select
    Rs.open SqlData,conn,1,1
DoWhat="留言搜索"
call HeadHtml()'网页头过程
response.write "<table width=780 border=1 cellspacing=1 cellpadding=2 align=center bordercolor=#FFFFFF>"&_
"<form method=post action=""?"" name=""serchform""><tr bordercolor=#FFFFFF>"&_
"<td colspan=5><img src=""images/serch.gif"" border=0><input type=text szie=25 name=""keywords"" value=""" & KeyWords & """>"&_
" <input type=submit name=""submit"" value=""搜 索"" onclick=""if(serchform.keywords.value==''){alert('请输入搜索关键字!');return (false);} return (true)"">"&_
" 搜索范围：<input type=radio name=""serchtype"" CHECKED value=1>作者 <input type=radio name=""serchtype"" value=2>主题 <input type=radio name=""serchtype"" value=3>内容 <input type=radio name=""serchtype"" value=0>所有范围"&_
" <input type=checkbox " & MainChecked & " name=""serchmain"" value=1>只搜索主题（不在回复中搜索）</td></tr></form>"
if KeyWords>"" then
	response.write "<tr bordercolor=#FFFFFF><td colspan=5 align=center>以下是所有 <font color=RED>" & SerchWhere & "</font> 包含关键字(词) <font color=RED>" & KeyWords & "</font> 的留言</td></tr>"
end if
if Rs.eof and Rs.bof then
	response.write "<tr bordercolor=#FFFFFF><td height=50 colspan=5 align=center>对不起，没有找到相关内容的留言！"
else
		totalrec=rs.recordcount
		Rs.pagesize=HomePageNO
    mpage=Rs.pagecount
    if isempty(pageno) or (not isnumeric(pageno)) then 
    	pageno=1
    elseif cint(pageno)<1 or cint(pageno)>mpage then
    	pageno=1
    end if
    Rs.absolutepage=pageno
response.write "</td></tr><tr bordercolor=#FFFFFF>"&_
    "<td width=30 align=center bgcolor=#DEE5EF><B>状态</B></td>"&_
    "<td width=400 align=center bgcolor=#FFFFFF><B>主题</B></td>"&_
    "<td width=85 align=center bgcolor=#DEE5EF><B>作者</B></td>"&_
    "<td width=65 align=center bgcolor=#FFFFFF><B>回复/人气</B></td>"&_
    "<td width=200 bgcolor=#DEE5EF align=center><B>最后更新/回复人</B></td></tr>"
rc=Rs.pagesize
re=1
do while not Rs.eof and rc>0
if Rs("SubMainNumber")>0 then RightId=Rs("SubMainNumber") else RightId=Rs("id")
response.write "<tr bordercolor=#FFFFFF><td align=center bgcolor=#DEE5EF><img src=""images/"
		if Rs("istop")=1 then
    	response.write "folder_top.gif"" border=0 alt=""置顶主题"">"
    elseif Rs("report")>=HotPageNO then 
    	response.write "folder_hot.gif"" border=0 alt=""热门主题"">"
	  elseif year(Rs("writetime"))=year(Now()) and (month(Rs("writetime"))=month(Now()) and int(day(Rs("writetime")))+2>int(day(Now()))) then
	    response.write "folder_new.gif"" border=0 alt=""新发表的主题"">"
    else
   		response.write "folder_old.gif"" border=0 alt=""开放主题"">"
    end if
response.write "</td><td bgcolor=#FFFFFF><img src=""images/"
    if Rs("report")>0 then response.write "plus.gif"" border=0 alt=""有回复"">" else response.write "minus.gif"" border=0 alt=""无回复"">"
response.write "<img src=""face/face" & Rs("face") & ".gif"" border=0> <a href=""dis.asp?id=" & RightId & """ target=_blank>"
    if len(Rs("SubMain"))>23 then
    	response.write ChkBadWords(left(Rs("SubMain"),23)) & "..."
    else
    	response.write ChkBadWords(Rs("SubMain"))
    end if
response.write "</a></td><td align=center bgcolor=#DEE5EF>" & Rs("name") & "</td>"&_
    	"<td align=center bgcolor=#FFFFFF>" & Rs("report") & "/" & Rs("counter") & "</td>"&_
    	"<td bgcolor=#DEE5EF align=center>" & Rs("lasttime") & "/" & Rs("lastname") & "</td></tr>"
Rs.movenext
re=re+1
rc=rc-1
loop
response.write "<tr><td colspan=2>页次：" & pageno & "/" & mpage & "页 每页" & HomePageNO & "条留言 总共" & totalrec & "条留言</td>"&_
"<td align=right colspan=3>分页：[ "
for ii=1 to mpage
  If ii=cint(pageno) then
    response.write "<font color=#808080>" & ii & "</font> "
  Else
    response.write "<b><a href=""?pageno=" & ii & "&keywords=" & KeyWords & "&serchtype=" & SerchType & """>" & ii & "</a></b> "
	End If
next
response.write " ]"
end if
Rs.close
set Rs=nothing
conn.close
set conn=nothing
response.write "</td></tr></table>"
call FootHtml()		'网页尾过程%>