- <%
- ' Checks weither a file exists on the server
- ' receive relative path to the file + file name
- ' ex : existFic("images/myImage.gif")
- ' returns false if file does not exists
- ' true if file exists or is URL
- function existFic(nom)
- dim existFic_tmp
- ' if is URL then say it exists
- if lcase(left(nom,7))="http://" then
- existFic_tmp = true
- else
- if nom="" OR isNull(nom) then
- existFic_tmp = false
- else
- dim oFile, f
- set oFile = server.createObject("Scripting.FileSystemObject")
- If (oFile.FileExists(server.mapPath(nom))) then
- existFic_tmp = true
- else
- existFic_tmp = false
- end i
- end if
- end if
- existFic = existFic_tmp
- end function
-
-
- ' include dynamique
- ' can include any text based page
- ' taking nothing but inside <BODY></BODY> if HTML page
- ' I take the option that you can't have
- ' "<HTML>,<HEAD>,</HEAD>,</HTML>" tags without the <body> tag
- function incFile(filPath)
- dim fichier
- fichier = "page.asp"
- if existFic(fichier) then
- dim fso,fic,fn, contenu, debut, fin
- fic=server.mappath(fichier)
- set fso=server.createObject("scripting.filesystemObject")
- set fn = fso.opentextfile(fic)
- contenu = fn.readAll
- 'takes all after "<BODY>"
- debut = inStr(UCase(contenu),"<BODY>")
- if debut>0 then
- contenu = mid(contenu , debut + 6 , len(contenu) - debut - 1 )
- end if
- 'takes all before "</BODY>"
- fin = inStr(UCase(contenu),"</BODY>")
- if fin>0 then
- contenu = mid(contenu , 1 , fin - 1 )
- end if
- fn.close
- set fso=nothing
- incFile = contenu
- end if
- end function
- %>
<%
' Checks weither a file exists on the server
' receive relative path to the file + file name
' ex : existFic("images/myImage.gif")
' returns false if file does not exists
' true if file exists or is URL
function existFic(nom)
dim existFic_tmp
' if is URL then say it exists
if lcase(left(nom,7))="http://" then
existFic_tmp = true
else
if nom="" OR isNull(nom) then
existFic_tmp = false
else
dim oFile, f
set oFile = server.createObject("Scripting.FileSystemObject")
If (oFile.FileExists(server.mapPath(nom))) then
existFic_tmp = true
else
existFic_tmp = false
end i
end if
end if
existFic = existFic_tmp
end function
' include dynamique
' can include any text based page
' taking nothing but inside <BODY></BODY> if HTML page
' I take the option that you can't have
' "<HTML>,<HEAD>,</HEAD>,</HTML>" tags without the <body> tag
function incFile(filPath)
dim fichier
fichier = "page.asp"
if existFic(fichier) then
dim fso,fic,fn, contenu, debut, fin
fic=server.mappath(fichier)
set fso=server.createObject("scripting.filesystemObject")
set fn = fso.opentextfile(fic)
contenu = fn.readAll
'takes all after "<BODY>"
debut = inStr(UCase(contenu),"<BODY>")
if debut>0 then
contenu = mid(contenu , debut + 6 , len(contenu) - debut - 1 )
end if
'takes all before "</BODY>"
fin = inStr(UCase(contenu),"</BODY>")
if fin>0 then
contenu = mid(contenu , 1 , fin - 1 )
end if
fn.close
set fso=nothing
incFile = contenu
end if
end function
%>