<% @ Language=VBScript %> <% Option Explicit Response.Buffer = True %> Photos Viewer <% '################################################################################# '# '# USAGE: '# '# FREE OF CHARGE! '# '# OK, I wrote this from scratch, but I'd be proud if anyone thought it useful '# enough to use. It is designed so that the relatively untutored can maintain '# their on-line photo album with nothing more than a basic image editing package, '# e.g. PaintShop Pro (www.jasc.com) or Microsoft Photo Editor (Part of Office), '# and an FTP client such as CuteFTP or FTPExplorer. You should be able to avoid '# ever having to edit the code. '# All I ask is that: 1. the following lines remain: %> <% '# I would also appreciate a brief email, if you take it live, letting me know '# the URL. '################################################################################# ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' ' INSTALLATION: ' ' 1. Create a folder anywhere on the site (eg www.site.com/photos/) ' 2. Insert the necessary HTML headers and footers ' 3. Put this file in the folder created in step 1. ' 4. For each set of pictures to publish create a subfolder ' (e.g. www.site.com/photos/sept/ and www.site.com/photos/oct/) ' 5. If captions are used, rename the image files so that the filename is ' the caption (problem: only certain punctuation marks can be used, ' apostrophes will break it every time ' 6. Load the image files into their respective photos/folders ' 7. Open photos.asp in a browser ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Declaration of variables and constants '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dim i ' Counter Dim tot ' Number of piccies Dim pic ' Current picture Dim dir ' Current folder Dim MyDirectory ' Path to folder containing photos.asp Dim MyFolders ' List of subfolders (albums) Dim MyFiles ' List of files in an album Dim folderFound ' individual subfolder Dim fileFound ' individual photo ' Turn off captions globally by changing the value of captions to "no" ' Turn off captions individually by naming the file with an initial undescore (_) Const captions = "yes" ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Store QueryStrings as variables (out of habit) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'Get querystring for pic number as sub-type integer pic = Cint(Request.QueryString("pic")) 'Get name of folder containing current album dir = Request.QueryString("dir") ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Create FileSystemObjects '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set MyDirectory=Server.CreateObject("Scripting.FileSystemObject") ' MyFolders is contents of folder containing photos.asp Set MyFolders=MyDirectory.GetFolder(Server.MapPath("./")) ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' If there is no current album set it to the first one found '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For Each folderFound In MyFolders.subfolders If dir = "" Then dir = folderFound.Name End If Next ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Get contents of current album '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set MyFiles=MyDirectory.GetFolder(Server.MapPath(dir)) ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Count the photos '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tot = -1 For Each filefound in MyFiles.files tot = tot + 1 Next ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Decide if target photo is outside the range and reset variable pic accordingly '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If pic > tot Then pic = 0 ElseIf pic < 0 Then pic = tot End If ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' If there is no current photo set current photo to the first one found '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If Request.QueryString("pic") = "" Then pic = 0 End If '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Output some basic page layout - change this to suit the desired appearance '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf & "" & vbCrLf & "
" & vbCrLf) ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Flick through current album until we get to the target photo (pic) ' Output the image path and filename with Server.URLPathEncode so that people who ' insist on clinging to that pathetic software they call Netscape, can see it. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ i = 0 For Each filefound In MyFiles.files If pic = i Then ' Write out the image tag Response.Write ("" & filefound.Name & "
" & vbCrLf) ' Use File title as caption Response.Write("

 ") ' Decide if captions are required (globally or individually) If captions = "yes" And Left(filefound.Name,1) <> "_" Then ' Write out filename as caption, but lop off the letters after the period Response.Write(Left(filefound.Name,(Len(filefound.name)-3))) End If Response.Write(" 

" & vbCrLf) End If i = i + 1 Next ' Now i is the total number of objects in the folder ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' More layout '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response.Write("
") ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Write out previous and next photo links as text links but images could easily be used ' Be careful with form buttons...! (Netscape again) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response.Write("<= prev  next =>
" & vbCrLf & vbCrLf) Response.Write("
") ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Write out menu of available albums as links to the photos in that folder '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response.Write(" Choose Album: ") For Each folderFound In MyFolders.SubFolders ' Ignore any FrontPage Server Extension folders If Left(folderFound.Name,1) <> "_" Then Response.Write("" & folderFound.Name &"   ") End If Next ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Finish the layout '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Response.Write(vbCrLf & "
") ' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Get rid of the objects '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set MyDirectory = Nothing Set MyFiles = Nothing Set MyFolders = Nothing %>  

<<  Back to Main Page  >>