Ai galera salve salve amigos que nos ajudam todos os dias, venho mais uma vez pedir sua ajuda, tenho esse script aqui que faz uma busca em todo o diretorio do site minha bronca é que ele mostra também todos os html de pastas que não podem ser visualizados na internet algum pode me ajudar a fazer esse script mostra apenas resultados na pasta que ele está e não as subpastas.
Agradeço
código
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
' Set up some FileSystem objects.
dim objFS, objFolder, objFiles, File, FileName, objCheckFile, strSitePath
set objFS = server.CreateObject("Scripting.FileSystemObject")
dim strListofFiles, arrFileList, strPageTitle, iReturnCount
dim objFolders
strListofFiles = ""
iReturnCount = 0
' The search values, search space, and the return value
dim strKeyWord, strFileContents, returnValue, arrKeyWords
dim bKeyWordFound, i, j
' Get the Physical path to the current directory
strSitePath = Server.MapPath(".")
' Grab the keyworlds and split them into an array
strKeyWord = Trim(request("txtKeyWord"))
arrKeyWords = split(strKeyWord," ")
' Get the list of files.
Set objFolder = objFS.GetFolder(strSitePath)
' Sub that grabs all the ".html" & ".html" files in the given folder and
' recurses through all subfolders.
sub getCompleteFileList(inFolder, Path)
dim oFiles, oFolders, Folder, sPath
' Get all the files and subfolders.
Set oFiles = inFolder.Files
Set oFolders = inFolder.SubFolders
' If we have a subfolder we need the partial path
if (Path <> "") then
sPath = Path + "\"
end if
' Add each ".html" & ".html" file to the list
For Each File in oFiles
FileName = File.Name
if((Lcase(right(FileName,4)) = ".html") OR (Lcase(right(FileName,5)) = ".html")) then
if (strListofFiles = "") then
strListofFiles = sPath + FileName
else
strListofFiles = strListofFiles + "," + sPath + FileName
end if
end if
Next
' Check all the subfolders for ".html" & ".html" files
For Each Folder in oFolders
if (Folder.Name <> "images" AND Folder.Name <> "stats") then
call getCompleteFileList(Folder, sPath + Folder.Name)
end if
Next
' Clean up
set File = Nothing
set oFiles = Nothing
set Folder = Nothing
set oFolders = Nothing
end sub
%>
<html>
<head>
<title>::: resultado :::</title>
</head>
<STYLE type=text/css>BODY {
BACKGROUND-REPEAT: repeat-y
}
TD {
FONT-FAMILY: verdana,arial,helvetica,sans-serif; FONT-SIZE: 10px
}
P {
FONT-FAMILY: verdana,arial,helvetica,sans-serif; FONT-SIZE: 11px
}
LI {
FONT-FAMILY: verdana,arial,helvetica,sans-serif; FONT-SIZE: 11px
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:active {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: #9AACB3; TEXT-DECORATION: none
}
INPUT {
BACKGROUND-COLOR: #e3f4fd; BORDER-BOTTOM-COLOR: #106394; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT-COLOR: #106394; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #106394; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #106394; BORDER-TOP-WIDTH: 1px; COLOR: #000066; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 11px
}
TEXTAREA {
BACKGROUND-COLOR: #e3f4fd; BORDER-BOTTOM-COLOR: #106394; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT-COLOR: #106394; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #106394; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #106394; BORDER-TOP-WIDTH: 1px; COLOR: #000066; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 11px
}
SELECT {
BACKGROUND-COLOR: #e3f4fd; BORDER-BOTTOM-COLOR: #106394; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT-COLOR: #106394; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #106394; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #106394; BORDER-TOP-WIDTH: 1px; COLOR: #000066; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 11px
}
INPUT.botao {
BACKGROUND-COLOR: #cc0000; BORDER-BOTTOM-COLOR: #cc0000; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT-COLOR: #000066; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #000066; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #000066; BORDER-TOP-WIDTH: 1px; COLOR: #E5ECF6; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 11px
}
INPUT.checkbox {
BACKGROUND-COLOR: #E5ECF6; COLOR: #000066; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 9px
}
INPUT.radio {
BACKGROUND-COLOR: #E5ECF6; COLOR: #000066; FONT-FAMILY: Verdana, Tahoma, Arial, Helvetica, Sans-Serif; FONT-SIZE: 9px
}
</STYLE>
<script type="text/javascript" src="milonic_src.js"></script> <script type="text/javascript">if(ns4)_d.write("<scr"+"ipt type=text/javascript src=mmenuns4.js><\/scr"+"ipt>"); else _d.write("<scr"+"ipt type=text/javascript src=mmenudom.js><\/scr"+"ipt>"); </script>
<body topmargin="0" leftmargin="0">
<center>
<!-- inicio top // -->
<table cellpadding="0" cellspacing="0">
<tr>
<td><iframe name="center" src="top.html" marginwidth="0" marginheight="0" scrolling="NO" frameborder="0" framespacing="0" border="0" height="160" width="778"></iframe></td>
</tr>
</table>
<!-- fim top // -->
<!-- incio tableas alinhamento centro -->
<table cellpadding="0" cellspacing="0" width="778">
<tr>
<!-- abaixo inicio td back-1 -->
<td width="29" valign="top" background="img/back-1.gif" width="29" height="100%"><br>
</td>
<!-- acima fim td back-1 -->
<td valign="top" width="195" bgcolor="#E8E7E8">
<!-- inicio lado direito //-->
<script type="text/javascript" src="fitness.js"></SCRIPT>
<br>
<table cellpadding="0" cellspacing="0">
<tr>
<td background="img/busca.gif" width="195" height="98">
<iframe name="center" src="teste.asp" marginwidth="0" marginheight="0" scrolling="NO" frameborder="0" framespacing="0" border="0" height="52" width="195"></iframe>
</td>
</tr>
</table>
<!-- fim lado direito //-->
</td>
<td valign="top" width="527" bgcolor="#E8E7E8"">
<!-- inicio lado center //-->
<br>
<table>
<tr>
<td> </td>
<td><table cellpadding="0" cellspacing="0">
<tr>
<td><strong>::: R E S U L T A D O D A B U S C A ::: </strong> </td>
</tr>
<tr>
<td><HR size="1" color="SILVER" width="500"></td>
</tr>
</table></td>
</tr>
</table>
<table width="95%" border="0" cellspacing="1" cellpadding="1" align="center">
<tr bgcolor="#330099">
<td bgcolor="#FFFFFF">
<div align="left"><font color="#FFFFFF"><b> <font color="#666666">Sua pesquisa por:</font><font color="#000000"> </font></b><font color="#000000"><font color="#FF0000"><%= strKeyWord%></font></font></font></div>
</td>
</tr>
<tr><td> </td></tr>
<%
' Only to the search if we got at least one keyword
if (strKeyWord <> "") then
' Call the sub that gets all the files
call getCompleteFileList(objFolder, "")
' Take the big ole string the contains all the files seperated by commas and chop it up.
arrFileList = split(strListofFiles,",")
For i=0 to UBound(arrFileList)
' Open the current file and read everything into a single string.
' If the files are huge this could eat a lot or resources.
Set objCheckFile = objFS.OpenTextFile(strSitePath + "\" + arrFileList(i),1,false,0)
strFileContents = objCheckFile.ReadAll
' Default the search flag to false.
bKeyWordFound = false
' For each keyword entered search the file.
for j = 0 to UBound(arrKeyWords)
returnValue = InStr(1,strFileContents,arrKeyWords(j),1)
' If the returnValue isn't zero the keyword was found
' Set the search flage to true and short cut out of the loop.
if (returnValue <> 0) then
bKeyWordFound = true
j = UBound(arrKeyWords)
end if
next
' If a keyword was found include this file in the list.
if (bKeyWordFound) then
' Keep track of the number of results and grab the title of the page for the search display
iReturnCount = iReturnCount + 1
dim startChar, endChar
startChar = InStr(1,strFileContents,"<title>",1)
endChar = InStr(1,strFileContents,"</title>",1)
if (startChar = 0 OR endChar = 0 OR ((startChar + 7) > (endChar - 7))) then
%>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><a href="<%= arrFileList(i) %>"><%= arrFileList(i) %></a> <%= arrFileList(i) %></font></td>
</tr>
<%
else
strPageTitle = mid(strFileContents,InStr(1,strFileContents,"<title>",1) + 7, InStr(1,strFileContents,"</title>",1) - InStr(1,strFileContents,"<title>",1) - 7)
if (strPageTitle = "") then
strPageTitle = arrFileList(i)
end if
%>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><a href="<%= arrFileList(i) %>"><%= strPageTitle%></a> - <%= arrFileList(i) %></font></td>
</tr>
<%
end if
end if
' Close the file so we can open another one.
objCheckFile.Close
Next
end if
%>
<tr>
<tr><td> </td></tr>
<td><font face="Arial, Helvetica, sans-serif" size="2" color="#999999"><%= iReturnCount%> Páginas encontradas</font></td>
</tr>
<tr>
<td> </td>
</tr>
<%
' Clean up all the objects used.
set objCheckFile = Nothing
set File = Nothing
set objFiles = Nothing
set objFolder = Nothing
set objFS = Nothing
%>
</table>
<!-- fim lado center //-->
</td>
<!-- abaixo inicio td back-2 -->
<td width="27" valign="top" background="img/back-2.gif" width="27" height="100%"><br>
</td>
<!-- acima fim td back-2 -->
</tr>
</table>
<!-- fim tableas alinhamento centro -->
</body>
</html>
Pergunta
Guest Almirante
Ai galera salve salve amigos que nos ajudam todos os dias, venho mais uma vez pedir sua ajuda, tenho esse script aqui que faz uma busca em todo o diretorio do site minha bronca é que ele mostra também todos os html de pastas que não podem ser visualizados na internet algum pode me ajudar a fazer esse script mostra apenas resultados na pasta que ele está e não as subpastas.
Agradeço
código
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.