#!c:/perl/bin/perl.exe ################################################## # Photos 03/02/99 by Jeff Waldock # Lists pictures (on sambar) ################################################## $cgilocation = "photos.pl"; $rootdir="f:/photos/"; $rooturl="/photos/"; $albumdir=$rootdir."albums/"; $albumurl=$rooturl."albums/"; $cgiroot="f:/photos/"; $imageurl="/sysimage"; ################################################### # Get Date and Time from Server @days=("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); @longdays=("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); @month=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); # Get Date and Time from Server $date = localtime(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($min < 10) {$min="0".$min; } $shorttime="$hour:$min"; $century="19"; if ($year < 50) { $century="20"; } $date1="$days[$wday] $mday $month[$mon] $century$year at $shorttime"; $date2="$longdays[$wday] $mday $month[$mon] $century$year at $shorttime"; $thisyear=$century.$year; print "Content-Type: text/html\n\n"; $request_method=$ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $form_info=$ENV{'QUERY_STRING'}; } else { $size_of_info=$ENV{'CONTENT_LENGTH'}; read(STDIN, $form_info, $size_of_info); } @key_value_pairs=split(/&/,$form_info); foreach $key_value (@key_value_pairs) { ($key,$value)=split(/=/,$key_value); $value=~ tr/+/ /; $value=~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg; $INPUT{$key} = $value; #print "",$key," = ",$value,"
\n"; } $picsperframe=$INPUT{'n'}; unless ($picsperframe) { $picsperframe=4; } print "\n"; print "\n"; print "\n"; print "\n"; $pic1=$INPUT{"first"}; unless ($pic1) { $pic1=1; } &GetPhotoData; &Footer; print "\n"; exit; sub Footer { print "\n"; print "\n"; print "\n"; print "\n"; print "
\"Back© Jeff Waldock, 1999
\n"; print "This query: $date2
Data file last updated: $lastdate
\n"; } sub GetPhotoData { $resfile=$rootdir."index.txt"; #print $resfile; open (FILE,$resfile); @lines=; close(FILE); $lastdate=$lines[0]; $lastdate =~ s/"//g; print "

Jeff's Photos

"; $numpix=$#lines; print "$numpix images

\n"; $p=$picsperframe-1; $pic2=$pic1+$p; $w=(100-$p*5)/$picsperframe; print "\n"; #do the labels in row 1 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; #do the photo thumbnails in row 2 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; #do the info in row 3 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; print "
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; print "$id"; } print " 
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id) { $section=$info[1]; $section =~ tr/A-Z/a-z/; $filename=$info[2]; $type=$info[3]; $xpix=$info[4]; $ypix=$info[5]; $pixels=$xpix." by ".$ypix." pixels "; $fileurl=$rooturl.$section."/".$filename."\.".$type; $thumburl=$rooturl.$section."/thumb/".$filename."\.".$type; $filepath=$rootdir.$section."/".$filename."\.".$type; #$thumburl =~ s/\/\//g; #$filepath =~ s/\/\//g; #$fileurl =~ s/\/\//g; #($size)=(stat($filepath))[7]; #$filesize="(".int($size/1000)."K)"; print "\"$pixels$filesize\"

"; } } print "

 
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id) { $section=$info[1]; $section =~ tr/A-Z/a-z/; $filename=$info[2]; $type=$info[3]; $imagedet=$info[6]; $datetaken=$info[7]; $keywords=$info[8]; $description=$info[9]; $fileurl=$rooturl.$section."/".$filename."\.".$type; $thumburl=$rooturl.$section."/thumb/".$filename."\.".$type; print "$description

"; print "$datetaken"; } } print "

\n"; print "

\n"; print "

\n"; print "\n"; print "
\n"; if (($pic1 > 1)&&($pic2 < $numpix)) { $prevpic=$pic1-$picsperframe; $nextpic=$pic1+$picsperframe; $lastpic=$numpix-$picsperframe+1; print "
"; print "\"Back\n"; print "\"Previous\n"; print "\"Next\n"; print "\"Go\n"; print "
"; } if ($pic1 < 2) { $nextpic=$pic1+$picsperframe; $lastpic=$numpix-$picsperframe+1; print "
"; print "\n"; print "\n"; print "\"Next\n"; print "\"Go\n"; print "
"; } if ($pic2 >= $numpix) { $prevpic=$pic1-$picsperframe; print "
"; print "\"Back\n"; print "\"Previous\n"; print "\n"; print "\n"; print "
"; } $picbeg=$pic1; $picend=$pic2; if ($pic2>$numpix) { $picend=$numpix; } print "
Showing $picbeg to $picend of $numpix
\n"; print "
\n"; print "
\n"; }