<% 'on error resume next dim rs,sql dim currentpage dim totalrec dim guestlist dim stype,pSearch,nSearch,keyword dim searchboard,ordername stats="搜索结果" stype=request("stype") pSearch=request("pSearch") nSearch=request("nSearch") keyword=trim(request("keyword")) boardid=request("boardid") 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 boardmaster or master then guestlist="" else guestlist=" board.lockboard<>2 and " end if if stype<3 then if not isInteger(boardid) then Errmsg=Errmsg+"
"+"
  • 版面id必须是整数。" founderr=true elseif cint(boardid)>1 then call boardinfo() end if if keyword="" then Errmsg=Errmsg+"
    "+"
  • 必须输入查询关键字。" founderr=true end if if cint(boardid)<1 then searchboard="" else searchboard=" b.boardid="&boardid&" and " end if end if call nav() call headline(1) if founderr then call error() else call search() if founderr then call error() end if call endline() sub search() '搜索多少天内帖子 if trim(request("SearchDate"))="ALL" then searchday="" else searchday=" DATEDIFF('d',dateandtime,Now()) < "&request("SearchDate")&" and " end if sql="" set rs=server.createobject("adodb.recordset") select case stype case 1 select case nSearch '搜索主题帖子作者 case 1 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where b.username like '%"&keyword&"%' and "&guestlist&" "&searchboard&" b.boardid=board.boardid and "&searchday&" b.parentid=0 ORDER BY b.announceID desc" ordername="搜索主题作者帖子" '搜索回复帖子作者 case 2 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where b.username like '%"&keyword&"%' and "&guestlist&" "&searchboard&" b.boardid=board.boardid and "&searchday&" and b.parentid>0 ORDER BY b.announceID desc" ordername="搜索回复作者帖子" '两者都搜索 case 3 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where b.username like '%"&keyword&"%' and "&guestlist&" "&searchboard&" "&searchday&" b.boardid=board.boardid ORDER BY b.announceID desc" ordername="搜索主题和回复作者帖子" end select case 2 select case pSearch '搜索主题关键字 case 1 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where (" & translate(keyword,"topic") & ") and "&guestlist&" "&searchboard&" "&searchday&" b.boardid=board.boardid ORDER BY b.announceID desc" '搜索内容关键字 ordername="搜索主题" case 2 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where (" & translate(keyword,"body") & ") and "&guestlist&" "&searchboard&" "&searchday&" b.boardid=board.boardid ORDER BY b.announceID desc" '两者都搜索 ordername="搜索内容" case 3 sql="select b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where (" & translate(keyword,"topic") & " or " & translate(keyword,"body") & ") and "&guestlist&" "&searchboard&" "&searchday&" b.boardid=board.boardid ORDER BY b.announceID desc" ordername="搜索主题和内容" end select case 3 sql="select top 50 b.locktopic,b.boardid,b.rootid,b.announceid,b.body,b.Expression,b.topic,b.username,b.child,b.hits,b.dateandtime,board.lockboard from bbs1 b,board where "&guestlist&" b.boardid=board.boardid ORDER BY b.announceID desc" ordername="最新50帖" end select 'response.write sql if sql="" then Errmsg=Errmsg+"
    "+"
  • 请指定查询条件。" founderr=true exit sub end if rs.open sql,conn,1,1 if err.number<>0 then Errmsg=Errmsg+"
    "+"
  • 数据库出错,查询失败。" founderr=true else if rs.eof and rs.bof then Errmsg=Errmsg+"
    "+"
  • 没有找到您要查询的内容。" founderr=true else totalrec=rs.recordcount if currentpage<1 then currentpage=1 end if MaxAnnouncePerpage=Clng(MaxAnnouncePerpage) 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
    <%=ordername%>共查询到><%=totalrec%>个结果
    align=center>
    valign=middle width=1> >状态 valign=middle width=1> >主 题 (点心情符为开新窗浏览) valign=middle width=1> >作 者 valign=middle width=1> >回复/人气 valign=middle width=1> >作者 | 发表时间 valign=middle width=1>
    align=center>
    <% do while not rs.eof %>
    valign=middle width=1 height=24> > <%if rs("locktopic")=1 then%>lockfolder.gif alt="本主题已锁定"><%else%><%if rs("child")>=10 then%>hotfolder.gif><%else%>folder.gif><%end if%><%end if%> valign=middle width=1> width=*>>开新窗口浏览此主题 <%if rs("topic")="" then%><%=left(htmlencode(rs("body")),26)%>...<%else%><%=htmlencode(rs("topic"))%><%end if%> valign=middle width=1> >',350,300)"><%=htmlencode(rs("username"))%> valign=middle width=1> ><%=rs("child")%>/<%=rs("hits")%> valign=middle width=1> width=195>>  <%=FormatDateTime(rs("dateandtime"),2)%> <%=FormatDateTime(rs("dateandtime"),4)%>  |  ',350,300)"><%=htmlencode(rs("username"))%> valign=middle width=1>
    align=center>
    <% i=i+1 if i>=MaxAnnouncePerPage then exit do rs.movenext loop rs.close end sub sub listPages3() dim n if totalrec mod MaxAnnouncePerPage=0 then n= totalrec \ MaxAnnouncePerPage else n= totalrec \ MaxAnnouncePerPage+1 end if %> ">
    页次:<%=currentPage%>/<%=n%>页 每页<%=MaxAnnouncePerPage%> 总贴数<%=totalrec%>

    分页: <% for p=1 to n if p<10 then if p=currentPage then response.write "["+Cstr(p)+"] " else response.write "["+Cstr(p)+"] " end if end if next %> 转到:

    <% if err.number<>0 then err.clear end sub sub boardinfo() set rs=server.createobject("adodb.recordset") sql="select boardtype,Tableback,Tabletitle,Tablebody,aTablebody,TableFont,TableContent,AlertFont,strAllowForumCode,strAllowHTML,strIMGInPosts,strIcons,strflash,Forumlogo from board where boardID="&BoardID rs.open sql,conn,1,1 if not(rs.bof and rs.eof) then boardtype=rs("boardtype") Tablebackcolor=trim(rs("Tableback")) Tabletitlecolor=trim(rs("Tabletitle")) Tablebodycolor=trim(rs("Tablebody")) aTablebodycolor=trim(rs("aTablebody")) TableFontcolor=trim(rs("TableFont")) TableContentcolor=trim(rs("TableContent")) AlertFont=trim(rs("AlertFont")) strAllowForumCode=rs("strAllowForumCode") strAllowHTML=rs("strAllowHTML") strIMGInPosts=rs("strIMGInPosts") strIcons=rs("strIcons") strflash=rs("strflash") Forumlogo=rs("Forumlogo") end if rs.close set rs=nothing end sub %>