#!/usr/bin/perl -w ## Modules and setup use CGI; use HTML::Template; ## check perldoc HTML::Template for more informati +on use strict; $CGI::POST_MAX=1024 * 1; # max 1k post $CGI::DISABLE_UPLOADS = 1; # No uploads ## Setup vars my $ThisScript = 'pictureview.cgi'; my ($q) = new CGI; my $DisplayPicture; my $DirPath; ## Check for picture peram if ($q->param('Picture')) { $DisplayPicture = ($q->param('Picture'))*1; } else { $DisplayPicture = 1; } ## Count number of files. my @LFiles = (); opendir (DIR, "./"); @LFiles = grep {not /^(\.\.?|template\.html|pictureview\.cgi)$/} readdir(DIR); closedir (DIR); my $TotalFiles = $#LFiles + 1; ## Correct to first file = 1 my $PreviousPicture; my $NextPicture; ## ## Make sure numbers are good (Bounds checking) ## if ($DisplayPicture == 0) { $DisplayPicture = 1;} if ($DisplayPicture > $TotalFiles) { $DisplayPicture = 1;} if ($DisplayPicture == 1) { $PreviousPicture = $TotalFiles; } else { $PreviousPicture = $DisplayPicture - 1; } if ($DisplayPicture == $TotalFiles) { $NextPicture = 1;} else { $NextPicture = $DisplayPicture + 1; } ## Load template my $Template = HTML::Template->new(filename => "./template.html"); ## Insert vars into template $Template->param('PreviousPicture' => "$PreviousPicture"); $Template->param('PictureToView' => "$DisplayPicture"); $Template->param('NextPicture' => "$NextPicture"); ## Print Header and Template print $q->header, $Template->output(); ## Bye exit;