<% '************************************** '** search.asp '** '** 文件说明:搜索页面 '** 修改日期:2005-11-02 '** 作者:Howlion '** Email:howlion@163.com '************************************** dim key key=sql_filter(left(trim(Request.QueryString("key")),15)) dim currentpage,page_count,Pcount dim totalrec,endpage if Request.QueryString("page")="" then currentPage=1 else if (not isnumeric(Request.QueryString("page"))) then errinfo="
  • 非法的页面参数!" call showError() end if currentPage=cint(Request.QueryString("page")) end if pagename="搜索留言" call bodySkin() sub pageContent() if Request.QueryString("act")="fillform" then fillForm() else searchResult() end if end sub function fillForm() %>
     
    搜索范围将包括:留言者的称呼、留言标题、正文以及回复
    <% end function function searchResult() if sql_filter(trim(Request.Form("key")))="" and key="" then errinfo="
  • 请输入搜索关键字!" call showError() else if (not sql_filter(trim(Request.Form("key")))="") and key="" then Response.Redirect "?key="&trim(Request.Form("key")) Response.Flush end if end if if login then sql = "Select * from [topic] where (usertitle like '%"&key&"%' or usercontent like '%"&key&"%' or username like '%"&key&"%' or recontent like '%"&key&"%') order by top desc,usertime desc" set rs=server.CreateObject("adodb.recordset") rs.open sql,conn,1,1 else sql = "Select * from [topic] where checked=1 and whisper=0 and (usertitle like '%"&key&"%' or usercontent like '%"&key&"%' or username like '%"&key&"%' or recontent like '%"&key&"%') order by top desc,usertime desc" set rs=server.CreateObject("adodb.recordset") rs.open sql,conn,1,1 end if if rs.eof or rs.bof then rs.close set rs=nothing errinfo="
  • 没有找到包含“"&key&"”的留言,请简化关键字后再搜索。" call showError() end if rs.PageSize = perpage rs.AbsolutePage=currentpage page_count=0 totalrec=rs.recordcount if not totalrec mod perpage=0 then if currentPage > (totalrec/perpage)+1 then response.redirect "?key="&key&"&page=" & Int((totalrec/perpage))+1 else if currentPage > (totalrec/perpage) then response.redirect "?key="&key&"&page=" & Int((totalrec/perpage)) end if call pages() while (not rs.eof) and (not page_count = rs.PageSize) dim username,userURL,usermail,userqq,usertitle,usertime,usercontent,recontent,retime username = Boldkey(HTMLencode(rs("username")),key) userURL = HTMLencode(rs("userURL")) usermail = HTMLencode(rs("usermail")) userqq = HTMLencode(rs("userqq")) usertitle = Boldkey(HTMLencode(rs("usertitle")),key) usertime = rs("usertime") usercontent = Boldkey(UBBCode(rs("usercontent"),rs("top")),key) recontent = Boldkey(UBBCode(rs("recontent"),1),key) retime = rs("retime") %> ">
    <%if rs("whisper")="1" and (not login) then%>
    • 悄悄话
    悄悄话留言
    <%=usertime%>
    此留言仅管理员可见。
    <%if rs("replycode")<>"" then%> <%if rs("reply")=1 then call viewreply(rs("id")) else%>状态:未被回复。<%end if else%>状态:无法被回复。<%end if%>
    <%else%>
    • <%if rs("top")=1 then%>管理员<%else%>.gif" alt="<%=HTMLencode(rs("username"))%>" /><%end if%>
    • <%if rs("top")=1 then%>管理员<%else%><%=username%><%end if%>
    <%if rs("top")=1 then%>公告:<%else%>标题:<%end if%>

    <%=usertitle%>

    <%=usertime%>
    <%if not rs("userURL")="" then%>访问“<%=HTMLencode(rs(”的网站" /> <%else%> <%end if%> <%if not rs("usermail")="" then%>给“<%=HTMLencode(rs(”发送电子邮件" /> <%else%> <%end if%> <%if not rs("userqq")="" then%>向“<%=HTMLencode(rs(”的QQ发起临时会话(QQ软件须开启)" /> <%else%> <%end if%>
    <%=usercontent%>
    <%if rs("reply")=1 then%>
    管理员回复 : ( <%=retime%> )
    <%=recontent%>
    <%end if%>
    <%if login then%> <%end if%> <%end if%>
    <% page_count = page_count + 1 rs.movenext wend %>
    <% call pages() rs.close set rs=nothing end function sub pages() '//////// 分页代码 %>
    <% dim ii,p,n if totalrec mod perpage=0 then n= totalrec \ perpage else n= totalrec \ perpage+1 end if p=(currentpage-1) \ 5 %> 搜索“<%=key%>”  页次:<%=currentpage%>/<%=n%>页,每页<%=rs.pagesize%>条,共<%=totalrec%>条    <%if currentpage=1 then%>首页  <%else%>首页  <%end if%> <%if p*5>0 then%> 上翻  <%end if for ii=p*5+1 to p*5+5 if ii=currentpage then%> <%=cstr(ii)%> <%else%> <%=cstr(ii)%> <%end if if ii=n then exit for next %> <%if ii  下翻 <%end if%> <%if currentpage=n then%>  尾页 <%else%>  尾页 <%end if%>
    <% end sub Function Boldkey(strContent,key) '//////// 加亮关键字 dim B_key Set B_key=new RegExp B_key.IgnoreCase =true B_key.Global=true B_key.Pattern="(" & key & ")" strContent=B_key.Replace(strContent,"$1" ) Set B_key=Nothing Boldkey=strContent End Function %>