<!--#include file="bbstop.asp"-->
<%
	itype=request("type")
	strCompare=request("selCompare")
	topic=trim(request("txtTopic"))
	announceid=trim(request("aid"))
	if isempty(request("page")) or isNull(request("page")) or (request("page")="")  then
		currentPage=1
	else
		if isInteger(request("page")) then
			currentPage=cint(request("page"))
        	else
			currentPage=1
        	end if
        	if err.number<>0 then 
			err.clear
            		currentPage=1
        	end if
	end if
	if memberclass = user_level7 or memberclass = user_level8 or memberclass = user_level9 then
		guestlist=""
	else
		guestlist=" bbs_board.lockboard<>2 and "
	end if
	if request("selBoard")<>"" then bID=request("selBoard")
	
	if bID<>"" then
		call chkIntRequest()
	end if

	sub chkIntRequest()
		if not isInteger(bid)  then
			Response.Write "版面ID必须是整数"
			call endConnection()
			Response.End 
		end if
	end sub
	sql=""
	set rs=server.createobject("adodb.recordset")
	select case itype
	case 1
	if request("txtTopic")<>"" then sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where (" & translate(topic,"topic") & ") and "&guestlist&" bbs_content.boardID="&cstr(bid)&" and bbs_content.boardid=bbs_board.boardid ORDER BY bbs_content.announceID desc"
	searchname="按主题查询"
	case 2
	if request("txtuser")<>"" then sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where bbs_content.username like '%"&trim(request("txtuser"))&"%' and "&guestlist&" bbs_content.boardID="&cstr(bid)&" and bbs_content.boardid=bbs_board.boardid ORDER BY bbs_content.announceID desc"
	searchname="按用户名查询"
	case 3
	if request("txtCon")<>"" then sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where bbs_content.body like '%"&trim(request("txtCon"))&"%' and "&guestlist&" bbs_content.boardID="&cstr(bid)&" and bbs_content.boardid=bbs_board.boardid ORDER BY bbs_content.announceID desc"
	searchname="按内容查询"
	case 4
	if request("aid")<>"" then sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where bbs_content.announceID "&request("selCompare")&cstr(request("aid"))&" and "&guestlist&" bbs_content.boardID="&cstr(bid)&" and bbs_content.boardid=bbs_board.boardid ORDER BY bbs_content.announceID desc"
	searchname="按贴子ID查询"
	case 5
					tl=1
					timeLimited=request("selTimeLimit")
					if timeLimited="一天" then tl=1
					if timeLimited="一周" then tl=7
					if timeLimited="一月" then tl=30
					if timeLimited="一年" then tl=365
					'shijiancha=cdate(now()-tl)
	sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where dateandtime>='"&cdate(now()-tl)&"' and "&guestlist&" bbs_content.boardid="&cstr(bid)&" and bbs_content.boardid=bbs_board.boardid order by bbs_content.announceid desc"
	searchname="按日期查询"
	case 6
		select case cstr(strcompare)
			case "1"
		sql="select top 10 bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where "&guestlist&" bbs_content.boardid=bbs_board.boardid order by bbs_content.hits desc"
		searchname="按点击查询"
			case "2"
		sql="select top 50 bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where "&guestlist&" bbs_content.boardid=bbs_board.boardid order by bbs_content.announceid desc"
		searchname="最新贴子查询"
		end select
	case 7
	if request("name")<>"" then sql="select bbs_content.locktopic,bbs_content.boardid,bbs_content.rootid,bbs_content.announceid,bbs_content.body,bbs_content.Expression,bbs_content.topic,bbs_content.username,bbs_content.child,bbs_content.hits,bbs_content.dateandtime,bbs_board.lockboard from bbs_content,bbs_board where bbs_content.username like '%"&trim(request("name"))&"%' and "&guestlist&" bbs_content.boardid=bbs_board.boardid ORDER BY bbs_content.announceID desc"
	searchname="用户发表文章查询"
	end select
	if sql="" then
		Errmsg=Errmsg+"<br>"+"<li>请指定查询条件。"
		call error()
		response.end
	end if
'	response.write sql
'	response.end
%>
<%
	rs.open sql,conn,1,1

	if err.number<>0 then 
		Errmsg=Errmsg+"<br>"+"<li>数据库出错，查询失败。"
		call error()
		err.clear
	else
		if rs.eof and rs.bof then
		Errmsg=Errmsg+"<br>"+"<li>没有找到您要查询的内容。"
		call error()
		else
	      		totalrec=rs.recordcount 
      			if currentpage<1 then 
          			currentpage=1 
      			end if 

      			if (currentpage-1)*MaxAnnouncePerPage>totalrec then 
	   			if (totalrec mod MaxAnnouncePerPage)=0 then 
	     				currentpage= totalrec \ MaxAnnouncePerPage 
	   			else 
	      				currentpage= totalrec \ MaxAnnouncePerPage + 1 
	   			end if 
      			end if 
       			if currentPage=1 then 
            			call searchinfo()
       			else 
          			if (currentPage-1)*MaxAnnouncePerPage<totalrec then 
            				rs.move  (currentPage-1)*MaxAnnouncePerPage 
            				call searchinfo()
        			else 
	        			currentPage=1 
           				call searchinfo()
	      			end if 
	   		end if 
			call listPages3()
		end if
	end if
	set rs=nothing

	sub searchinfo()
%>
<table cellpadding=0 cellspacing=0 border=0 width=762 class=pian align=center>
<tr><td height=25 bgcolor=#ffffff align=center>共查询到<font color=#ff3300><%=totalrec%></font>个结果
</td></tr>
</table>
<TABLE bgColor="#efefef" border=0 cellPadding=0 cellSpacing=0 width=762 class=pian  align=center>
  <TBODY>
  <TR bgcolor=#66cc00>
    <TD align=middle height=25 width=32>状态</TD> 
    <TD align=middle width=*>主 题  (点心情符为开新窗浏览)</TD> 
    <TD align=middle width=80>作 者</TD> 
    <TD align=middle width=64>回复/人气</TD>
    <TD align=middle width=195>作者 | 发表时间</TD>
</TBODY></TABLE>
<TABLE bgColor="#efefef" border=0 cellPadding=0 cellSpacing=1 width=762 class=pian align=center>
<TBODY>
<%
       do while not rs.eof
%>
<TR> 
    <TD align=middle bgColor="#ffffff" width=32>
<%if rs("locktopic")=1 then%><img src=images/lockfolder.gif alt="本主题已锁定"><%else%><%if rs("child")>=10 then%><img src=images/hotfolder.gif><%else%><img src=images/folder.gif><%end if%><%end if%></font>
    </TD> 
    <TD width=*><a href='dispbbs.asp?boardID=<%=rs("boardID")%>&RootID=<%=rs("RootID")%>&ID=<%=rs("announceID")%>' target=_blank><img src='images/<%if instr(rs("Expression"),"face")>0 then%><%=rs("Expression")%><%else%>face1.gif<%end if%>' border=0 alt="开新窗口浏览此主题"></a> <a href='dispbbs.asp?boardID=<%=rs("boardID")%>&RootID=<%=rs("RootID")%>&ID=<%=rs("announceID")%>'><%if rs("topic")="" then%><%=left(htmlencode(rs("body")),26)%>...<%else%><%=htmlencode(rs("topic"))%><%end if%></a></TD> 
    <TD align=middle width=80><a href='dispuser.asp?name=<%=htmlencode(rs("username"))%>' TARGET=_BLANK><%=htmlencode(rs("username"))%></a></TD> 
    <TD align=middle width=64><%=rs("child")%>/<%=rs("hits")%></TD> 
    <TD width=195>  <IMG border=0 src="images/lastpost.gif">
<%=FormatDateTime(rs("dateandtime"),2)%>&nbsp;<%=FormatDateTime(rs("dateandtime"),4)%>
&nbsp;<font color=#990000>|</font>&nbsp;
<a href='dispuser.asp?name=<%=htmlencode(rs("username"))%>' TARGET=_BLANK><%=htmlencode(rs("username"))%></a>
</TD></tr>
<%
	  i=i+1
	  if i>=MaxAnnouncePerPage then exit do
          rs.movenext
        loop
	rs.close %>
</TBODY></TABLE>
<%	end sub

	sub listPages3()
	'on error resume next

  	'dim n
  	if totalrec mod MaxAnnouncePerPage=0 then
     		n= totalrec \ MaxAnnouncePerPage
  	else
     		n= totalrec \ MaxAnnouncePerPage+1
  	end if
%>
   <script language="Javascript">
	function viewPage(ipage){
        document.frmList2.Page.value=ipage
        document.frmList2.submit() 
	}
   </script>
<table border="0" cellpadding="0" cellspacing="0" width=762 class=pian align="center">
<form method="post" action="queryresult.asp" name="frmList2">
<input type=hidden name=type value="<%=itype%>">
<input type=hidden name=txtTopic value="<%=request("txtTopic")%>">
<input type=hidden name=selBoard value="<%=bID%>">
<input type=hidden name=txtUser value="<%=request("txtuser")%>">
<input type="hidden" name="txtCon" value="<%=request("txtCon")%>">
<input type=hidden name=selCompare value="<%=strCompare%>">
<input type="hidden" name="aID" value="<%=announceid%>">
<input type="hidden" name="name" value="<%=request("name")%>">
<input type=hidden name="selTimeLimit" value="<%=request("selTimeLimit")%>">
<tr bgcolor=#ffffff>
    <td valign="middle" nowrap><span class="smallFont">&nbsp;页次：<strong><%=currentPage%></strong>/<strong><%=n%></strong>页 每页<strong><%=MaxAnnouncePerPage%></strong> 总贴数<strong><%=totalrec%></strong></td>
    <td valign="middle" height=25 nowrap align=right>分页：
<%	   for p=1 to n
	   if p<10 then
	       if p=currentPage then
	          response.write "["+Cstr(p)+"] "
		   else
		      response.write "<a href='javascript:viewPage("+Cstr(p)+")' language='javascript'>["+Cstr(p)+"]</a>   "
		   end if
		end if
	next
%>
<span class="smallFont">转到:<input type="text" name="Page" size=3 maxlength=10  value="<%=currentpage%>"><input type="button" value="Go" language="javascript" onclick="viewPage(document.frmList2.Page.value)" id="button1" name="button1"></span>
    </td>
  </tr>
<input type="hidden" name="BoardID" value="<%=BoardID%>">
</form>
</table>

<%		if err.number<>0 then err.clear
	end sub 
%>
<!--#include file="bbsend.asp"-->