#! c:/perl/bin/perl # # album.cgi # Photo album. Display photo with comments. # # 1.02 : 8/3/03 : Fixed back link # 1.01 : 8/2/03 : Added $imagedir # 1.0 : 7/26/03 : Created # Hideki Kanayama #### Environement setup from here ############## # A directory name which $script(default is album.cgi) is located.(relative path from shtml file which describes SSI. $subdir = "."; # A directory name which images are located.(relative path from album.cgi) Can be set as an URL starting from http://. $imagedir = "."; # This script name $script = "album.cgi"; # list file name. Put file name, title and comments in it. $file = "album.lst"; # Parent file to go back.(relative path and file name from where album.cgi is located or from http://) $back = "album.shtml"; #### Environement setup until here ############## if ($ENV{"REQUEST_METHOD"} eq "POST"){ read(STDIN,$data,$ENV{"CONTENT_LENGTH"}); } else { $data = $ENV{"QUERY_STRING"}; } @tmparry=split(/&/,$data); foreach $string (@tmparry){ ($key,$value)=split(/=/,$string); $value =~ tr/+/ /; $in{"$key"}=$value; } if ($in{file} eq ''){ &linklist; } else { &dispphoto; } sub linklist { print "Content-Type: text/html\n\n"; if (!open(FILE,"< $file")){ print "
Cannot find the file $file
"; exit; } $i=1; while (){ ($image,$title,$comment)=split(/,/); print "$title
\n"; $i = $i + 1; } close(FILE); } sub dispphoto { print "Content-Type: text/html\n\n"; if (!open(FILE,"< $in{file}")){ print "
Cannot find the file $in{file}
"; exit; } $i=0; while (){ ($image,$title,$comment)=split(/,/); $i = $i + 1; if ("$image" ne "$in{image}") {$previmage=$image;$prevtitle="$title";next;} print < $title

$title

Back

$comment
END ($nextimage,$nexttitle,$nextcomment)=split(/,/,); if ($previmage eq '') { $prevlink="$back#1"; $prevtitle = "Top" } else { $prevlink = "$script?file=$file&image=$previmage"; } if ($nextimage eq '') { $nextlink="$back#1"; $nexttitle = "Top" } else { $nextlink = "$script?file=$file&image=$nextimage"; } print < ©$prevtitle $nexttitle¨ BOTTOM } close(FILE); }