% Option Explicit %> <% '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 = 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 = "htm,html" ' --------------------- Place the names of the folders you don't want searched in the following line spearated by commas -------------------------- strBarredFolders = "_private,_vti_cnf,_borders" '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 = "toc.htm" '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 %>
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
-- |
||||||||
![]() |
![]() |
![]() |
|||||||||||||
|
|
|
|
|
|
|
|
|||||||||
| Search our Website... | |||||||||||||||
|
Louisiana Public Service Commission
|
Use the form below to search for documents
in this Web site containing specific words or combinations of words. The
text search engine will display a weighted list of matching documents, with
better matches shown first. Each list item is a link to a matching document;
if the document has a title it will be shown, otherwise only the document's
file name is displayed.
<%
'Read in all the search words into one variable
strSearchWords = Trim(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 < and >
strSearchWords = Replace(strSearchWords, "<", "<", 1, -1, 1)
strSearchWords = Replace(strSearchWords, ">", ">", 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
'Call the Bubble Sort procedure to sort the results into highest matches first
Call SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)
'Display the HTML table with the results status of the search or what type of search it is
Response.Write vbCrLf & "
" Response.Write vbCrLf & "
Error The Server does not support the Regular Expessions object 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(" " & strPageDescription sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & " Search Matches " & intNumMatches & " - Last Updated " & FormatDateTime(filObject.DateLastModified, VbLongDate) & " - Size " & CInt(filObject.Size / 1024) & "kb" '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 %> |
||||||||||||||
Concordia
Electric Cooperative, Inc1865 Hwy 84 PO Box 98 Jonesville, LA 71343-0098 Tel: (318) 339-7969 | Fax: (318) 339-7462 Toll Free for 318 Area Code: 1-800-617-6282 General Email: info @ concordiaelectric.com |
|
||||||||||||||
|
|
|||||||||||||||
|
|
|||||||||||||||