searchfiles.htmlÂ
<html>
<head>
<title>æ¼éªå·äºä¹æ¬ç½æç´¢å¼æ</title>
</head>
<body>
<form method=”POST” action=”cgi-bin/searchfiles.asp”>
 <table border=”0″ cellpadding=”5″ bgcolor=”#C2E7E3″>
   <tr>
     <td align=”center”>请è¾å ¥æ¡ç®æå ³é®è¯<input type=”text” name=”term” size=”15″> <input  type=”submit” value=”æç´¢“></td>
   </tr>
 </table>
</form>
</body></html>
 xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /??
searchfiles.asp
<%
SearchTerm = request.form(“term”)
Novalid=” a b c d e f g h i j k l m n o p q r s t u v w x y z yes no and more”
NovalidResponse =”ä½ è¾å
¥çå
容è¿äºç®å,请è¿åéè¯!”
if instr(SearchTerm,Novalid)=0 then
Response. Write (“<CENTER><H2>æç´¢ç»æ</H2></CENTER>”)
 FolderName= “FolderName”
 ShowList()
else
Response.Write NovalidResponse
End if
SearchResponse=””
%>
<%
Sub ShowList()
FolderToCheck = server.mappath(“\”) &”/” & FolderName & “/”
Dim fs, f, f1, fc, s
  Set fs = CreateObject(“Scripting.FileSystemObject”)
  Set f = fs.GetFolder(FolderToCheck)
Set fc = f.Files
For Each f1 in fc
    Wfile = f1.name
     if right(Wfile, 5)=”.html” OR right(Wfile, 4)=”.htm” then
      Wfile2 = FolderToCheck & Wfile
      Set fs = CreateObject(“Scripting.FileSystemObject”)
      Set a = fs.OpenTextFile(Wfile2)
      ct = a.ReadAll
      a.close
      ct2=lcase(ct)
      SearchTerm2 = lcase(SearchTerm)
         if instr(ct2,SearchTerm2)>0 then
           if instr(ct,”</title>”)>0 then
         longitud=instr(ct,”</title>”)
         longitud=longitud -1
             ct=left(ct,longitud)
             longitud2=len(ct)
         longitud=instr(ct,”<title>”)
         longitud=longitud2 -longitud -6
             ct=right(ct,longitud)
          else
            if instr(ct,”</title>”)>0 then
          longitud=instr(ct,”</title>”)
          longitud=longitud -1
              ct=left(ct,longitud)
              longitud2=len(ct)
          longitud=instr(ct,”<title>”)
          longitud=longitud2 -longitud -6
              ct=right(ct,longitud)
      end if
          end if
          SearchResponse= SearchResponse +”<tr><td>”+ ct + “</td><td ALIGN=CENTER
VALIGN=MIDDLE>” + ” <A HREF=” + “/” + FolderName + “/” + Wfile +”> More </A></td></tr>”
     longitud=0
         ct=””
         end if
     end if
Next
Response.Write (“<html><head><title>æç´¢ç»æ</title></head><body BGCOLOR=FFFFFF><CENTER>”)Â
Response.Write (“<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0><FONT SIZE=5><B>æç´¢ç»æ</B></FONT></td></tr></TABLE>”)Â
Response.Write (“<TABLE BORDER=0 WIDTH=550>”)Â
if SearchResponse<>”” thenÂ
Response.Write SearchResponse
else
Response.Write (“<tr><td>对ä¸èµ·,没ææ¾å°ä½ è¾å
¥çæ¡ç®æå
³é®è¯!</td></tr>”)
end if
Response.Write (“</TABLE>”)
Response.Write (“<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>ç°å¨è°ç¨ä¸ä¸æç´¢å¼æ<A HREF= http://www.yahoo.com.cn/ </A></FONT></td></tr></TABLE>”)
‘ ä»»éä¸ä¸ªä½ å欢çå¼æ.
Response.Write (“</CENTER></body></html>”)
End Sub
%>
Â
Â
[1]