Billedgallery: Filer og biblioteker i koloner.
Dette billedgallery lister alle filer og biblioteker i én kolone.Kan man ikke få den til at liste dem i kolonner med 15 i hver???
Denne streng skal ligge i en default.asp i roden af de biblioteker der skal vises.
<!-- #include file="gallery.asp" -->
<%=STVGallery(Request.Querystring("p"))%>
-------------------------------------------------------
<%
Function STVGallery(path)
Dim ValidExt(4)
ValidExt(0) = "jpg"
ValidExt(1) = "gif"
ValidExt(2) = "png"
ValidExt(3) = "bmp"
imgpath = "/pics/"
On Error Resume Next
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
root = Server.Mappath(".")
url = Request.ServerVariables("URL")
webpath = left(url, instrrev(url, "/"))
If path = "" or right(path, 1) = "/" or right(path, 1) = "\" then
If instr(path, "/") > 0 then
path = replace(path, "/", "\")
End if
If left(path, 1) <> "\" then
path = "\" & path
End if
If right(path, 1) <> "\" then
path = path & "\"
End if
If instr(path, "..") < 1 then
uppath = left(replace(path, "\", "/"), instrrev(left(replace(path, "\", "/"), len(path)-1), "/"))
If uppath = "" then
uppath = "/"
End if
result = vbcrlf & "<!-- Begin STVGallery file list -->" & vbcrlf
result = result & "<table border=""0"" cellspacing=""3"" cellpadding=""0"">" & vbcrlf
result = result & " <tr>" & vbcrlf
result = result & " <td width=""18"" align=""center""><a href=""" & webpath & "?p=" & uppath & """><img src=""" & imgpath & "folder_up.gif"" border=""0"" alt=""Tilbage""></a></td>" & vbcrlf
result = result & " <td nowrap><a href=""" & webpath & "?p=" & uppath & """>Tilbage</a></td>" & vbcrlf
result = result & " </tr>" & vbcrlf
result = result & " <tr>" & vbcrlf
result = result & " <td colspan=""2"" style=""height: 10px""></td>" & vbcrlf
result = result & " </tr>" & vbcrlf
If FSO.FolderExists(root & path) then
Set dir = FSO.GetFolder(root & path)
Set subdirs = dir.SubFolders
For each subdir in subdirs
If err.Number = 0 then
result = result & " <tr>" & vbcrlf
result = result & " <td align=""center""><a href=""" & webpath & "?p=" & replace(path, "\", "/") & subdir.name & "/""><img src=""" & imgpath & "folder.gif"" border=""0"" alt=""Folder""></a></td>" & vbcrlf & " <td nowrap><a href=""" & webpath & "?p=" & replace(path, "\", "/") & subdir.name & "/"">" & subdir.name & "</a></td>" & vbcrlf
result = result & " </tr>" & vbcrlf
Else
result = result & " <tr>" & vbcrlf
result = result & " <td></td><td>" & err.Description & "</td>" & vbcrlf
result = result & " </tr>" & vbcrlf
err.Clear
End if
Next
Set subdirs = Nothing
Set dirfiles = dir.Files
For each dirfile in dirfiles
For ext = 0 to ubound(ValidExt)-1
If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then
result = result & " <tr>" & vbcrlf
result = result & " <td align=""center""><a href=""" & webpath & "?p=" & replace(path, "\", "/") & dirfile.name & """><img src=""" & imgpath & "file.gif"" border=""0"" alt=""File""></a></td>" & vbcrlf & " <td nowrap><a href=""" & webpath & "?p=" & replace(path, "\", "/") & dirfile.name & """>" & dirfile.name & "</a></td>" & vbcrlf
result = result & " </tr>" & vbcrlf
End if
Next
Next
Set dirfiles = Nothing
Set dir = Nothing
Else
result = result & " <tr>" & vbcrlf
result = result & " <td></td>" & vbcrlf
result = result & " <td nowrap>Path not found</td>" & vbcrlf
result = result & " </tr>" & vbcrlf
End if
result = result & "</table>" & vbcrlf
result = result & "<!-- End STVGallery file list -->" & vbcrlf
Else
Response.Redirect(webpath)
End if
Else
If instr(path, "/") > 0 then
path = replace(path, "/", "\")
End if
If left(path, 1) <> "\" then
path = "\" & path
End if
If instr(path, "..") < 1 then
uppath = left(replace(path, "\", "/"), instrrev(left(replace(path, "\", "/"), len(path)-1), "/"))
result = vbcrlf & "<!-- Begin STVGallery item display -->" & vbcrlf
result = result & "<table border=""0"" cellspacing=""3"" cellpadding=""0"">" & vbcrlf
result = result & " <tr>" & vbcrlf
result = result & " <td width=""18"" align=""center""><a href=""" & webpath & "?p=" & uppath & """><img src=""" & imgpath & "folder_up.gif"" border=""0"" alt=""Up""></a></td>" & vbcrlf
result = result & " <td nowrap><a href=""" & webpath & "?p=" & uppath & """>Tilbage</a></td>" & vbcrlf
result = result & " </tr>" & vbcrlf
result = result & "</table>" & vbcrlf
If uppath = "" then
uppath = "/"
End if
If FSO.FileExists(root & path) then
Set imgfile = FSO.GetFile(root & path)
imgname = imgfile.Name
result = result & "<p align=""center""><a href=""" & webpath & "?p=" & replace(path, "\", "/") & """>" & imgname & "</a><br><br><img src=""" & webpath & right(replace(path, "\", "/"), len(path)-1) & """ alt=""" & imgname & """></p>" & vbcrlf
Set imgfile = Nothing
dirpath = left(path, len(path)-len(imgname))
Set dir = FSO.GetFolder(root & dirpath)
Set dirfiles = dir.Files
counter = 0
For each dirfile in dirfiles
For ext = 0 to ubound(ValidExt)-1
If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then
counter = counter + 1
If instr(dirfile, imgname) > 0 then
imgfileloc = counter
End if
End if
Next
Next
counter = 0
For each dirfile in dirfiles
For ext = 0 to ubound(ValidExt)-1
If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then
counter = counter + 1
If counter = imgfileloc-1 then
prevfile = dirfile.name
prevfileloc = counter
End if
If counter = imgfileloc+1 then
nextfile = dirfile.name
nextfileloc = counter
End if
End if
Next
Next
Set dirfiles = Nothing
Set dir = Nothing
result = result & "<table width=""100%"" border=""0"" cellspacing=""3"" cellpadding=""0"">" & vbcrlf
result = result & " <tr>" & vbcrlf
result = result & " <td width=""50%"" nowrap>"
If prevfile <> "" then
result = result & "<a href=""" & webpath & "?p=" & replace(dirpath, "\", "/") & prevfile & """><<< Previous</a>"
End if
result = result & "</td>" & vbcrlf
result = result & " <td width=""50%"" nowrap align=""right"">"
If nextfile <> "" then
result = result & "<a href=""" & webpath & "?p=" & replace(dirpath, "\", "/") & nextfile & """>Next >>></a>"
End if
result = result & "</td>" & vbcrlf
result = result & " </tr>" & vbcrlf
result = result & "</table>" & vbcrlf
result = result & "<!-- End STVGallery item display -->" & vbcrlf
Else
If err.Number = 0 then
result = result & "<br> File not found"
Else
result = result & "<br> " & err.Description
err.Clear
End if
End if
Else
Response.Redirect(webpath)
End if
End if
Set FSO = Nothing
STVGallery = result
End function
%>
