Search
 

 
Look for: <% sterms = request("terms") %>
<% '=============================== 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,"") t2 = InStr(1,strContents,"") if t1>0 and t2 > t1+7 then strTitle = mid(strcontents, t1+7, t2 - (t1+7)) & " (" & objFile.Name & ")" else strTitle = "CPAG-Guide (" & objFile.Name & ")" end if '=================== remove html 'Set the regular expression object to read all cases of the occurance not just the first 'Regexp.Global = True 'Set the regular expression object to ignore case 'Regexp.IgnoreCase = True '==Set the pattern using regular expressions to srip any HTML tags 'Regexp.Pattern = "<[^>]*>" '==Strip HTML tags from the contects of the file to be searched 'strContents = RemoveHTML(strContents) '=============================== bolValid = True For iLoop = 0 to iUBound m = InStr(1,strContents,aLookFor(iLoop),1) If m then 'spc = InStr(m,strContents," ",1) addedinfo = ("..." & mid(strcontents, m - 20, 40) & "...") Else bolValid = False exit for End If Next If bolValid then path = FormatURL(objFile.Path) path = mid(path, 18) if matches < 10 then '== only strip files where we found it - and if in first 10! strContents = RemoveHTML(strContents) m = InStr(1,strContents,aLookFor(0),1) if m> 0 then addedinfo = ("..." & mid(strcontents, m - 20, 40) & "...") '===== Response.Write "" & strTitle & "- " & addedinfo &"
" & 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 %>