searchchk.asp

来自「电子商务网络购物系统」· ASP 代码 · 共 335 行 · 第 1/2 页

ASP
335
字号
<!-- #include file="includes/header.asp" -->
<%
Response.Buffer = True

Function BuildSQL (strTable, sarySearchWord)
	Dim intSQLLoopCounter
	intSQLLoopCounter = 0
	BuildSQL = BuildSQL & "(" & strTable & " LIKE '%" & sarySearchWord(0) & "%'"
	For intSQLLoopCounter = 1 To UBound(sarySearchWord)
		If Request.QueryString("SM") = "1" Then
			BuildSQL = BuildSQL & " AND "
		Else
			BuildSQL = BuildSQL & " OR "
		End If
		BuildSQL = BuildSQL & strTable & " LIKE '%" & sarySearchWord(intSQLLoopCounter) & "%'"
	Next
	BuildSQL = BuildSQL & ")"
End Function

Dim dtmstartdate
Dim rsST	
Dim strSQLResultsQuery
Dim intForumID	
Dim strForumName
Dim strSearchKeywords
Dim sarySearchWord
Dim strSearchIn
Dim intSearchForumID
Dim lngNumberOfReplies
Dim lngTopicID
Dim strSubject	
Dim strTopicStartUsername 
Dim lngTopicStartUserID
Dim lngNumberOfViews
Dim lngLastEntryMessageID
Dim strLastEntryUsername
Dim lngLastEntryUserID
Dim dtmLastEntryDate
Dim intRecordPositionPageNum
Dim intTotalNumOfPages
Dim intRecordLoopCounter
Dim intLinkPageNum
Dim blnReturnedSearchResults
Dim intTopicPageLoopCounter
Dim blnTopicLocked
Dim intPriority	
Dim intNumberOfTopicPages
Dim intTopicPagesLoopCounter
Dim intHighlightLoopCounter
Dim blnNewPost	
Dim lngPollID

blnReturnedSearchResults = True
strSearchKeywords = Trim(Mid(Request.QueryString("kw"), 1, 35))
strSearchIn = Trim(Mid(Request.QueryString("si"), 1, 3))
intForumID = CInt(Request.QueryString("FM"))
If Request.QueryString("si") <> "AR" Then
	strSearchKeywords = Replace(strSearchKeywords, "_", " ")
End If
strSearchKeywords = formatSQLInput(strSearchKeywords)
sarySearchWord = Split(Trim(strSearchKeywords), " ")
If strSearchKeywords = "" Then
	Set rsConn = Nothing
	adoCon.Close
	Set adoCon = Nothing
	Response.Redirect "index.asp"
End If
If Request.QueryString("Spn") = 0 Then
	intRecordPositionPageNum = 1
Else
	intRecordPositionPageNum = CInt(Request.QueryString("Spn"))
End If
If blnAdmin = False Then blnModerator = isModerator(intForumID, intGroupID)
If Request.QueryString("si") = "TC"  Then
	strSearchKeywords = removeAllTags(strSearchKeywords)
	strSearchKeywords = formatInput(strSearchKeywords)
	strSQLResultsQuery = "SELECT topicid, bbsid, pollid, viewnum, Subject, startdtm "
	strSQLResultsQuery = strSQLResultsQuery & "FROM timestopic WHERE "
	If (Request.QueryString("SM") = "2" OR Request.QueryString("SM") = "1") AND Request.QueryString("si") = "Topic" Then
		strSQLResultsQuery = strSQLResultsQuery & BuildSQL ("timestopic.Subject", sarySearchWord)
	Else
		strSQLResultsQuery = strSQLResultsQuery & "timestopic.Subject LIKE '%" & strSearchKeywords & "%'"
	End If

	If intForumID <> 0 Then
		strSQLResultsQuery = strSQLResultsQuery & " AND timestopic.bbsid =" & intForumID & " "
	End If
End If
If Request.QueryString("si") = "PT"  Then
	strSQLResultsQuery = "SELECT timestopic.topicid, timestopic.bbsid, timestopic.pollid, timestopic.viewnum, timestopic.Subject, timestopic.startdtm "
	strSQLResultsQuery = strSQLResultsQuery & "FROM timestopic "
	strSQLResultsQuery = strSQLResultsQuery & "WHERE timestopic.topicid IN "
	strSQLResultsQuery = strSQLResultsQuery & "	(SELECT timespost.topicid "
	strSQLResultsQuery = strSQLResultsQuery & "	FROM timespost "
	strSQLResultsQuery = strSQLResultsQuery & "	WHERE ( "
	If Request.QueryString("SM") = "2" OR Request.QueryString("SM") = "1" Then
		strSQLResultsQuery = strSQLResultsQuery & BuildSQL ("timespost.Message", sarySearchWord)
	Else
		strSQLResultsQuery = strSQLResultsQuery & "timespost.Message LIKE '%" & strSearchKeywords & "%'"
	End If
	strSQLResultsQuery = strSQLResultsQuery & ")) "
	If intForumID <> 0 Then
		strSQLResultsQuery = strSQLResultsQuery & " AND (timestopic.bbsid=" & intForumID & ")"
	End If
End If
If Request.QueryString("si") = "AR" Then
	strSearchKeywords = disallowedMemberNames(strSearchKeywords)
	strSearchKeywords = formatSQLInput(strSearchKeywords)
	strSQLResultsQuery = "SELECT DISTINCT timestopic.topicid, timestopic.bbsid, timestopic.pollid, timestopic.viewnum, timestopic.Subject, timestopic.lastdtm, timestopic.startdtm "
	strSQLResultsQuery = strSQLResultsQuery & "FROM timestopic INNER JOIN (timesuser INNER JOIN timespost ON timesuser.userid = timespost.userid) ON timestopic.topicid = timespost.topicid "
	strSQLResultsQuery = strSQLResultsQuery & "WHERE (((timesuser.Username) LIKE '" & strSearchKeywords & "') "
	If intForumID <> 0 Then
		strSQLResultsQuery = strSQLResultsQuery & "AND ((timestopic.bbsid)=" & intForumID & ") "
	End If
	strSQLResultsQuery = strSQLResultsQuery & ") "
End If
Select Case Request.QueryString("OB")
	Case "3"
		strSQLResultsQuery = strSQLResultsQuery & " ORDER BY timestopic.Subject ASC;"
	Case "4"
		strSQLResultsQuery = strSQLResultsQuery & " ORDER BY timestopic.viewnum DESC;"
	Case "2"
		strSQLResultsQuery = strSQLResultsQuery & " ORDER BY timestopic.startdtm ASC;"
	Case Else
		strSQLResultsQuery = strSQLResultsQuery & " ORDER BY timestopic.lastdtm DESC;"
End Select

%>
<title><% = strMainForumName %> 搜索 <% = strSearchKeywords %></title>

<table width="96%" border="0" cellspacing="0" cellpadding="3" align="center">
 <tr>
  <td align="left" width="71%" class="bold"><img src="images/open.gif" border="0" align="absmiddle">&nbsp;<a href="index.asp" target="_self" class="boldLink"><% = strMainForumName %></a><%

Response.Write(strNavSpacer)  
strSQL = "SELECT timesbbs.bbsname FROM timesbbs WHERE bbsid = " & intForumID
rsConn.Open strSQL, adoCon
If rsConn.EOF AND NOT intForumID = 0 Then %>
<span class="bold">没有论坛</span>
<%
Else
	If intForumID > 0 Then
		strForumName = rsConn("bbsname") %>
	<a href="topic.asp?fid=<%= intForumID %>" target="_self" class="boldLink"><%= strForumName %></a><%= strNavSpacer %>	
		<%	End If %>
		<a href="searchchk.asp?kw=<% = Server.URLEncode(Request.QueryString("kw")) %>&SM=<% = Request.QueryString("SM") %>&si=<% = Request.QueryString("si") %>&FM=<% = Request.QueryString("FM") %>&OB=<% = Request.QueryString("OB") %>" target="_self"  class="boldLink">论坛搜索结果</a>
   <% End If
rsConn.Close
%>
  </td>
 </tr>
</table>
<table width="96%" border="0" cellspacing="0" cellpadding="4" align="center">
 <tr>
  <td align="center" width="90%" class="Text" colspan="2"><%
rsConn.CursorType = 1
rsConn.Open strSQLResultsQuery, adoCon
rsConn.PageSize = intTopicPerPage
If NOT rsConn.EOF Then %>
共搜索到&nbsp;<b><%= rsConn.RecordCount %></b>&nbsp;条与&nbsp;'<b><%= strSearchKeywords %></b>'&nbsp;相关的帖子
<% End If  %></td>
 </tr>
</table>

   <table width="96%" border="0" cellspacing="1" cellpadding="0" bgcolor="<% = strTableBgColour %>" align="center"><%
If rsConn.EOF Then %>
<tr bgcolor="#FFFFFF"><td colspan="5" align="center" height="150" class="text">没有相关主题
<br /><br /><a href="search.asp?RP=S&kw=<%= Server.URLEncode(Request.QueryString("kw")) %>&SM=<%= Request.QueryString("SM") %>&si=<%= Request.QueryString("si") %>&FM=<%= Request.QueryString("FM") %>&OB=<%= Request.QueryString("OB")  %>&Spn=1 target="_self">点击搜索其他主题</a></td></tr>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?