Site search

7 отговора 276 прегледа
#1

Site search

Ako mojete pomognete!!

tarsia script za tarsene v webSite.
Nai dobre da e JavaScript no ako se sestate za drugo Ok.

mersi

Отговор
в отговор на anex #2

Re: Site search

правих такъв на ПХП, ама ти трябва и база данни /*моя бачка с МуСКЛ и мога да ти го дам*/ А пък на жаваскрипт ми е трудно да си представя как ще стане. Може би е по-добре да питаш в "Web i HTML" - и там се намират програмисти

дао дъ дзин

Отговор
в отговор на voyager #3

Re: Site search

ami da po dobre nesto otkolkoto biz hi4:)
ako mojesh mi izprati tvoeto reshenie na emaila mi andy_ne@web.de
mersi.

Отговор
в отговор на anex #4

Re: Site search

Въпроса е твърде мъгляв... В кое на сайта искаш да се търси? В база данни ли, в HTML страници ли, във файлове на сървъра? И без конкретен пример и отговорите ще са силно мъгляви...

чети и дишай по-леко
Отговор
в отговор на anex #5

Re: Site search

Два файла.

1.search.asp

<HTML>
<HEAD>
<meta HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=Windows-1251">
</HEAD>
<BODY>
<%@ Language=VBScript %>
<%
Function FormatURL(strPath)
'ERROR !!!!!! Path is not formatted properly !
'Cut off everything before wwwroot and replace all \ with /
Dim iPos
iPos = InStr(1,strPath,"QM",1)
Dim str
a=Len(strPath)-iPos+1
str = right(strPath,a)
FormatURL = Replace(str,"\","/")
' FormatURL = Replace(strPath,"\","/")
End Function


Function GetFiles(objFolder, aLookFor, strLF, bolLFFound,bolAnd, iCount)
If Left(objFolder.Name,1) = "_" then exit function

Const iListPerPage = 9

if iCount > iListPerPage then Exit Function

'Now, loop through each file
Dim objFile, objTextStream, objFSO, strContents, iUBound, iLoop, bolValid
Dim strTitle, iPos, strDesc
iUBound = UBound(aLookFor)

For Each objFile in objFolder.Files
'Do we need to search this file?
If UCase(Right(objFile.Name,4)) = ".HTM" or UCase(Right(objFile.Name,5)) = ".HTML" or UCase(Right(objFile.Name,4)) = ".ASP" then
If bolLFFound then
if objFile.Size > 0 then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(objFile.Path,1)
strContents = objTextStream.ReadAll
objTextStream.Close
Set objFSO = Nothing

if bolAnd then bolValid = True else bolValid = False
For iLoop = 0 to iUBound
If InStr(1,strContents,aLookFor(iLoop),1) then
if Not bolAnd then bolValid = True
Else
If bolAnd then bolValid = False
End If
Next

If bolValid then
iPos = InStr(1,strContents,"<!--TITLE:")
If iPos = 0 then
strTitle = "Untitled (" & objFile.Name & ")"
strDesc = ""
Else
strTitle = Mid(strContents,iPos+10,InStr(iPos,strContents,"-->")-iPos-10)

iPos = InStr(iPos,strContents,"<!--DESC:")
If iPos = 0 then
strDesc = ""
Else
strDesc = Mid(strContents,iPos+9,InStr(iPos,strContents,"-->")-iPos-9)
End If
End If

Response.Write "<A HREF=""" & FormatURL(objFile.Path) & """>" & _
strTitle & "</A><BR>" & vbCrLf
Response.Write "<FONT SIZE=2>" & strDesc
Response.Write "</FONT><P>" & vbCrLf
iCount = iCount + 1
End if
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
End If
Elseif FormatURL(objFile.Path) = strLF then
bolLFFound = True
End If
End if
Next

Dim objSubFolder
For Each objSubFolder in objFolder.SubFolders
GetFiles objSubFolder,aLookFor,strLF,bolLFFound,bolAnd,iCount
Next
End Function

'Search the site!
Dim strKeywords
strKeywords = Request("terms")

'Split the terms on spaces
Dim termsArray
termsArray = split(strKeywords," ")

'Set the boolean search option
Dim bolAnd
If Request("boolean") = "AND" then bolAnd = True else bolAnd = False

Dim section
section = Request("selSearchWhere")

'Get the dirs to search
section = Server.MapPath("./QM")

'What page are we on?
Dim strLastFile
strLastFile=Request("lf")

Dim objFSO, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(section)
Set objFSO = Nothing
%>
<CENTER><FONT SIZE=+2><B>
Резултати от търсенето:
</B></FONT><BR>
<FONT SIZE=2><A HREF="/search/">Корекции в заявката за търсене.</A></FONT>
</CENTER>
<P><HR><P>
Това са резултатите от търсенето:
<P>
<%
Dim iResults
iResults = 0

'Now, recurse the directories
If Len(strLastFile) = 0 then
GetFiles objFolder,termsArray,strLastFile,True,bolAnd,iResults
Else
GetFiles objFolder,termsArray,strLastFile,False,bolAnd,iResults
End If

Set objFolder = Nothing

If iResults = 10 then
'Show next page link
%>
<P><HR><P><LI><FONT SIZE=2><B>
<A HREF="search.asp?terms=<%=Server.URLEncode(strKeywords)%>&boolean=<%=Request("boolean")%>&selSearchWhere=<%=Request("selSearchWhere")%>&lf=<%=Server.URLEncode(strLastFile)%>">
Още резултати:
</A></FONT>
<P>
<% Elseif iResults = 0 then
'No results found %>
<B>Няма документи,съдържащи ключова дума !</B><BR>
<FONT SIZE=2><A HREF="/search/">Ново търсене.</A></FONT>
<% End IF %>
</BODY></HTML>

2.search.html

<HTML>
<HEAD>
<meta HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=Windows-1251">
</HEAD>
<BODY>
<FORM NAME="frmSearch" METHOD="get" ACTION="search.asp">
<TABLE BORDER="0" align=center>
<TR>
<TD>
Ключови думи:
</TD>
<TD>
<FONT COLOR="black">
<INPUT NAME="terms" TITLE="Enter the
keywords to search on here!" >
</FONT>
</TD>
</TR>
<TR>
<TD>
Условия:
</TD>
<TD>
<FONT COLOR="black">
<SELECT NAME="boolean" SIZE="1">
<OPTION VALUE="AND" selected
>And</OPTION>
<OPTION VALUE="OR">Or</OPTION>
</SELECT>
</FONT>
</TD>
</TR>
</TABLE>
<P>
<CENTER>
<FONT COLOR="black">
<INPUT TYPE="submit" VALUE="Търсене">
</FONT>
</CENTER>
</FORM>
</BODY></HTML>

Това е АСП. ХТМЛ-файлът ползва АСП-файла за търсенето. Работи - просто копи&пейст :-)))

UB40 !
Отговор
в отговор на anex #6

Re: Site search

Dokolkoto znam Jscript ne stawa za ServerSide?
ili barkam?
ti wsashnost kaf sarch iskash da prash?

------------------------------
I got a COMPILER, and I'm not afraid to use it!
Отговор
в отговор на SDR #7

Не думай !

Трябва това да го кажа на всички дето не харесват VBScript и си пишат ASP-тата на JScript ! Щото днеска работел, ама утре - знае ли човек ?
Трябва да си вярваме все пак :-)))

UB40 !
Отговор
в отговор на jamie #8

Hod`i se snimaj

Towa bi trqbwalo da go kazwam na sichki deto si interpritirat server side-a sha znash!

------------------------------
I got a COMPILER, and I'm not afraid to use it!
Отговор