<% Option Explicit %>
<%

Server.ScriptTimeout = 1000
'content_indexer.asp
'****************************************************************************************
'** Copyright Notice
'**
'** Web Wiz Guide Advanced Site Search Engine
'**
'** Copyright 2001-2002 Bruce Corkhill All Rights Reserved.
'**
'** This program is free software; you can modify (at your own risk) any part of it
'** under the terms of the License that accompanies this software and use it both
'** privately and commercially.
'**
'** All copyright notices must remain in tacked in the scripts and the
'** outputted HTML.
'**
'** You may use parts of this program in your own private work, but you may NOT
'** redistribute, repackage, or sell the whole or any part of this program even
'** if it is modified or reverse engineered in whole or in part without express
'** permission from the author.
'**
'** You may not pass the whole or any part of this application off as your own work.
'**
'** All links to Web Wiz Guide and powered by logo's must remain unchanged and in place
'** and must remain visible when the pages are viewed unless permission is first granted
'** by the copyright holder.
'**
'** This program is distributed in the hope that it will be useful,
'** but WITHOUT ANY WARRANTY; without even the implied warranty of
'** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER
'** WARRANTIES WHETHER EXPRESSED OR IMPLIED.
'**
'** You should have received a copy of the License along with this program;
'** if not, write to:- Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom.
'**
'**
'** No official support is available for this program but you may post support questions at: -
'** http://www.webwizguide.info/forum
'**
'** Support questions are NOT answered by e-mail ever!
'**
'** For correspondence or non support questions contact: -
'** info@webwizguide.com
'**
'** or at: -
'**
'** Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom
'**
'****************************************************************************************
'This modification to serve as a site file content indexer by Lil Peck August 2, 2004.
'Thanks to Vladimir Miho for his logging script that creates the csv file!



'Set the response buffer to true
Response.Buffer = False

'Dimension global variables
Dim fsoObject 'File system object
Dim fldObject 'Folder object
Dim sarySearchWord 'Array to hold the words to be searched for
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(1000,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 = 1500 '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 = "htm,html,rtf,jpg,doc,pdf,txt"

' --------------------- Place the names of the folders you don't want searched in the following line spearated by commas --------------------------
strBarredFolders = "_vti_cnf" 'cgi_bin and _bin have been put in here as examples, but you can put any folders in here

' ---------- Place the names of the files you don't want searched in the following line spearated by commas include the file extension -------------
strBarredFiles = "adminstation.htm,download.asp" 'adminstration.htm and not_allowed.asp have been put in as an examples

' -------------------- Set this boolean to False if you are not using an English language web site --------------------------------------------------
blnEnglishLanguage = True 'True = HTML Encode best for English sites \ False = no Emcoding best for non English sites

'-----------------------------------------------------------------------------------------------------------------------------------------------------


'Initalise variables
intTotalFilesSearched = 0

%>
<html>
<head>
<title>Index File Content in this folder.</title>
<meta name="Description" content="Search the web site for pages or information that you are after">
<meta name="KeyWords" content="site search">

<!-- The Web Wiz Guide advanced site search engine is written and produced by Bruce Corkhill 2001
If you want your own site search engine then go to http://www.webwizguide.info -->


</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000CC" vlink="#0000CC" alink="#FF0000">
<h1 align="center">Site File Content Indexer</h1>

<p align="center">Script modified from WebWizGuide.info original site_search.asp<br>
Thanks to Vladimir Miho&nbsp;for his logging script that creates the csv file.</p>

<form method="get" name="frmSiteSearch" action="content_indexer.asp">
<table cellpadding="0" cellspacing="0" width="90%" align="center">
<tr>

<td height="66" width="165" align="right" rowspan="3" valign="middle">
&nbsp;</td>
<td height="66" width="15" align="right" rowspan="3" valign="middle">&nbsp;</td>
<td class="arial" height="4" width="571"> Index the files in this folder: </td>
</tr>
<tr>
<td class="normal" height="2" width="571">
<input type="hidden" name="search" maxlength="50" size="36" value="*">
<input type="submit" value="INDEX" name="submit">
</td>
</tr>
<tr>
<td class="normal" height="34" width="571" valign="top"> &nbsp;</td>
</tr>
</table>
</form>

<%

'Read in all the search words into one variable
strSearchWords = request.querystring("search")

'If the site is in English then use the server HTML encode method
If blnEnglishLanguage = True Then
'Replace any HTML tags with the HTML codes for the same characters (stops people entering HTML tags)
strSearchWords = Server.HTMLEncode(strSearchWords)

'If the site is not english just change the script tags
Else
'Just replace the script tag <> with HTML encoded &lt; and &gt;
strSearchWords = Replace(strSearchWords, "<", "&lt;", 1, -1, 1)
strSearchWords = Replace(strSearchWords, ">", "&gt;", 1, -1, 1)
End If

'Slit each word to be searched up and place in an array
sarySearchWord = Split(Trim(strSearchWords), " ")



'Read the file number to show from
intFileNum = CInt(Request.QueryString("FileNumPosition"))

'Set the number of files shown so far to the file number read in above
intNumFilesShown = intFileNum


'Create the file system object
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")


'If there is no words entered by the user to search for then dont carryout the file search routine
If NOT strSearchWords = "" Then


'Get the path and the root folder to be searched
Set fldObject = fsoObject.GetFolder(Server.MapPath("./"))

'Read in the server path to this ASP script
strServerPath = fldObject.Path & "\"

'Set to true as this is searching the root directory
blnIsRoot = True

'Call the search sub prcedure
Call SearchFile(fldObject)

'Reset server variables
Set fsoObject = Nothing
Set fldObject = Nothing



'Display the HTML table with the results status of the search or what type of search it is
Response.Write vbCrLf & " <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#CCCCCC"">"
Response.Write vbCrLf & " <tr>"


'Close the HTML table with the search status
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"


'HTML table to display the search results or an error if there are no results
Response.Write vbCrLf & " <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td>"


'the following log script is by Vladimir Miho and is seen at http://planet-source-code.com/vb/scripts/showcode.asp?lngWId=4&txtCodeId=8911

Const strFolderName = "U_Z"
Const strFileExt = ".csv"

Dim strLogsPath, data
strLogsPath = Server.MapPath(strFolderName) &"..\..\"



'data = "this is a new line of text...."
'Call CreateLogFile(strLogsPath,strFileExt)
'Call WriteLog(strLogsPath,strFileExt,data)




'=------------------------------------------------------------------------------='
'=- This function will create the log file if it doesn't exist -='
'=- INPUT: -='
'=- -> strLogFolderPath - the path where the log file should be -='
'=- created -='
'=- -> strFileExt - extension of the log file -='
'=- OUTPUT: -='
'=- -> Creates the file if it does not exist in the given folder -='
'=------------------------------------------------------------------------------='
Function CreateLogFile(byVal strLogFolderPath, byVal strFileExt)
'generate log file name
dim strLogFileName
strLogFileName = FileName(strFileExt)
'check if the file doesn't exist in the folder (if no create it)
If CheckIfFileExists(strLogFolderPath, strLogFileName) = False Then
'Declare local variables
Dim objFSO, objCreatedFile
'create an instance FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'create text file
Set objCreatedFile = objFSO.CreateTextFile(strLogFolderPath & strLogFileName, True)
'close instance
objCreatedFile.Close
Set objFSO = nothing
Else
'if the log file already exists then exit function
Exit Function
End if
End Function

'=------------------------------------------------------------------------------='
'=- This function will generate the file name in the format YYYYMMDD.extension -='
'=- INPUT: -='
'=- -> strFileExt - file extension for the log file ex. '.dat' -='
'=- OUTPUT: -='
'=- -> File name ex. 20040707.dat -='
'=------------------------------------------------------------------------------='
Function FileName(byVal strFileExt)
dim strYear,strMonth,strDay
strYear = DatePart("YYYY",Date) 'get current year
strMonth = DatePart("M",Date) 'get current month
strDay = DatePart("D",Date) 'get current date
'if the month is one digit ex. 7 then add a '0' in front to become 07
If Len(strMonth) = 1 Then strMonth = "0"&strMonth
'if the date is one digit ex. 7 then add a '0' in front to become 07
If Len(strDay) = 1 Then strDay = "0"&strDay
'construct the filename.
FileName = strYear&strMonth&strDay&strFileExt
End Function

'=------------------------------------------------------------------------------='
'=- Checks if A SPECIFIC file EXISTS in A SPECIFIC folder -='
'=- INPUT: -='
'=- -> FolderPath: the path of the folder -='
'=- -> FileName: the name of the file you want to check for -='
'=- OUTPUT: -='
'=- -> True: if the file exists -='
'=- -> False: if the file does not exist -='
'=------------------------------------------------------------------------------='
Function CheckIfFileExists(byVal FolderPath, byVal FileName)
CheckIfFileExists = False
Dim objFSO, objFolder,file
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
For Each file In objFolder.files
if Lcase(file.name) = Trim(LCase(Filename)) Then
CheckIfFileExists = True
End if
Next
Set objFSO = nothing
End function


'=------------------------------------------------------------------------------='
'=- This subroutine will append the data you pass to it to a new line in the -='
'-= log file -='
'=- INPUT: -='
'=- -> strLogFolderPath - the path of the folder where the log -='
'=- file is located -='
'=- -> strData - the data you want to append to file -='
'=------------------------------------------------------------------------------='
Sub WriteLog (byVal strLogFolderPath, byVal strFileExt, byVal strData)
'construct full path with the file name
dim strPath, Forappending,tempFile
strPath = strLogFolderPath & FileName(strFileExt)
'declare variables
Dim objFSO, tmpFile
'create an instance FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Forappending = 8
'open file for appending
set tempFile = objFSO.OpentextFile(strPath, Forappending)
'add the data into a new line. Time() will print the current time when the data
'will be written to file
tempFile.writeline data
'close instance
tempFile.close
Set tempFile = nothing
Set objFSO = nothing
End Sub

'=------------------------------------------------------------------------------='








'Loop round to display each result within the search results array
For intDisplayResultsLoopCounter = (intFileNum + 1) to intNumFilesShown



data = sarySearchResults(intDisplayResultsLoopCounter,1)
Call CreateLogFile(strLogsPath,strFileExt)
Call WriteLog(strLogsPath,strFileExt,data)


'Response.Write vbCrLf & " <br>"
Response.Write vbCrLf &sarySearchResults(intDisplayResultsLoopCounter,1) & vbNewLine


Next



'Close the HTML table displaying the results
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"




'Display an HTML table with links to the other search results
If intTotalFilesFound > intRecordsPerPage then

'Display an HTML table with links to the other search results
Response.Write vbCrLf & " <br>"
Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td>"
Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
Response.Write vbCrLf & " <tr>"
Response.Write vbCrLf & " <td width=""50%"" align=""center"">"

Response.Write vbCrLf & " Results Page:&nbsp;&nbsp;"


'If the page number is higher than page 1 then display a back link
If intNumFilesShown > intRecordsPerPage Then
Response.Write vbCrLf & " <a href=""site_search.asp?FileNumPosition=" & intFileNum - intRecordsPerPage & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=allwords" & """ target=""_self"">&lt;&lt;&nbsp;Prev</a> "
End If


'If there are more pages to display then display links to all the search results pages
If intTotalFilesFound > intRecordsPerPage Then

'Loop to diplay a hyper-link to each page in the search results
For intPageLinkLoopCounter = 1 to CInt((intTotalFilesFound / intRecordsPerPage) + 0.5)

'If the page to be linked to is the page displayed then don't make it a hyper-link
If intFileNum = (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage Then
Response.Write vbCrLf & " " & intPageLinkLoopCounter
Else

Response.Write vbCrLf & " &nbsp;<a href=""site_search.asp?FileNumPosition=" & (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">" & intPageLinkLoopCounter & "</a>&nbsp; "
End If
Next
End If


'If it is Not the last of the search results than display a next link
If intTotalFilesFound > intNumFilesShown then
Response.Write vbCrLf & " &nbsp;<a href=""site_search.asp?FileNumPosition=" & intNumFilesShown & "&search=" & Replace(strSearchWords, " ", "+") & "&mode=" & Request.QueryString("mode") & """ target=""_self"">Next&nbsp;&gt;&gt;</a>"
End If


'Finsh HTML the table
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"
Response.Write vbCrLf & " </td>"
Response.Write vbCrLf & " </tr>"
Response.Write vbCrLf & " </table>"


End If

%>
<br>
<div align="center">
<table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#CCCCCC" align="center">
<tr>
<td width="47%" height="18">&nbsp;Searched <% = intTotalFilesSearched %> documents in total.</td>
<td width="53%" align="right" height="18"><%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
Response.Write(" Powered By - <a href=""http://www.webwizguide.info"" target=""_blank"">www.webwizguide.info</a>")
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>
</td>
</tr>
</table>
<!-- Swap animated search icon for still icon -->
<script langauge="JavaScript">document.searchIcon.src = search_icon_off.src</script>
<br>
<a href="http://www.webwizguide.info" target="_blank">
http://www.webwizguide.info</a></div>
<br>
</body>
</html>
<%



'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

'Set the error object to 0
Err.Number = 0

'Create the regular expresions object
Set objRegExp = New RegExp

'If an error has occured then the server does not support Regular Expresions
If Err.Number <> 0 Then
Response.Write("<br>Error The Server does not support the Regular Expessions object<br>Please download the alternative version of this application from http://www.webwizguide.info/asp/sample_scripts/site_search_script.asp")

'Reset error object
Err.Number = 0
End If

'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

'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 = GetFileMetaTag("<title>", "</title>", strFileContents)

'Read in the description meta tag of the file
strPageDescription = GetFileMetaTag("<meta name=""description"" content=""", """>", strFileContents)

'Read in the keywords of the file
strPageKeywords = GetFileMetaTag("<meta name=""keywords"" content=""", """>", strFileContents)




'Set the pattern using regular expressions to srip any HTML tags
objRegExp.Pattern = "<[^>]*>"



'Strip HTML tags from the contects of the file to be searched
strFileContents = objRegExp.Replace(strFileContents,"")

'dim MyString
'MyString = Replace(strFileContents, vbCr, "")
'MyString = Replace(strFileContents, vbLf, "")
'MyString = Replace(strFileContents, vbTab, "")
'strFileContents = MyString

Dim RegEx,strText
Set RegEx = New RegExp
RegEx.Pattern = "\s+"
RegEx.Multiline = True
RegEx.Global = True
strText = RegEx.Replace(strFileContents, " ")
strFileContents = strText

Dim sComments
sComments = ReplaceBadWords(filename)


'Function ReplaceBadWords(InputComments)
Dim badChars, newChars, i
'create our array of bad words
badChars = array("<",">","/","'","=","%","^","$","#","@","!","*","elseif","{","}","[","]","\","?","-","(",")","browser_type",";","document.write","elseif","&nbsp;","&nbsp")
newChars = strFileContents
for i = 0 to uBound(badChars)
newChars = Replace(newChars, badChars(i), "")
Next
strFileContents = newChars
'End function



'Put the tittle, description and the keywords back into the file to be searched
strFileContents = strFileContents & " " & strPageTitle & " " & strPageDescription & " " & strPageKeywords



blnSearchFound = True




'Loop round to search for each word to be searched
For intSearchLoopCounter = 0 to UBound(sarySearchWord)

'Set the pattern to search for
objRegExp.Pattern = "\b" & sarySearchWord(intSearchLoopCounter) & "\b"

'Search the file for the search words
Set objMatches = objRegExp.Execute(strFileContents)

'Check to see if any of the words have been found
If objMatches.Count > 0 Then

'Get the number of times the search word is matched
intNumMatches = intNumMatches + objMatches.Count

'If the search word is found and the search is for any words then set the search found variable to true
If Request.QueryString("mode") = "anywords" then blnSearchFound = True

Else
'If the search word is not found and the search is for all words then set the search found variable back to false as one of the words has not been found
If Request.QueryString("mode") = "allwords" then blnSearchFound = False

End If
Next
End If


'Calculate the total files searched
intTotalFilesSearched = intTotalFilesSearched + 1



'If the page contains no title then Page Title variable the appropriate message to display
If strPageTitle = "" Then strPageTitle = "No Title"

if strPageKeywords = "" then strPageKeywords="No keywords."


'If the page contains no title then Page Description variable the appropriate message to display
If strPageDescription = "" Then strPageDescription = "There is no description available for this page"


'If the search found variable is true then display the results
If blnSearchFound = True Then


'Calculate the total files found
intTotalFilesFound = intTotalFilesFound + 1


'Check that the file shown is between the the files shown so far and the maximum files to show per page
If intNumFilesShown < (intRecordsPerPage + intFileNum) and intTotalFilesFound > intNumFilesShown Then

'Calculate the number of results shown
intNumFilesShown = intNumFilesShown + 1

End If



'Place the search results into the saerch results array
'Calculate the array position of the results array
intResultsArrayPosition = intResultsArrayPosition + 1


'Set the search results found boolean to true
blnSearchResultsFound = True

'If the file is in the root directory then
If blnIsRoot = True Then



'Place the search results into the search results array
sarySearchResults(intResultsArrayPosition,1) = intNumFilesShown &"|"& "'" & filObject.Name & "'"& "|" & "'"&strPageTitle &"'"


'Else it is not in the root directiory

'Else



'Place the search results into the search results array
'sarySearchResults(intResultsArrayPosition,1) = strFileURL&"|" & fldObject.Name & "|" & filObject.Name & "|" & "'"&strPageTitle &"'"&""

'End If






'Place the rest of the search results in the search results array


sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & "|"& "'"&strPageDescription&"'"

sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & "|"& FormatDateTime(filObject.DateLastModified, VbLongDate) & "|" & CInt(filObject.Size / 1024)&"|"&"'"& strPageKeywords &"'"&"|"


dim StripFileExt
StripFileExt = Right(filObject.Name, Len(filObject.Name) - InStrRev(filObject.Name, ".") + 1)
StripFileExt=Lcase(StripFileExt)
'response.write StripFileExt
if StripFileExt=".rtf" then
strFileContents="Rich Text File"
end if
if StripFileExt=".jpg" then
strFileContents="JPG File"
end if
if StripFileExt=".doc" then
strFileContents="Word Document File"

end if
if StripFileExt=".pdf" then
strFileContents="Adobe Acrobat Document"
end if

sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) &"'"&strFileContents &"'" &""




'Read in the number of search word matches into the second part of the two dimensional array
sarySearchResults(intResultsArrayPosition,2) = intNumMatches

End If

'Close the text stream object
tsObject.Close
End If
End If
Next

'Reset the Regular Expression object
Set objRegExp = Nothing


'Loop to search through the sub folders within the site
For Each subFldObject In FldObject.SubFolders

'Check to make sure the folder about to be searched is not a barred folder if it is then don't search
If NOT InStr(1, strBarredFolders, subFldObject.Name, vbTextCompare) > 0 Then

'Set to false as we are searching sub directories
blnIsRoot = False


'Get the server path to the file
strFileURL = fldObject.Path & "\"

'Turn the server path to the file into a URL path to the file
strFileURL = Replace(strFileURL, strServerPath, "")

'Replace the NT backslash with the internet forward slash in the URL to the file
strFileURL = Replace(strFileURL, "\", "/")

'Encode the file name and path into the URL code method
strFileURL = Server.URLEncode(strFileURL)

'Just incase it's encoded any backslashes
strFileURL = Replace(strFileURL, "%2F", "/")

'Call the search sub prcedure to search the web site
Call SearchFile(subFldObject)
End If
Next



'Reset server variables
Set filObject = Nothing
Set tsObject = Nothing
Set subFldObject = Nothing
End Sub




'Sub procedure to sort the array using a Bubble Sort to place highest matches first
Private Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)

'Dimension variables
Dim intArrayGap 'Holds the part of the array being sorted
Dim intIndexPosition 'Holds the Array index position being sorted
Dim intTempResultsHold 'Temperary hold for the results if they need swapping array positions
Dim intTempNumMatchesHold 'Temperary hold for the number of matches for the result if they need swapping array positions
Dim intPassNumber 'Holds the pass number for the sort


'Loop round to sort each result found
For intPassNumber = 1 To intTotalFilesFound

'Shortens the number of passes
For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)

'If the Result being sorted hass less matches than the next result in the array then swap them
If sarySearchResults(intIndexPosition,2) < sarySearchResults((intIndexPosition+1),2) Then


'Place the Result being sorted in a temporary variable
intTempResultsHold = sarySearchResults(intIndexPosition,1)

'Place the Number of Matches for the result being sorted in a temporary variable
intTempNumMatchesHold = sarySearchResults(intIndexPosition,2)


'Do the array position swap

'Move the next Result with a higher match rate into the present array location
sarySearchResults(intIndexPosition,1) = sarySearchResults((intIndexPosition+1),1)

'Move the next Number of Matches for the result with a higher match rate into the present array location
sarySearchResults(intIndexPosition,2) = sarySearchResults((intIndexPosition+1),2)

'Move the Result from the teporary holding variable into the next array position
sarySearchResults((intIndexPosition+1),1) = intTempResultsHold

'Move the Number of Matches for the result from the teporary holding variable into the next array position
sarySearchResults((intIndexPosition+1),2) = intTempNumMatchesHold
End If
Next
Next
End Sub




'Function to read in the files meta tags
Private Function GetFileMetaTag(ByRef strStartValue, ByRef strEndValue, ByVal strFileContents)

'Dimension Variables
Dim intStartPositionInFile 'Holds the start position in the file
Dim intEndPositionInFile 'Holds the end position in the file


'Get the start position in the file of the meta tag
intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)


'If no description or keywords are found then you may be using http-equiv= instead of name= in your meta tags
If intStartPositionInFile = 0 And InStr(strStartValue, "name=") Then

'Swap name= for http-equiv=
strStartValue = Replace(strStartValue, "name=", "http-equiv=")

'Check again for keywords or description
intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)
End If


'If there is a description then the position in file will be over 0
If NOT intStartPositionInFile = 0 Then

'Get the end position of the HTML meta tag
intStartPositionInFile = intStartPositionInFile + Len(strStartValue)

'Get the position in file of the closing tag for the meta tag
intEndPositionInFile = InStr(intStartPositionInFile, LCase(strFileContents), strEndValue, 1)

'Read in the meta tag from the file for the function to return
GetFileMetaTag = Trim(Mid(strFileContents, intStartPositionInFile, (intEndPositionInFile - intStartPositionInFile)))

'If the is no meta tag then the GetFileMetaTag function returns a null value
Else
GetFileMetaTag = ""

End If

End Function
end if

%>