<% @ LANGUAGE = "VBscript" %>
<Html>
<Head>
<Meta NAME = "GENERATOR" Content = "Microsoft FrontPage 3.0">
<Meta HTTP-EQUIV = "Content-Type" content = "text/html; charset = gb_2312-80">
<Title>Galaxy video full-text search</Title>
<Meta name = "Microsoft Border" content = "tl, default">
</Head>
<Body BGPROPERTIES = "FIXED" BGCOLOR = "#00 FFFF">
<%
Mousepointer = 13
Set Conn1 = Server. CreateObject ("ADODB. Connection ")
Conn1.open "DSN = intels"
Set rcst1 = conn1.execute ("select * from pages_catalogue ")
Sch_str = request. form ("text1 ")
Doubbytes = len (sch_str) \ 2
Sch_str = left (sch_str, doubbytes)
'Matching String Length.PreprocessingRequestObtained data (useful information entered by the user),Extract the required string by calculating the length of valid information.You can also append a flag character (for example#OrChr (7))..
Response. Write "<CENTER>Search results<HR> <Br>"
Dim result
Result = false
Response. Write "<UL>"
Do while not rcst1.eof
Tit = rcst1.fields ("file_title ")
Fn = rcst1.fields ("file_name ")
File_name = Server. MapPath ("/") & "\ song \ chunfeng \" & fn
To_find = text_match (file_name, sch_str)
'Open the files pointed to by the current record in the record set one by one. Use the searched string to match and compare the full text of the file.
If to_find then
Url = "chunfeng/" & fn
Response. Write "<a href =" & url & ">
"& Tit
End if
Rcst1.movenext
Result = result or to_find
Loop
Response. Write "</UL>"
'SetThe qualified file title is output to the client as a hyperlink.
If not result then
Response. Write"Sorry,Not found! "
End if
Mousepointer = 0
%>
<Script RUNAT = "Server" LANGUAGE = "VBScript">
Function text_match (filename, search_string)
Dim retstring
Dim find_pos
Dim fso,
Dim done
Text_match = false
Set fso = Server. CreateObject ("Scripting. FileSystemObject
")
'Create a script file system,Open Text Stream to read.
Set a = fso. OpenTextFile (filename, 1, FALSE)
Done = a. AtEndOfStream or text_match
Do While not done
Retstring = a. ReadLine
Find_pos = instr (retstring, search_string)
If find_pos> 0 then text_match = true
Done = a. AtEndOfStream or text_match
Loop
A. Close
End function
</Script>
</Body>
[1]