⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search_process.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 3 页
字号:
			"AND " & strDbTable & "Thread.Author_ID = " & strDbTable & "Author.Author_ID " & _
			"AND LastThread.Author_ID = LastAuthor.Author_ID " & _
			"AND " & strDbTable & "Topic.Start_Thread_ID = " & strDbTable & "Thread.Thread_ID " & _
			"AND " & strDbTable & "Topic.Last_Thread_ID = LastThread.Thread_ID "
			
	
	
	'Else displaying results as posts so the query needs to be less complex and less data
	Else	
		
		'Initalise SQL query (quite complex but required if we only want 1 db hit to get the lot for the whole page)
		strSQL = "" & _
		"SELECT "
		If strDatabaseType = "SQLServer" OR strDatabaseType = "Access" Then
			strSQL = strSQL & " TOP " & intMaxResults & " "
		End If
		strSQL = strSQL & _
		"" & strDbTable & "Forum.Forum_ID, " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Forum_code, " & strDbTable & "Topic.Topic_ID, " & strDbTable & "Topic.Poll_ID, " & strDbTable & "Topic.Moved_ID, " & strDbTable & "Topic.Subject, " & strDbTable & "Topic.Icon, " & strDbTable & "Topic.No_of_replies, " & strDbTable & "Topic.No_of_views, " & strDbTable & "Topic.Locked, " & strDbTable & "Topic.Priority, " & strDbTable & "Topic.Hide, " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message_date, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Topic.Event_date, " & strDbTable & "Topic.Event_date_end " & _
		"FROM " & strDbTable & "Category" & strDBNoLock & ", " & strDbTable & "Forum" & strDBNoLock & ", " & strDbTable & "Topic" & strDBNoLock & ", " & strDbTable & "Thread" & strDBNoLock & ", " & strDbTable & "Author" & strDBNoLock & " " & _
		"WHERE " & strDbTable & "Category.Cat_ID = " & strDbTable & "Forum.Cat_ID " & _
			"AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID "
			
			'If searcing topic subjects so join the start topic ID with threads table
			If strSearhIn = "subject" Then
				strSQL = strSQL & _
				"AND " & strDbTable & "Topic.Start_Thread_ID = " & strDbTable & "Thread.Thread_ID "
			
			'Else join the topic ID with thread table
			Else
				strSQL = strSQL & _
				"AND " & strDbTable & "Topic.Topic_ID = " & strDbTable & "Thread.Topic_ID "
			End If
			
			strSQL = strSQL & _	
			"AND " & strDbTable & "Thread.Author_ID = " & strDbTable & "Author.Author_ID "
			
	End If
		
		
		
	'Put in where forum search here so we can 
	strSQL = strSQL & strSQLwhereForum
	
	
	'Check the permissions
	strSQL = strSQL & _
	"AND (" & strDbTable & "Topic.Forum_ID " & _
		"IN (" & _
			"SELECT " & strDbTable & "Permissions.Forum_ID " & _
			"FROM " & strDbTable & "Permissions " & strDBNoLock & " " & _
			"WHERE (" & strDbTable & "Permissions.Group_ID = " & intGroupID & " OR " & strDbTable & "Permissions.Author_ID = " & lngLoggedInUserID & ") " & _
				"AND " & strDbTable & "Permissions.View_Forum = " & strDBTrue & _
		")" & _
	") "
	
	
	'If this is a guest don't display hidden posts
	If intGroupID = 2 Then
		strSQL = strSQL & "AND (" & strDbTable & "Topic.Hide = " & strDBFalse & ") AND (" & strDbTable & "Thread.Hide = " & strDBFalse & ") "
	'If this isn't a moderator only display hidden posts if the user posted them
	ElseIf blnModerator = false AND blnAdmin = false Then
		strSQL = strSQL & "AND (" & strDbTable & "Topic.Hide = " & strDBFalse & " OR " & strDbTable & "Thread.Author_ID = " & lngLoggedInUserID & ") AND (" & strDbTable & "Thread.Hide=" & strDBFalse & " OR " & strDbTable & "Thread.Author_ID = " & lngLoggedInUserID & ") "
	End If
	

	
	'Place the most expenisve WHERE clauses last
	strSQL = strSQL & _
	strSQLwhereMemSearch & _
	strSQLwhereDate & _
	strSQLwhereKeywords
	
	
	'Set the sort by order
	Select Case strOrderBy
		Case "StartDate"
			'Use the Thread_ID as it should be in the same order as date but offers a massive performance boost
			strSQL = strSQL & "ORDER BY " & strDbTable & "Thread.Thread_ID ASC" 
		Case "Subject"
			strSQL = strSQL & "ORDER BY " & strDbTable & "Topic.Subject ASC"
		Case "Replies"
			strSQL = strSQL & "ORDER BY " & strDbTable & "Topic.No_of_replies DESC"
		Case "Views"
			strSQL = strSQL & "ORDER BY " & strDbTable & "Topic.No_of_views DESC"
		Case "Username"
			strSQL = strSQL & "ORDER BY " & strDbTable & "Author.Username ASC"
		Case "ForumName"
			strSQL = strSQL & "ORDER BY " & strDbTable & "Forum.Forum_name ASC"
		Case Else
			'If displaying results as topics we have created a new table using the query so results must be order by the new table
			If strResultType = "topics" Then
				'strSQL = strSQL & "ORDER BY " & strDbTable & "Topic.Last_Thread_ID DESC"
				strSQL = strSQL & "ORDER BY LastThread.Message_date DESC"
			Else
				'Use the Thread_ID as it should be in the same order as date but offers a massive performance boost
				strSQL = strSQL & "ORDER BY " & strDbTable & "Thread.Thread_ID DESC"
			End If
	End Select
	
	'mySQL limit operator
	If strDatabaseType = "mySQL" Then
		strSQL = strSQL & " LIMIT " & intMaxResults
	End If
	strSQL = strSQL & ";"


	
	'If the keywords and member names are not to short run the query
	If blnSearhWordsTwoShort = false Then

		'Set error trapping
		On Error Resume Next
			
		'Query the database
		rsCommon.Open strSQL, adoCon
		
		'If an error has occurred write an error to the page
		If Err.Number <> 0 AND  strDatabaseType = "mySQL" Then	
			Call errorMsg("An error has occurred while executing SQL query on database.<br />Please check that the MySQL Server version is 4.1 or above.", "get_search_results_data", "search_process.asp")
		ElseIf Err.Number <> 0 Then	
			Call errorMsg("An error has occurred while executing SQL query on database.", "get_search_results_data", "search_process.asp")
		End If
					
		'Disable error trapping
		On Error goto 0
		
		
		'******************************************
		'***   	Save the search to app memory	***
		'******************************************
		
		'If a search result is found the  save the details and recordset to memory
		If NOT rsCommon.EOF Then
		
		
			'Create an ID for the search using time in secounds for a unique value
			lngSearchID = internationalDateTime(Now())
			lngSearchID = Replace(lngSearchID, "-", "", 1, -1, 1)
			lngSearchID = Replace(lngSearchID, ":", "", 1, -1, 1)
			lngSearchID = Replace(lngSearchID, " ", "", 1, -1, 1)
		
		
			'ReDimesion the search index array
			ReDim Preserve sarySearchIndex(5, UBound(sarySearchIndex, 2) + 1)
			
			'Place the new search index data into the new array position
			sarySearchIndex(0, UBound(sarySearchIndex, 2)) = lngSearchID
			sarySearchIndex(1, UBound(sarySearchIndex, 2)) = strSeachIPAddress
			sarySearchIndex(2, UBound(sarySearchIndex, 2)) = internationalDateTime(Now())
			sarySearchIndex(3, UBound(sarySearchIndex, 2)) = lngLoggedInUserID
			sarySearchIndex(4, UBound(sarySearchIndex, 2)) = internationalDateTime(Now())
			sarySearchIndex(5, UBound(sarySearchIndex, 2)) = FormatNumber(Timer() - dblStartTime,3)
			
			
			'Place the recordset into an application array
			'Lock the application so that no other user can try and update the application level variable at the same time
			Application.Lock
			
			'Place the search record set into an array using the search ID as the application variable name
			Application(lngSearchID) = rsCommon.GetRows()
				
			'Unlock the application
			Application.UnLock
			
			'Set the results found boolean to true
			blnResultsFound = true
		End If
		
		'Close rs
		rsCommon.Close
	End If
End If

'Clean up
Call closeDatabase()

'Update search index application array
'Lock the application so that no other user can try and update the application level variable at the same time
Application.Lock
			
'Update the application level variables
Application(strAppPrefix & "sarySearchIndex") = sarySearchIndex
			
'Unlock the application
Application.UnLock


'If the search is secsussful
If blnResultsFound Then 
	'If search results displayed in topics then redirect to topic page
	If strResultType = "topics" Then
		Response.Redirect("search_results_topics.asp?SearchID=" & lngSearchID & "&KW=" & Server.URLEncode(strSearchKeywords) & strQsSID3)
	
	'Else results displayed as posts so redirect to that page
	Else
		Response.Redirect("search_results_posts.asp?SearchID=" & lngSearchID & "&KW=" & Server.URLEncode(strSearchKeywords) & strQsSID3)
	End If
End If


'Set bread crumb trail
strBreadCrumbTrail = strBreadCrumbTrail & strNavSpacer & strTxtSearchTheForum

%>
<!-- #include file="includes/browser_page_encoding_inc.asp" -->
<meta name="generator" content="Web Wiz Forums" />
<title><% = strTxtSearchTheForum %></title>

<%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write("<!--//" & _
vbCrLf & "/* *******************************************************" & _
vbCrLf & "Software: Web Wiz Forums(TM) ver. " & strVersion & "" & _
vbCrLf & "Info: http://www.webwizforums.com" & _
vbCrLf & "Copyright: (C)2001-2008 Web Wiz(TM). All rights reserved" & _
vbCrLf & "******************************************************* */" & _
vbCrLf & "//-->" & vbCrLf & vbCrLf)
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>

<link href="<% = strCSSfile %>default_style.css" rel="stylesheet" type="text/css" />
<!-- #include file="includes/header.asp" -->
<!-- #include file="includes/status_bar_header_inc.asp" -->
<table class="basicTable" cellspacing="0" cellpadding="3" align="center">
 <tr>
  <td align="left"><h1><% = strTxtSearchTheForum %></h1></td>
 </tr>
</table> 
<br />
<table class="errorTable" cellspacing="1" cellpadding="3" align="center">
 <tr>
  <td><img src="<% = strImagePath %>error.png" alt="<% = strTxtError %>" /> <strong><% = strTxtSearchError %></strong></td>
 </tr>
 <tr>
  <td><%
 
'Write the error message
If blnSearchIPFound Then
	Response.Write("<br />" & strTxtIPSearchError)  
ElseIf blnSearhWordsTwoShort Then
	Response.Write("<br />" & strTxtSearchWordLengthError)  
ElseIf blnResultsFound = false Then    
	Response.Write("<strong>" & strTxtNoSearchResultsFound & "</strong><br /><br />" & strTxtNoSearchResults)  
End If        
        %><br /><br /><a href="search_form.asp<% = strQsSID1 %>"><% = strTxtClickHereToRefineSearch %></a>
   <br />
  </td>
 </tr>
</table>
<br /><br />
<div align="center"><%

'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
If blnLCode = True Then
	
	If blnTextLinks = True Then
		Response.Write("<span class=""text"" style=""font-size:10px"">Bulletin Board Software by <a href=""http://www.webwizforums.com"" target=""_blank"" style=""font-size:10px"">Web Wiz Forums&reg;</a> version " & strVersion & "</span>")
	Else
  		Response.Write("<a href=""http://www.webwizforums.com"" target=""_blank""><img src=""webwizforums_image.asp"" border=""0"" title=""Bulletin Board Software by Web Wiz Forums&reg; version " & strVersion& """ alt=""Bulletin Board Software by Web Wiz Forums&reg; version " & strVersion& """ /></a>")
	End If

	Response.Write("<br /><span class=""text"" style=""font-size:10px"">Copyright &copy;2001-2008 <a href=""http://www.webwizguide.com"" target=""_blank"" style=""font-size:10px"">Web Wiz</a></span>")
End If
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******

'Display the process time
If blnShowProcessTime Then Response.Write "<span class=""smText""><br /><br />" & strTxtThisPageWasGeneratedIn & " " & FormatNumber(Timer() - dblStartTime, 3) & " " & strTxtSeconds & "</span>"
%>
</div>
<!-- #include file="includes/footer.asp" -->

⌨️ 快捷键说明

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