#!/usr/bin/perl $| = 1; print "Content-type: text/html\n\n"; # VARIABLES TO PASS # action = makeindex --> make the table of all the thumbnails # action = openone --> open the page with the specified number # number = the number of the file TO OPEN # COMMENT FILE $commentfile = "../comments/allcomments.txt"; # PARSE THE INPUT if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; # REMOVE WEB MARKUP $value =~ s/\/)/g; $VAL{$name} = $value; } ####### CHOOSE ACTION # ADD ON COMMENT; include query string to define the number and then reopen if ($VAL{'action'} eq "addcomment") { # TEST CHECK if ($VAL{'testcheck'} eq "on") { # REPOPEN THE PAGE &openone; } else { &addcomment; &openone; } } elsif ($VAL{'action'} eq "makeindex") { &makeindex; } elsif ($VAL{'action'} eq "openone") { &openone; } else { print "Method not found; try again.

"; } exit; ######## MAKE INDEX sub makeindex { open (MAINLIST, "filelist.txt"); print "\n"; $counter = 1; while () { chomp; ($number, $name, $caption) = split(/\t/); ($basename,$foo) = split(/\./,$name); $thumbname = "../thumbnails/$basename"."_TN.jpg"; print "\n"; $counter = 0; } $counter++; } close (MAINLIST); } # EOS # OPEN ONE OF THE PAGES ########### sub openone { print "
\n"; # PRINT OUT THE WARNING if ($VAL{'testcheck'} eq "on") { print "
You either are not a human or you did not read the directions. Please try again.


" } open (MAINLIST, "filelist.txt"); while () { chomp; ($number, $name, $caption) = split(/\t/); if ($number == $VAL{'number'}) { $imagename = "../images/$name"; print "

$caption

\n"; } if ($number > 0) { $keepnumber = $number; } } close (MAINLIST); # DETERMINE THE PREVIOUS AND NEXT NUMBERS, CYCLING THROUGH $previousnum = $VAL{'number'} - 1; if ($previousnum < 1) { $previousnum = $keepnumber; } $nextnum = $VAL{'number'} + 1; if ($nextnum > $keepnumber) { $nextnum = 1; } print "

\n"; print "({-----(back) O "; print "\n"; print "(next)-----})\n"; print "

Return to the Index\n"; # WRITE COMMENT BOX print "


Make a comment:
\n"; #print "
\n"; print ""; print ""; print ""; print "
\n"; print "By UNchecking this box I certify that I am a human being,"; print "that I have free will, and that my comment is sincere.
\n"; print "Your name:
\n"; print "\n"; print "
"; # PRIOR COMMENTS print "<\/center>COMMENTS:
\n"; open (PRINTCOMM, "$commentfile"); while () { ($number,$messageauthor,$messagetext) = split(/\*\*\&\*\*\g\*\*\t/, $_); if ($number == $VAL{'number'}) { print "
$messageauthor<\/b>:"; print "$messagetext
\n"; } } # EOS } # ADD THE COMMENT TO THE MAIN FILE ############ sub addcomment { open (COMMFILE, ">>$commentfile"); # REMOVE LINE RETURNS FROM THE COMMENT $VAL{'messagetext'} =~ s/\n/
/g; $VAL{'messagetext'} =~ s/\r//g; print COMMFILE "$VAL{'number'}**&**g**\t"; print COMMFILE "$VAL{'messageauthor'}**&**g**\t"; print COMMFILE "$VAL{'messagetext'}\n\n\n"; close (COMMFILE); }
\n"; print "\n"; print "
$caption\n"; print "
"; if ($counter ==4) { print "