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
|
<%
server.scriptTimeout = 5*60
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
' Nettoyage du dossier
set fc = FSO.GetFolder(server.mapPath(".")).files
for each f in fc
if f.name <> "default.asp" and f.name <> "generateur.asp" and f.name <> "modele.asp" then
set fd = FSO.getFile(server.mapPath(".")&"\"&f.name)
fd.Delete
end if
next
if request.queryString("act")="clean" then response.redirect "default.asp"
' Lecture du modèle
set inF = FSO.OpenTextFile(server.mapPath("modele.asp"),1,false)
dy_modele = inF.readAll
inF.close
' CONNEXION
Set dy_Conn = Server.CreateObject("ADODB.Connection")
dy_Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../45260.mdb")
Set dy_RS = server.createobject("ADODB.Recordset")
dy_SQL= "SELECT * FROM Livre WHERE Web1=-1"
dy_RS.Open dy_SQL,dy_Conn , 3, 3
Function clean(txt)
dim regEx
Set regEx = New RegExp
regEx.Global = True
regEx.Pattern = "[àâ]"
txt = regEx.REPLACE(txt,"a")
regEx.Pattern = "[éèêë]"
txt = regEx.REPLACE(txt,"e")
regEx.Pattern = "[îï]"
txt = regEx.REPLACE(txt,"i")
regEx.Pattern = "[ôö]"
txt = regEx.REPLACE(txt,"o")
regEx.Pattern = "[ùûü]"
txt = regEx.REPLACE(txt,"u")
txt = replace(txt,"ç","c")
regEx.Pattern = "[^a-zA-Z0-9 _-]+"
txt = regEx.replace(txt,"")
clean = replace(txt," ","_")
end function
dy_fld = Array("SusTitre","Auteur","Titre","Adresse","Collation","Reliure","IDLiv","Prix","Commentaire","RefBiblio","Commentaire_en","RefBiblio_en","Commentaire_es","RefBiblio_es","Commentaire_ca","RefBiblio_ca")
while not dy_RS.eof
dy_page = dy_modele
for i = 0 to 15
if isnull(dy_RS(dy_fld(i))) then
dy_page = replace(dy_page,"[\"&dy_fld(i)&"/]","")
elseif dy_fld(i)="Prix" then
if cInt(dy_RS(dy_fld(i)))>0 then
dy_page = replace(dy_page,"[\"&dy_fld(i)&"/]",dy_RS(dy_fld(i)))
else
dy_page = replace(dy_page,"[\"&dy_fld(i)&"/]","Prix sur demande")
end if
else
dy_page = replace(dy_page,"[\"&dy_fld(i)&"/]",dy_RS(dy_fld(i)))
end if
next
' nom de fichier
dy_nf = ""
if not isnull(dy_RS("Auteur")) then dy_nf = dy_RS("Auteur")
if not isnull(dy_RS("Titre")) then
if dy_nf <>"" then dy_nf = dy_nf & " - "
dy_nf = dy_nf & dy_RS("Titre")
end if
dy_nf = clean(left(dy_nf,100))
dy_page = replace(dy_page,"[\Title/]",replace(left(dy_nf,50),"_"," "))
dy_nf = dy_nf & "-" & dy_RS("IDLiv") & ".asp"
dy_nf = replace(dy_nf,"_-","-")
if left(dy_nf,1)="_" then dy_nf=mid(dy_nf,2)
' Ecriture
set inF = FSO.OpenTextFile(server.mapPath(dy_nf),2,true)
inF.write dy_page
inF.close
dy_RS.moveNext
wend
dy_RS.close
' Déconnexion
dy_Conn.close : set dy_Conn=nothing
response.redirect "default.asp"
%> |
Partager