gusucode.com > 仿MOP对开式论坛程序 1.0源码程序 > search.asp

    <%@Language="VBScript"%>
<!--#include file="title.asp"-->
<%
Dim rsa,key,i,n,tfselect,forum,area,types,sql,ntsql,nfsql,erryes,page
key=Trim(Replace(Replace(Request.Form("key"),"'",""),"%",""))
forum=Request.Form("forum")
area=Request.Form("area")
types=Request.QueryString("types")
page=Request.QueryString("page")
if IsNumeric(page) then
page=Abs(Clng(page))
else
page=1
end if
if page=0 then page=1
Set rsa=Server.CreateObject("ADODB.Recordset")
if IsNull(bbsadmin) or bbsadmin="" then
ntsql=" and typeshow=1"
nfsql=" and forumshow=1"
end if
contents=contents &"<title>搜索/工具栏-"& caption &"</title>"&_
"</head>"&_
"<Script Language=""JavaScript"">"&_
"function searchbar()"&_
"{"&_
"if (parent."& bbssn &"leftsearch.rows!=""*,30"")"&_
"{"&_
"document.all.baropen.style.display=""none"";"&_
"document.all.barclose.style.display="""";"&_
"}"&_
"else"&_
"{"&_
"document.all.baropen.style.display="""";"&_
"document.all.barclose.style.display=""none"";"&_
"}"&_
"}"&_
"</Script>"&_
"<base target="""& bbssn &"right"">"
if gbmaduser="" then
contents=contents &"<body topmargin=""5"">"&_
"<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">"&_
"<tr class=""toptr"" height=""20""><td width=""6""><img src="""& theme &"02.gif"" border=""0""></td>"&_ 
"<td background="""& theme &"02.gif"">  "&_
"你还没登陆或者已经掉线,请<a href=""login.asp"">登陆</a>。"&_
"</td><td width=""6""><img src="""& theme &"02.gif"" border=""0""></td></tr></table>"
else
contents=contents &"<body topmargin=""5"" onResize=""searchbar();"" onLoad=""searchbar();"">"&_
"<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"">"&_
"<tr class=""toptr"" height=""20""><td width=""6""><img src="""& theme &"02.gif"" border=""0""></td>"&_ 
"<td background="""& theme &"02.gif"">  "&_
"<a href=""search.asp?types=topic"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='55%,45%';"" target=""_self"">自发帖</a> <a href=""search.asp?types=reply"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='55%,45%';"" target=""_self"">自回帖</a> <a href=""search.asp?types=elite"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='55%,45%';"" target=""_self"">精华帖</a> <a href=""search.asp?types=top"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='55%,45%';"" target=""_self"">最新100帖</a> "&_
"<a href=""#"" target=""_self"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='55%,45%';"" style=""display:none"" id=""baropen"">打开栏</a><a href=""#"" target=""_self"" onClick=""javascript:parent."& bbssn &"leftsearch.rows='*,30';"" style=""display:none"" id=""barclose"">关闭栏</a>"&_
"</td><td width=""6""><img src="""& theme &"02.gif"" border=""0""></td></tr></table><br>"&_
""&_
"<table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  帖子搜索</td></tr>"&_
"<form name=""search"" onsubmit=""return validinput();"" method=""post"" action=""search.asp"" target=""_self"">"&_
"<tr class=""tds""><td>"&_
"<script language=""JavaScript"">"&_
"function validinput()"&_
"{"&_
"if (document.search.key.value.length==0){"&_
"alert(""你还没输入搜索内容呢。"");"&_
"document.search.key.focus();"&_
"return false;"&_
"}"&_
"return true;"&_
"}"&_
"</script>"&_
"搜索:<input name=""key"" type=""text"" maxlength=""20"" size=""15"" class=""iptwin"" value="""& key &"""> <input name=""button"" type=""submit"" value=""提交"" onmouseover=""this.className='over';"" onmouseout=""this.className='out';"" class=""out""> <font class=""del"">关键字不能小于2个字</font>"&_
"<br>在版面:<select name=""forum"" size=""1""><option value=""all"">所有版面</option>"
if IsNull(bbsadmin) or bbsadmin="" then
rs.Open "forumtype Where typeshow=1 Order by typeorder",conn,1,1
For i=1 to rs.RecordCount
tfselect=""
if forum="types="& rs("id") then tfselect=" selected"
contents=contents &"<option value=""types="& rs("id") &""""& tfselect &">╋"& rs("forumtype") &"</option>"
rsa.Open "forum Where forumtype="& rs("id") &" and forumshow=1 Order by forumorder",conn,1,1
For n=1 to rsa.RecordCount
tfselect=""
if forum="forum="& rsa("id") then tfselect=" selected"
contents=contents &"<option value=""forum="& rsa("id") &""""& tfselect &"> ┗"& rsa("forumname") &"</option>"
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
rs.Close
else
rs.Open "forumtype Order by typeorder",conn,1,1
For i=1 to rs.RecordCount
tfselect=""
if forum="types="& rs("id") then tfselect=" selected"
contents=contents &"<option value=""types="& rs("id") &""""& tfselect &">╋"& rs("forumtype") &"</option>"
rsa.Open "forum Where forumtype="& rs("id") &" Order by forumorder",conn,1,1
For n=1 to rsa.RecordCount
tfselect=""
if forum="forum="& rsa("id") then tfselect=" selected"
contents=contents &"<option value=""forum="& rsa("id") &""""& tfselect &"> ┗"& rsa("forumname") &"</option>"
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
rs.Close
end if
contents=contents &"</select>"&_
" 里的:<select name=""area"" size=""1""><option value=""title"">帖子标题</option><option value=""content"">帖子内容</option><option value=""all"">标题内容</option><option value=""postuser"">帖子作者</option></select>"&_
"</td></tr>"&_
"</form>"
if Len(key)>1 then
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  搜索结果</td></tr>"
sql="Select Top 50 title,gbmaduser,posttime,anonymity,click,link,reply,lastupdate,lastuser From topic Where deler is Null"
if area="title" then
sql=sql &" and title Like '%"& key &"%'"
elseif area="content" then
sql=sql &" and content Like '%"& key &"%'"
elseif area="all" then
sql=sql &" and (title Like '%"& key &"%' or content Like '%"& key &"%')"
elseif area="postuser" then
sql=sql &" and gbmaduser='"& key &"'"
end if
if Instr(forum,"types")>0 then
forum=Replace(forum,"types=","")
if IsNumeric(forum) then
forum=Abs(Clng(forum))
else
forum=0
end if
rs.Open "forumtype Where id="& forum & ntsql,conn,1,1
if Not rs.Eof then
rsa.Open "forum Where forumtype="& rs("id") & nfsql,conn,1,1
if rsa.Eof then
erryes="yes"
else
sql=sql &" and ("
For n=1 to rsa.RecordCount
if n=rsa.RecordCount then
sql=sql &"forumid="& rsa("id") &")"
else
sql=sql &"forumid="& rsa("id") &" or "
end if
rsa.MoveNext
Next
end if
rsa.Close
end if
rs.Close
elseif Instr(forum,"forum")>0 then
forum=Replace(forum,"forum=","")
if IsNumeric(forum) then
forum=Abs(Clng(forum))
else
forum=0
end if
rs.Open "forum Where id="& forum & nfsql,conn,1,1
if Not rs.Eof then
sql=sql &" and forumid="& forum
else
erryes="yes"
end if
rs.Close
elseif forum="all" then
sql=sql &" and ("
rs.Open "forumtype Where id>0 "& ntsql,conn,1,1
if Not rs.Eof then
For i=1 to rs.RecordCount
rsa.Open "forum Where forumtype="& rs("id") & nfsql,conn,1,1
For n=1 to rsa.RecordCount
sql=sql &"forumid="& rsa("id") &" or "
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
end if
rs.Close
sql=sql &"forumid=0)"
end if
if erryes<>"yes" then
sql=sql &" Order by posttime Desc"
rs.Open sql,conn,1,1
if rs.Eof then
contents=contents &"<tr><td><br>没有搜索到任何相关的结果。<br><br></td></tr>"
else
For i=1 to rs.RecordCount
if rs("anonymity")<>"" then
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:神秘人物"& rs("anonymity") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
else
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:"& rs("gbmaduser") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
end if
rs.MoveNext
Next
end if
if i=51 then contents=contents &"<tr><td><br>总共搜索到超过50项结果。<br>为了服务器更好运行我们只为你列出最类似的50项。<br>如果还没搜索到你要的,<a href=""#top"" target=""_self"" onClick=""document.search.key.focus();"">请适当的更改关键字再搜索</a>。<br><br></td></tr>"
rs.Close
else
contents=contents &"<tr><td><br>搜索出错,请确定你是通过正常方式进行操作。<br>如果依旧出错,请<a href=""reporting.asp"">联系管理员报告错误</a>。<br><br></td></tr>"
end if
end if
if types="topic" then
sql="Select title,gbmaduser,posttime,anonymity,click,link,reply,lastupdate,lastuser From topic Where deler is Null and gbmaduser='"& gbmaduser &"' Order by posttime Desc"
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  我发表的帖子</td></tr>"
elseif types="elite" then
sql="Select title,gbmaduser,posttime,anonymity,click,link,reply,lastupdate,lastuser From topic Where deler is Null and topictype=1 and ("
rs.Open "forumtype Where id>0 "& ntsql,conn,1,1
if Not rs.Eof then
For i=1 to rs.RecordCount
rsa.Open "forum Where forumtype="& rs("id") & nfsql,conn,1,1
For n=1 to rsa.RecordCount
sql=sql &"forumid="& rsa("id") &" or "
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
end if
rs.Close
sql=sql &"forumid=0) Order by posttime Desc"
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  社区精华帖</td></tr>"
elseif types="help" then
sql="Select title,gbmaduser,posttime,anonymity,click,link,reply,lastupdate,lastuser From topic Where deler is Null and topictype=0 and ("
rs.Open "forumtype Where id>0 "& ntsql,conn,1,1
if Not rs.Eof then
For i=1 to rs.RecordCount
rsa.Open "forum Where forumtype="& rs("id") & nfsql,conn,1,1
For n=1 to rsa.RecordCount
sql=sql &"forumid="& rsa("id") &" or "
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
end if
rs.Close
sql=sql &"forumid=0) Order by posttime Desc"
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  社区求助帖</td></tr>"
end if
if sql<>"" and types<>"" then
rs.Open sql,conn,1,1
if Not rs.Eof then
rs.PageSize=100
if page>rs.PageCount then page=rs.PageCount
rs.AbsolutePage=page
contents=contents &"<tr class=""tds""><td>"&_
"当前在第"& page &"页 转到第 "
For i=1 to rs.PageCount
contents=contents &"<a href=""search.asp?types="& types &"&page="& i &""" target=""_self"">"& i &"</a> "
Next
contents=contents &"页 共有"& rs.PageCount &"页 共"& rs.RecordCount &"条"&_
"</td></tr>"
For i=1 to rs.PageSize
if rs("anonymity")<>"" then
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:神秘人物"& rs("anonymity") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
else
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:"& rs("gbmaduser") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
end if
rs.MoveNext
if rs.Eof then Exit For
Next
end if
rs.Close
end if
if types="reply" then
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  我回复的帖子</td></tr>"
rs.Open "Select t.title,t.gbmaduser,t.anonymity,t.posttime as tposttime,t.link,t.reply,t.click,r.content,r.posttime,r.deler From topic t,reply r Where r.gbmaduser='"& gbmaduser &"' and t.id=r.topicid and t.deler is Null Order by r.posttime Desc",conn,1,1
if Not rs.Eof then
rs.PageSize=20
if page>rs.PageCount then page=rs.PageCount
rs.AbsolutePage=page
contents=contents &"<tr class=""tds""><td>"&_
"当前在第"& page &"页 转到第 "
For i=1 to rs.PageCount
contents=contents &"<a href=""search.asp?types=reply&page="& i &""" target=""_self"">"& i &"</a> "
Next
contents=contents &"页 共有"& rs.PageCount &"页 共"& rs.RecordCount &"条"&_
"</td></tr>"
For i=1 to rs.PageSize
if rs("anonymity")<>"" then
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:神秘人物"& rs("anonymity") & vbcrlf &"发贴时间:"& rs("tposttime") & vbcrlf &"回复时间:"& rs("posttime") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"
else
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:"& rs("gbmaduser") & vbcrlf &"发贴时间:"& rs("tposttime") & vbcrlf &"回复时间:"& rs("posttime") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"
end if
if rs("deler")<>"" then
contents=contents & vbcrlf &"回复内容:已经被 "& rs("deler") &" 删除"">"& rs("title") &"</a></td></tr>"
else
contents=contents & vbcrlf &"回复内容:"& Replace(Left(rs("content"),20),"""","") &"……"">"& rs("title") &"</a></td></tr>"
end if
rs.MoveNext
if rs.Eof then Exit For
Next
end if
rs.Close
end if
if types="top" then
sql="Select Top 100 title,gbmaduser,posttime,anonymity,click,link,reply,lastupdate,lastuser From topic Where deler is Null and ("
rs.Open "forumtype Where id>0 "& ntsql,conn,1,1
if Not rs.Eof then
For i=1 to rs.RecordCount
rsa.Open "forum Where forumtype="& rs("id") & nfsql,conn,1,1
For n=1 to rsa.RecordCount
sql=sql &"forumid="& rsa("id") &" or "
rsa.MoveNext
Next
rsa.Close
rs.MoveNext
Next
end if
rs.Close
sql=sql &"forumid=0) Order by posttime Desc"
contents=contents &"</table><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" class=""tdc"">"&_
"<tr class=""toptr""><td class=""tdc"" height=""20"" background="""& theme &"02.gif"">  社区最新100个帖子</td></tr>"
rs.Open sql,conn,1,1
For i=1 to rs.RecordCount
if rs("anonymity")<>"" then
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:神秘人物"& rs("anonymity") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
else
contents=contents &"<tr height=""20"" onmouseover=""this.className='otr';"" onmouseout=""this.className='';""><td class=""tdc"">&nbsp;<a href=""topic/"& rs("link") &""" title=""帖子作者:"& rs("gbmaduser") & vbcrlf &"发贴时间:"& rs("posttime") & vbcrlf &"最后回复:"& rs("lastuser") & vbcrlf &"更新时间:"& rs("lastupdate") & vbcrlf &"人气:("& rs("reply") &"/"& rs("click") &")"">"& rs("title") &"</a></td></tr>"
end if
rs.MoveNext
Next
rs.Close
end if
contents=contents &"</table>"&_
""
end if
Set rsa=Nothing
%>
<!--#include file="bottom.asp"-->