50 lines
1.6 KiB
Plaintext
50 lines
1.6 KiB
Plaintext
example usage:
|
|
Search all files of the entire web site For the exact phrase "request.cookies"
|
|
And delete them (also uses the kill statement).
|
|
<%
|
|
' declare variables
|
|
Dim a, b, i
|
|
|
|
' search the entire web site for the phrase "request.cookies"
|
|
a = Search( "request.cookies", Server.MapPath("/") )
|
|
|
|
' iterate the array of results
|
|
b = Split(a , vbCrLf)
|
|
For i = 0 To UBound(b) - 1
|
|
' delete each matching page
|
|
Kill b(i)
|
|
Next
|
|
%>
|
|
source code:
|
|
<%
|
|
Private Function Search(ByVal phrase, ByVal directory)
|
|
Dim objFSO, currentFolder, objFile, currentFile
|
|
Dim strSearch, fileContents, objFolder
|
|
|
|
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
|
|
Set currentFolder = objFSO.GetFolder(directory)
|
|
For Each objFile In currentFolder.Files
|
|
If LCase( objFile.Path ) = _
|
|
LCase( Server.MapPath( _
|
|
Request.ServerVariables("SCRIPT_NAME") ) ) Then
|
|
Else
|
|
Set currentFile = _
|
|
objFSO.OpenTextFile( objFile.Path, 1, False )
|
|
fileContents = LCase( currentFile.ReadAll() )
|
|
currentFile.Close
|
|
Set currentFile = Nothing
|
|
If InStr( fileContents, phrase ) Then
|
|
strSearch = strSearch & objFile.Path & vbCrLf
|
|
Else
|
|
strSearch = strSearch & ""
|
|
End If
|
|
End If
|
|
Next
|
|
For Each objFolder In currentFolder.SubFolders
|
|
strSearch = strSearch & Search( phrase, objFolder )
|
|
Next
|
|
Set currentFolder = Nothing
|
|
Set objFSO = Nothing
|
|
Search = CStr( strSearch )
|
|
End Function
|
|
%> |