1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
<%@ LANGUAGE="VBSCRIPT"%>
<%
function notag(txt)
set regEx = New RegExp
regEx.Global = True
regEx.Pattern = "<[^>]+>"
notag = regEx.replace(txt,"")
end function
%>
<%
DIM rep, dir
DIM keywords, expr, all
DIM go, resCounter
DIM carac
DIM contenu, content, termsCounter, text
%>
<%
SET fso = Server.CreateObject("Scripting.FileSystemObject")
rep = "French/"
dir = Server.MapPath(rep) & "\"
SET folder = fso.GetFolder(dir)
SET files = folder.Files
%>
<%
keywords = Request.form("terms")
IF Asc(keywords) = 0034 THEN expr = True ELSE expr = False END IF
IF Asc(keywords) = 0043 THEN all = True ELSE all = False END IF
keywords = trim(keywords)
keywords = lcase(keywords)
%>
<font size="3"><b>Rappel de votre requête : </b></font> <%response.write keywords%> <br>
<blockquote><a href="Formulaire.asp">Effectuez une nouvelle recherche</a></blockquote>
<hr size="1">
<font size="3"><b>Résultat :</b></font><br><br>
<%
go = False
resCounter = 0
%>
<%
IF keywords<>"" THEN
IF expr=True THEN
carac = Len(keywords)
keywords = Mid(keywords,2,(carac-2))
DIM termsArray(0)
termsArray(0) = keywords
ELSE
termsArray = split(keywords," ",-1,1)
IF all=True THEN
FOR i = 0 TO Ubound(termsArray)
termsArray(i) = Mid(termsArray(i),2)
NEXT
END IF
END IF
go = True
END IF
%>
<%
IF go=True THEN
FOR EACH file IN files
SET inF = fso.OpenTextFile(dir & file.name,1,false)
contenu = inF.readAll
inF.close
contenu = notag(contenu)
content = lcase(contenu)
termsCounter = 0
IF file.name<>"Default.asp" THEN
FOR i = 0 TO Ubound(termsArray)
IF InStr(content,termsArray(i)) > 0 THEN termsCounter = termsCounter + 1
NEXT
IF (termsCounter>0 AND all=False) OR (termsCounter=(Ubound(termsArray)+1) AND all=True) THEN
resCounter = resCounter + 1
text = "<div align=justify><b>" & resCounter & ". </b><A href=""" & rep & file.name & """ target=""_blank"">" & file.name & "</A><br>" & left(contenu,1000) & "...</div><b>Pertinence : </b>" & termsCounter & " sur " & Ubound(termsArray)+1 & "<br><br>"
response.write(text)
END IF
END IF
NEXT
END IF
%>
<%
IF resCounter=0 THEN response.write "<blockquote>Aucun document correspond à votre recherche.</blockquote>"
SET inF = NOTHING
SET files = NOTHING
SET folder = NOTHING
SET fso = NOTHING
%> |
Partager