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

📄 search_process.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="common.asp" -->
<!--#include file="functions/functions_date_time_format.asp" -->
<%
'****************************************************************************************
'**  Copyright Notice    
'**
'**  Web Wiz Forums(TM)
'**  http://www.webwizforums.com
'**                            
'**  Copyright (C)2001-2008 Web Wiz(TM). All Rights Reserved.
'**  
'**  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS UNDER LICENSE FROM 'WEB WIZ'.
'**  
'**  IF YOU DO NOT AGREE TO THE LICENSE AGREEMENT THEN 'WEB WIZ' IS UNWILLING TO LICENSE 
'**  THE SOFTWARE TO YOU, AND YOU SHOULD DESTROY ALL COPIES YOU HOLD OF 'WEB WIZ' SOFTWARE
'**  AND DERIVATIVE WORKS IMMEDIATELY.
'**  
'**  If you have not received a copy of the license with this work then a copy of the latest
'**  license contract can be found at:-
'**
'**  http://www.webwizguide.com/license
'**
'**  For more information about this software and for licensing information please contact
'**  'Web Wiz' at the address and website below:-
'**
'**  Web Wiz, Unit 10E, Dawkins Road Industrial Estate, Poole, Dorset, BH15 4JD, England
'**  http://www.webwizguide.com
'**
'**  Removal or modification of this copyright notice will violate the license contract.
'**
'****************************************************************************************



'*************************** SOFTWARE AND CODE MODIFICATIONS **************************** 
'**
'** MODIFICATION OF THE FREE EDITIONS OF THIS SOFTWARE IS A VIOLATION OF THE LICENSE  
'** AGREEMENT AND IS STRICTLY PROHIBITED
'**
'** If you wish to modify any part of this software a license must be purchased
'**
'****************************************************************************************



'Set the response buffer to true as we maybe redirecting
Response.Buffer = True


'Declare vars
Dim intSearchInterval		'Holds the amount of time between searches
Dim intMaxResults		'Holds the maximum returned results
Dim intShowTopicsFrom		'Holds when to show topic from
Dim strSQLwhereDate		'Holds the SQL for the date to get results for
Dim iarySearchForumID		'Holds the forums to be searched
Dim intCurrentRecord		'Holds the current record position
Dim strMemberName		'Holds the member name to search for
Dim intDateDirection		'Set if we are looking before or after trhe date given
Dim strSearchKeywords		'Holds the keywords to be search for
Dim sarySearchWord		'Array holding each of the search keywords
Dim strSQLwhereKeywords		'Holds the SQL for the seach oart of the sql query
Dim strTableFieldName		'Holds the table field
Dim strSQLoperator		'Holds AND or OR
Dim strSQLwhereForum		'Holds which forum to search
Dim strSQLwhereMemSearch	'Holds which user to search for
Dim strSearchType		'Holds the search type
Dim strSearhIn			'Holds where we are searching
Dim strDateDirection		'Holds the direction to run the searc in (before or after date)
Dim strForumIDs			'Holds the forum ID to search in
Dim blnExactUserMatch		'Set to true if the username needs to be exact
Dim strOrderBy			'Holds the order by cluse for the sql query
Dim sarySearchIndex		'Holds the details of the search array
Dim strSeachIPAddress		'Holds the user IP
Dim blnSearchIPFound 		'Set to true if the IP address has run a search recently
Dim lngSearchID			'Holds the search ID
Dim intSearchTimeToLive		'Holds the time to keep the search in memory
Dim blnResultsFound		'Set to true of no results found
Dim intRemovedEntries		'Holds the removed entries
Dim blnSearhWordsTwoShort	'Set to true if search words are below 4 chars
Dim intSearchWordLength		'Holds the length of the search words
Dim strResultType		'Holds the result type of how the results are displayed
Dim lngTopicID			'Holds the topic id if doing a topic search




'Initialise variables

intSearchTimeToLive = 20 	'Amount of minutes to keep the search in memory	

intCurrentRecord = 0
intRemovedEntries = 0
blnSearchIPFound = false
blnResultsFound = false
blnSearhWordsTwoShort = false


'Set the time between searches
'If not logged in then 30 secounds
If intGroupID = 2 Then
	intSearchInterval = 30 'Length of time between new searches for non-logged in users
	intSearchWordLength = 2 'Holds the minimum search word length non-logged in users
'Else logged in users 0 secounds
Else
	intSearchInterval = 0
	intSearchWordLength = 1 'Holds the minimum search word length for loged in users
End IF



'Get the users IP address
strSeachIPAddress = getIP()


'******************************************
'***   	Read in form details		***
'******************************************

'Read in form input
strSearchKeywords = Trim(Mid(Request.Form("KW"), 1, 35))
strSearchType = Request.Form("searchType")
strMemberName = Trim(Mid(Request.Form("USR"), 1, 20))
blnExactUserMatch = CBool(Request.Form("UsrMatch"))
strSearhIn = Request.Form("searchIn")
intShowTopicsFrom = CInt(Request.Form("AGE"))
strDateDirection = Request.Form("DIR")
strForumIDs = Request.Form("forumID")
strOrderBy = Request.Form("OrderBy")
strResultType = Request.Form("resultType")

'Set up topic search, if searching in a topic
If Request.Form("qTopic") Then 
	lngTopicID = CLng(Request.Form("TID"))
	strSearhIn = "body"
	intShowTopicsFrom = 0
	strOrderBy = "StartDate"
	strResultType = "posts"
End If	





'******************************************
'***   	Set max search results		***
'******************************************

If strResultType = "topics" Then
	intMaxResults = 100 'The max amount of results when searching as topics (topics requires more joins so is less efficeint)
Else
	intMaxResults = 250 'The max amount of results when search as posts
End If





'******************************************
'***   	Initialise  array		***
'******************************************
	
'Initialise  the array from the application veriable
If IsArray(Application(strAppPrefix & "sarySearchIndex")) Then 
	
	'Place the application level search results array into a temporary dynaimic array
	sarySearchIndex = Application(strAppPrefix & "sarySearchIndex")


'Else Initialise the an empty array
Else
	ReDim sarySearchIndex(5,0)
End If


'Array dimension lookup table
' 0 = Search ID
' 1 = IP
' 2 = Date/time last run
' 3 = Member ID
' 4 = Date/time search created
' 5 = time taken to run search



'**************************************************
'***  IP check to limit no. of searches		***
'**************************************************

'Iterate through the array to see if the IP address has ran a search in the last xx secounds
For intCurrentRecord = 0 To UBound(sarySearchIndex, 2)
	If sarySearchIndex(1, intCurrentRecord) = strSeachIPAddress AND CDate(sarySearchIndex(4, intCurrentRecord)) > DateAdd("s", - intSearchInterval, Now()) Then 
		blnSearchIPFound = true
	End If
Next 






'******************************************
'***   	Remove old search results	***
'******************************************

'Iterate through the array to see if the search is already in memory and see if the IP address has ran a search in the last xx secounds
For intCurrentRecord = 1 To UBound(sarySearchIndex, 2)
	
	'Check the serach results are not old, if they are remove them
	If CDate(sarySearchIndex(2, intCurrentRecord)) < DateAdd("n", - intSearchTimeToLive, Now()) Then
		
		'Delete the search result application array
		'Lock the application so that no other user can try and update the application level variable at the same time
		Application.Lock
		
		'Distroy the application level array
		Application(sarySearchIndex(0, intCurrentRecord)) = null
		
		'Unlock the application
		Application.UnLock
		
		'Swap this array postion with the last in the array
		sarySearchIndex(0, intCurrentRecord) = sarySearchIndex(0, UBound(sarySearchIndex, 2))
		sarySearchIndex(1, intCurrentRecord) = sarySearchIndex(1, UBound(sarySearchIndex, 2))
		sarySearchIndex(2, intCurrentRecord) = sarySearchIndex(2, UBound(sarySearchIndex, 2))
		sarySearchIndex(3, intCurrentRecord) = sarySearchIndex(3, UBound(sarySearchIndex, 2))
		sarySearchIndex(4, intCurrentRecord) = sarySearchIndex(4, UBound(sarySearchIndex, 2))
		sarySearchIndex(5, intCurrentRecord) = sarySearchIndex(5, UBound(sarySearchIndex, 2))
		
		'Set how many entries to remove
		intRemovedEntries = intRemovedEntries + 1
	End If
Next

'Remove the end array entries that are no-longer needed
If intRemovedEntries <> 0 Then ReDim Preserve sarySearchIndex(5, UBound(sarySearchIndex, 2) - intRemovedEntries)


'Reset current record variable
intCurrentRecord = 0

'If there is nothing to seardh for don't run search
If strSearchKeywords = "" AND strMemberName = "" Then blnSearhWordsTwoShort = True


'******************************************
'***   	Build SQL Query for Search	***
'******************************************

If blnSearchIPFound = false Then


	'******************************************
	'***   	SQL for keyword search		***
	'******************************************
	 
	'Build the SQL search string
	If strSearchKeywords <> "" Then
		
		'Filter for SQL injections
		strSearchKeywords = formatSQLInput(strSearchKeywords)
		
		'If searcing in a topic
		If strSearhIn = "subject" Then
			
			'Filter more if a topic subject search, as topic subjects are filtered more
			strSearchKeywords = removeAllTags(strSearchKeywords)
	
			'Set the field name for the SQL query
			strTableFieldName = strDbTable & "Topic.Subject"
		

⌨️ 快捷键说明

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