<%
Head = "Search"
SearchString = Request ("SearchString ")
Count = 0
Function UnMapPath (Path)
UnMapPath = Replace (Mid (Path, Len (Server. MapPath ("/") + 1 ),"\","/")
'Convert the actual path of the current directory to a virtual path.
End Function
Function SearchFile (f, s, title)
Set fo = fs. OpenTextFile (f)
Content = fo. ReadAll
'Read all the text to the content.
Fo. Close
SearchFile = InStr (1, content, S, vbTextCompare)> 0
'Check whether there is S in the content from the first character.
If SearchFile Then
'If there is, the title of the file is put into the variable.
Pos1 = InStr (1, content, "<title>", vbTextCompare)
Pos2 = InStr (1, content, "</title>", vbTextCompare)
Title = ""
If pos1> 0 And pos2> 0 Then
'Use the title to mark the characters in the middle.
Title = Mid (content, pos1 + 7, pos2-pos1-7)
End If
End If
End Function
Function FileLink (f, title)
VPath = UnMapPath (f. Path)
'Obtain the path.
If title = "" Then title = f. Name
'Make a link.
FileLink = "<a href =" "& vPath &" ">" & title & "</A>"
FileLink = "<UL> ·" & FileLink & "</UL>"
End Function
Sub SearchFolder (fd, s)
Found = False
For each f In fd. Files
Pos = Limit Rev (f. Path ,".")
If pos> 0 Then
Ext = Mid (f. Path, pos + 1)
Else
Ext = ""
End If
If LCase (ext) = "htm" Then
'Display the file with the extension name HTM.
If SearchFile (f, s, title) Then
Response. Write FileLink (f, title)
Count = count + 1
Response. Write cstr (count)
End If
End If
Next
For each sfd In fd. SubFolders
SearchFolder sfd, s
Next
End Sub
%>
<Html>
<Head>
<Meta http-equiv = "Content-Type"
Content = "text/html; charsets = gb_2312-80">
<Meta name = "GENERATOR" content = "Microsoft FrontPage Express 2.0">
<Title> <% = head %> </title>
</Head>
<Body>
<H1> galaxy movie invincible text search <% = head %>
<Hr>
<Form action = "search. asp" method = "Get">
<P> enter the content you want to search for: <input type = "text"
Size = "20" name = "SearchString" value = "<% = SearchString %>"> <input
Type = "submit" value = "Search"> </p>
</Form>
<%
Set fs = Server. CreateObject ("Scripting. FileSystemObject ")
Set fd = fs. GetFolder (Server. MapPath ("/"))
'Set the start search path.
If SearchString <> "" Then
Response. Write "<H2> Search <font color = red>" & SearchString & "</font> result: </H2> <P>"
SearchFolder fd, SearchString
End If
%>
<Hr>
</Body>
[1]