![]() |
|||||
| Search | |||||
|
<%
'===============================
Function FormatURL(strPath)
'Cut off everything before wwwroot and replace all \ with /
Dim iPos
Dim str
iPos = InStr(1,strPath,"wwwroot",1)
str = Mid(strPath,iPos+7,Len(strPath))
FormatURL = Replace(str,"\","/")
End Function
'===============================
Function RemoveHTML( strText )
Dim nPos1
Dim nPos2
nPos1 = InStr(strText, "<")
Do While nPos1 > 0
nPos2 = InStr(nPos1 + 1, strText, ">")
If nPos2 > 0 Then
strText = Left(strText, nPos1 - 1) & Mid(strText, nPos2 + 1)
Else
Exit Do
End If
nPos1 = InStr(strText, "<")
Loop
RemoveHTML = strText
End Function
Function GetFiles(objFolder, aLookFor, Matches, plist, acount)
Lastfile = Request("f")
'Set Regexp = New RegExp
If Left(objFolder.Name,1) = "_" then exit function
If right(objFolder.Name,5) = "stats" then exit function
If Left(objFolder.Name,7) = "cgi-bin" then exit function
If Left(objFolder.Name,7) = "cpagnet" then exit function
If Left(objFolder.Name,6) = "images" then exit function
Const iListPerPage = 200
if Matches > iListPerPage then Exit Function
'Now, loop through each file
Dim objFile, objTextStream, objFSO, strContents, iUBound, iLoop, bolValid
Dim strTitle, iPos, strDesc
iUBound = UBound(aLookFor)
For Each objFile in objFolder.Files
'=== Do we need to search this file?
If instr(UCase(objFile.Name), ".HTM") > 0 then
acount = acount + 1
if (acount > 0 + LastFile) and (lastfile + 0 = 0 or matches < 10) then
if objFile.Size > 0 then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(objFile.Path,1)
strContents = objTextStream.ReadAll
objTextStream.Close
Set objFSO = Nothing
'=================== Title?
t1 = InStr(1,strContents," " & vbCrLf Response.Write "" & strDesc Response.Write " " & vbCrLf end if Matches = Matches + 1 if matches mod 10 = 0 then plist = plist & " " & acount end if End if If Matches > iListPerPage then strLF = FormatURL(objFile.Path) exit function End If End If end if End if Next '== Recursive function call to loop through subdirectories Dim objSubFolder For Each objSubFolder in objFolder.SubFolders GetFiles objSubFolder,aLookFor,Matches,plist,acount Next End Function '=============================== 'Search the site! Dim strKeywords Dim section Dim termsArray Dim objFSO, objFolder Dim iResults strKeywords = trim(Request("terms")) termsArray = split(strKeywords," ") section = Request("selSearchWhere") section = Server.MapPath("./") '======================== Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(section) Set objFSO = Nothing %> Results <% iResults = 0 '=== only search if there are keywords entered If trim(sterms & "" ) > "" then '==== call recursive directory search GetFiles objFolder,termsArray,iResults,plist,acount Set objFolder = Nothing '=== count of links nlist = request("plist") Tcount = request("T") if tcount + 0 > iresults then iresults = Tcount if len(nlist) > len(plist) then plist=nlist LinkArray = split(plist," ") LinkUBound = UBound(LinkArray) response.write(" " ) response.write(iresults & " pages found") response.write(" " ) if iresults mod 10 = 0 then Linkubound = linkubound - 1 if iresults > 10 then response.write("   1   ") For LinkLoop = 1 to LinkUBound response.write("   " & LinkLoop + 1 & "   ") Next End if response.write(" ") '=================================== If iResults = 0 then 'No results found %> No results found for <%response.write(sterms)%> <% End IF Else Response.write("Enter in key words") End if %> |
|||||