#!/usr/bin/perl # # SimpleViewer.pl # dan@simplebits.com # September 2002 revised April 2003 and November 2003 # # Viewer for photos and slideshows # # - Rename this file SimpleViewer.pl # - Call a single image by http://www.yoursite.com/cgi-bin/SimpleViewer.pl?img=imagename.jpg # - Call a slideshow by http://www.yoursite.com/cgi-bin/SimpleViewer.pl?slideshow=dir_name # - imagename.jpg needs to be in the "photos" directory. # - Where "dir_name" is a directory of photos within the "slideshows" directory. # - Each image should be named numerically: 1.jpg, 2.jpg, 3.jpg, etc. Also works with .gifs as well. # # Header and footer can be modified below with your own markup and styles. # use strict; use CGI; use LWP::Simple; my $q = new CGI(); my $img = $q->param("img"); my $slideshow = $q->param("slideshow"); # header print "Content-type: text/html\n\n"; print < SimpleViewer HEADER # for slideshows if ($slideshow) { print "

Slide Shows › $slideshow

"; if ($img eq "") { $img = "1.jpg"; } # change the path below for your server opendir(DIR,"/path/to/your/public_html/slideshows/$slideshow/") || die $!; my @file_list = readdir(DIR); closedir(DIR); my @sorted = sort {$main::a <=> $main::b} @file_list; foreach my $slide (@sorted) { if ($slide =~ /(\.jpg$|\.gif$)/) { my $suffix = $1; $slide =~ s/$suffix//g; if ($img eq $slide . $suffix) { print "$slide "; } else { print "$slide "; } } } print "

\"$img\""; } # for single image viewing else { print "

Photos › Full Size

"; print "\"$img\""; } #footer print <SimpleViewer by SimpleBits

FOOTER exit;