% 'Set the response buffer to true Response.Buffer = True 'Dimension global variables Dim fsoObject 'File system object Dim fldObject 'Folder object Dim sarySearchWord 'Array to hold the words to be searched fo Dim strSearchWords 'Holds the search words Dim blnIsRoot 'Set to true if we are searching in the root directory Dim strFileURL 'Holds the path to the file on the site Dim strServerPath 'Holds the server path to this script Dim intNumFilesShown 'Holds the number of files shown so far Dim intTotalFilesSearched 'Holds the number of files searched Dim intTotalFilesFound 'Holds the total matching files found Dim intFileNum 'Holds the file number Dim intPageLinkLoopCounter 'Loop counter to display links to the other result pages Dim sarySearchResults(500,2) 'Two Dimensional Array holding the search results Dim intDisplayResultsLoopCounter 'loop counter to diplay the results of the search Dim intResultsArrayPosition 'Stores the array position of the array storing the results Dim blnSearchResultsFound 'Set to true if search results are found Dim strFilesTypesToSearch 'Holds the types of files to be searched Dim strBarredFolders 'Holds the folders that you don't want searched Dim strBarredFiles 'Holds the names of the files not to be searched Dim blnEnglishLanguage 'Set to True if the user is using English ' -------------------------- Change the following line to the number of results you wish to have on each page ------------------------------------ Const intRecordsPerPage = 10 'change this to the number of results to show on each page ' --------------------- Place the names of the files types you want searching in the following line sepeararted by commas -------------------------- strFilesTypesToSearch = "html" ' --------------------- Place the names of the folders you don't want searched in the following line spearated by commas -------------------------- strBarredFolders = "ns" ' ---------- Place the names of the files you don't want searched in the following line spearated by commas include the file extension ------------- strBarredFiles = "" ' -------------------- Set this boolean to False if you are not using an English language web site -------------------------------------------------- blnEnglishLanguage = True 'True = English \ False = Other language '----------------------------------------------------------------------------------------------------------------------------------------------------- 'Initalise variables intTotalFilesSearched = 0 %> <% 'Sub procedure to do the search Public Sub SearchFile(fldObject) 'Dimension local variabales Dim objRegExp 'Regular Expersions object Dim objMatches 'Holds the matches collection of the regular expresions object Dim filObject 'File object Dim tsObject 'Text stream object Dim subFldObject 'Sub folder object Dim strFileContents 'Holds the contents of the file being searched Dim strPageTitle 'Holds the title of the page Dim strPageDescription 'Holds the description of the page Dim strPageKeywords 'Holds the keywords of the page Dim intSearchLoopCounter 'Loop counter to search all the words in the array Dim intNumMatches 'Holds the number of matches Dim blnSearchFound 'Set to true if the search words are found 'Error handler On Error Resume Next 'Loop to search each file in the folder For Each filObject in fldObject.Files 'Check the file extension to make sure the file is of the extension type to be searched If InStr(1, strFilesTypesToSearch, fsoObject.GetExtensionName(filObject.Name), vbTextCompare) > 0 Then 'Check to make sure the file about to be searched is not a barred file if it is don't search the file If NOT InStr(1, strBarredFiles, filObject.Name, vbTextCompare) > 0 Then 'Initalise the search found variable to flase blnSearchFound = False 'Initalise the number of matches variable intNumMatches = 0 'Create the regular expresions object Set objRegExp = New RegExp 'Set the regular exprsion object to read all cases of the occurance not just the first objRegExp.Global = True 'Set the regular expression object to ignore case objRegExp.IgnoreCase = True 'Open the file for searching Set tsObject = filObject.OpenAsTextStream 'Read in the contents of the file strFileContents = tsObject.ReadAll 'Read in the title of the file strPageTitle = Server.HTMLEncode(GetFileMetaTag("
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
| Search |