⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.asp

📁 本搜索利用了基本的几个ASP语法写成; 我已经做了简单的美化
💻 ASP
字号:
<%
Option Explicit
Dim SearchString
Dim LenKey
Dim fs
Dim fd
'-----------
Const Catalog   = "/"    '被搜索的目录,请使用非绝对路径,当前使用默认的DOWNLOAD目录
Const Head   = "MOMOMAN站内搜索器"   '搜索引擎标题
Const KeyStart   = "<TITLE>"    '被搜索的HTM结构文件的可搜索范围的头标记(大小写无所谓)
Const KeyEnd   = "</TITLE>"    '被搜索的HTM结构文件的可搜索范围的末标记(大小写无所谓)
Const FolderImg   = "momoman_A.gif"    '代表目录的图片路径[可以不改]
Const FileImg   = "momoman_B.gif"    '代表文件的图片路径[可以不改]
Const FileType   = "htm"  '文件类型,后缀名,此处默认的为搜索后缀名称为.ASP的文件内容
SearchString   = Request("SearchString")  '接收被搜索的数值[无需更改]
LenKey    = Len(KeyStart)    'KeyStart字符长度[无需更改]

Function UnMapPath( Path )
    UnMapPath = Replace(Mid(Path, Len(Server.MapPath("/")) + 1), "\", "/")
End Function

Function SearchFile( f, s, title )
 Dim fo
 Dim content
 Dim pos1,pos2
   On Error Resume Next
   Set fo = fs.OpenTextFile(f)
   content = fo.ReadAll
   fo.Close
   SearchFile = InStr(1, content, S, vbTextCompare) > 0 
   If SearchFile Then
      pos1 = InStr(1, Lcase(content), Lcase(KeyStart), vbTextCompare)
      pos2 = InStr(1, Lcase(content), Lcase(KeyEnd), vbTextCompare)
      title = ""
      If pos1 > 0 And pos2 > 0 Then
         title = Mid( content, pos1 + LenKey, pos2 - pos1 - LenKey )
      End If
   End If
   If Err Then
 Response.Write ("<font color=#000000>")
 Response.Write ("Error #" & CStr(Err.Number) & "" & Err.description )
 Response.Write ( f.name & "在正常运行<br>" & VbCrlf)
 Response.Write ("</font>" & VbCrlf)
   End If
End Function

Function FolderLink( fd )
 Dim vPath
   vPath = UnMapPath( fd.Path )
   FolderLink = "目录:<A HREF=""" &  vPath & """>" & vPath & "</A>"
   FolderLink = "<IMG SRC=" & FolderImg & " Align=absMiddle> "& FolderLink
End Function

Function FileLink( f, title )
   Dim vPath
   vPath = UnMapPath( f.Path )
   If title = "" Then title = f.Name
   FileLink = "<A HREF=""" &  vPath & """>" & title & "</A>"
   FileLink = "<UL><IMG SRC=" & FileImg & " Align=TextTop> " & FileLink & "</UL>"
End Function

Sub SearchFolder( fd, s )
 Dim found
 Dim pos
 Dim ext
 Dim f
 Dim sfd
 Dim Title
   found = False  
   For each f In fd.Files
      pos = InStrRev(f.Path, "." )
      If pos > 0 Then
         ext = Mid(f.Path, pos + 1 )
      Else
         ext = ""
      End If
      If LCase(ext) = LCase(FileType) Then
         If SearchFile( f, s, title ) Then
            If found = False Then
               found = True
               Response.Write FolderLink(fd) & "<P>"
            End If
            Response.Write FileLink(f, title)
         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; charset=gb_2312-80">
<title><%=Head%></title>
</head>

<BASE target=_blank><LINK href="style.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript src="js.js"></SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top background="" height=130><A 
      href="http://www.momoman.com/"><IMG height=130 alt=[玩转满洲里-玩转你的快乐] hspace=0 
      src="title.gif" width=380 border=0 
      dypop="[玩转满洲里::.玩转你的快乐!]"></A></TD></TR>
  <TR>
    <TD background="" bgColor=#666666 height=1></TD></TR>
  <TR>
    <TD background="" bgColor=#e1e1e1 
height=8></TD></TR></TBODY></TABLE></P>

<form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" target=_self method="Get">
    <p align="center">请输入关键词: <input type="text"
    size="20" name="SearchString" value="<%=SearchString%>"> <input
    type="submit" value="搜索"></p>
</form>
<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fd = fs.GetFolder( Server.MapPath(Catalog))

If SearchString <> "" Then
   Response.Write "您搜索的是:" & SearchString & "<P>"
   SearchFolder fd, SearchString
End If
%><A href="search.asp" target=_self alt="BACK SEARCH.ASP">返回继续搜索</A>
<hr><TABLE height=60 cellSpacing=0 cellPadding=0 width=740 background="" border=0>
  <TBODY>
  <TR>
    <TD>
      <P align=center><FONT color=#666666>Copyright &copy; 2005 - 2006 Momoman.Com 
      NetWork All Rights Reserved.</FONT></P></TD></TR>
  <TR>
    <TD>
      <DIV align=center><FONT color=#666666>
      <P align=center><A href="http://www.momoman.com/info/copyright.htm"><IMG 
      height=15 alt="" hspace=0 src="copy.gif" width=100 
      align=absMiddle border=0 
      dypop="版权所有&nbsp;&copy;&nbsp;玩转满洲里"></A>&nbsp;版权所有</FONT></P></DIV></TD></TR></TBODY></TABLE>
</body>
</html>








⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -