#!/usr/pkg/bin/perl ############################################################################## # photoshow2.pl # # Updated 26-Sep-03: make full-size shot not take any prefix # Updated 24-Sep-03: handle include files # Updated 13-Sep-03: handle thumbnail ranges # Updated 13-Aug-03: handle thumbnail pages, different template directory # Updated 01-Jan-04: make it generate HTML files # Parse the input parameters: $qstring = $ENV{'QUERY_STRING'}; if ( $qstring eq "" ) { $qstring = @ARGV[0]; } ($working_dir, $thumbstemplate, $phototemplate, $photolistfile, $photonum_passed, $htmlname) = split(/\?/, $qstring); my $useHTMLFiles; if ($htmlname eq "") { $useHTMLFiles = 0; } else { $useHTMLFiles = 1; } $WEBSITE_BASE = ".."; # base relative to the cgi-bin directory this script is in, for HTML links $BASE_PATH = ""; if (!$useHTMLFiles) { $BASE_PATH = "/usr/tanelorn/dietrich/public_html/"; } $THISSCRIPT = "photoshow2.pl"; $PHOTOLISTFILE = "$BASE_PATH$working_dir/$photolistfile"; open(FLPHOTOLIST,"$PHOTOLISTFILE"); @photolist=; if ( $photonum_passed < -1 || $photonum_passed >= scalar(@photolist) ) { exit; } # this block is a loop for blank $photonum_passed; a single pass for passed-in $photonum_passed my $loopbegin; my $loopend; if ( $photonum_passed eq "" ) { $loopbegin = -1; $loopend = scalar(@photolist)-1; } else { $loopbegin = $photonum_passed; $loopend = $photonum_passed; } for ( $photonum=$loopbegin; $photonum<=$loopend; $photonum++ ) { my ($templatefile); if ( $photonum == -1 ) { $templatefile = "$BASE_PATH$working_dir/$thumbstemplate"; } else { $templatefile = "$BASE_PATH$working_dir/$phototemplate"; } open(FLTEMPL,"$templatefile"); @templ=; if ($useHTMLFiles) { if ( $photonum == -1 ) { open FLOUT, ">$working_dir/$htmlname.htm" ; } else { open FLOUT, ">$working_dir/$htmlname$photonum.htm" ; } select FLOUT; } if ($useHTMLFiles) { print "\n"; } else { print "Content-type: text/html\n\n"; } # Find the photo file name, caption, and other info for this photo: ( $photofilename, $caption, $hasfullsize ) = split (/\t/, @photolist[$photonum] ); # Go through each line of the template file, ignoring every line that's not in the # or section, and look for the special comment tags: $inbody=0; foreach $line (@templ) { chop $line; if (index($line, "/, $line); ($keyword, $thumbrange) = split( /=/, $heading); if ($thumbrange ne "") { ($thumbfirst, $thumblast) = split( /-/, $thumbrange); if ( $thumblast == 0 ) { $thumblast = $thumbfirst; } } for ( $linkphotonum = $thumbfirst; $linkphotonum <= $thumblast; $linkphotonum++ ) { ( $linkphotofilename ) = split (/\t/, @photolist[$linkphotonum] ); if ( $useHTMLFiles ) { print "\n"; } else { print "\n"; } # might add target=\"_blank\" to the above line? } } elsif (index ($line, "