<% option explicit %> <% 'constants const pageId = "pictures" const galleriesPerPage = 10 'variables dim jpeg 'jpeg object to open images dim fileSystem 'the filesystem object dim objXML 'xml object dim galleries 'array of gallery objects in xml dim numGalleries 'number of galleries in the xml dim page 'which page we are on, from querystring dim defaultGallery 'the default gallery number dim gallery 'which gallery to display, from querystring dim galleryTitle 'the title of this gallery dim galleryDate 'when the pictures were taken dim galleryPlace 'where the pictures were taken dim i 'loop counter dim imageDir 'the image directory on the server dim thumbsDir 'the thumbnail directory on the server dim images 'the images in the image directory dim file 'one file from images dim filename 'the filename of an image dim title 'gallery title for sidebar dim path 'gallery path for sidebar dim endline, tab endline = chr(10) tab = chr(9) 'Create instance of AspJpeg Set jpeg = Server.CreateObject("Persits.Jpeg") 'create the filesystem object set fileSystem = Server.CreateObject("Scripting.FileSystemObject") 'load the xml file Set objXML = Server.CreateObject("Microsoft.XMLDOM") 'do not do asynchronous download objXML.async = False 'load the document objXML.Load(Server.MapPath("xml/" & pageId & ".xml")) 'check for loading errors If objXML.parseError.errorCode <> 0 Then 'handle the error, do not continue processing! response.write "ERROR-->" & objXML.parseError.errorCode & "<--" End If 'get all the gallery subtrees Set galleries = objXML.getElementsByTagName("gallery") numGalleries = galleries.length 'read which page we are on page = Request.querystring("page") 'if no parameter is passed if page = "" then 'default to first page page = 0 else page = cint(request.querystring("page")) end if 'calculate defaultGallery defaultGallery = page * galleriesPerPage 'read which gallery this is gallery = Request.querystring("gallery") 'if no parameter is passed if gallery = "" then 'default to first gallery gallery = galleries.item(defaultGallery).childNodes(xmlPath).text end if 'default to first gallery in the list galleryTitle = galleries.item(defaultGallery).childNodes(xmlTitle).text galleryDate = galleries.item(defaultGallery).childNodes(xmlDate).text galleryPlace = galleries.item(defaultGallery).childNodes(xmlLocation).text 'loop through all galleries for i = 0 to (numGalleries - 1) 'if we find a match, use that name instead if gallery = galleries.item(i).childNodes(xmlPath).text then galleryTitle = galleries.item(i).childNodes(xmlTitle).text galleryDate = galleries.item(i).childNodes(xmlDate).text galleryPlace = galleries.item(i).childNodes(xmlLocation).text exit for end if next 'get the folder on the server set imageDir = fileSystem.GetFolder(Server.MapPath("pictures/" & gallery)) set thumbsDir = fileSystem.GetFolder(Server.MapPath("pictures/" & gallery & "/thumbs")) 'get the files in the folder set images = imageDir.Files %> daveberlin.com
daveberlin.com:<%=pageId%>
<%=galleryPlace%>
<%=galleryDate%>

<%=galleryTitle%>

<% for each file in images filename = file.name 'get width and height so we can load empty boxes 'response.write imageDir & "\thumbs\" & filename jpeg.open imageDir & "\thumbs\" & filename 'response.write jpeg.width & " x " 'response.write jpeg.height response.write ( "" & endline & tab & tab ) next %>

style