#!/usr/local/bin/perl ################################################################## # Copyright 1997 Jim Sauer # # This script was written by Jim Sauer (jim@theaction.com). # # # # # # # # This software is covered by the GNU General Public License # # (http://www.theaction.com/scripts/gnu.html) # # # # You may not remove or modify this header except to update the # # links. # # # # You have permission to do anything you want with this script. # # except restrict its further use. # # # # I would appreciate it if you e-mailed me to let me know how # # you used/modified the script. # # I would also appreciate a link to http://theaction/scripts. # # This script comes with no promise or warrantee including # # fitness for a particular purpose. Use it at your own risk. # # I cannot be responsible for any unfortunate # # consequences resulting from the use of this script. # # Read the GNU General Publiic License. # ################################################################## # # # If you modify this script add documentation here # # # ################################################################## ############################################# ### Trivia Administrator's Variables ### $question="What day comes between sunday and tuesday?"; $solution="monday"; $comment="Wow! $name, you must be a calendarologist or something!"; $logfile = "hallfame.html"; # This is the name of your log file. # If it is in a different directory than # your scripts the path must be included here # eg: path/mylogfile.html ############################################# ### System Variables ### $unix = 1; # Set this to 1 for UNIX; 0 for NT $datepath ="/bin/date"; #path to the unix date command ############################################ # Get the input read(STDIN, $STDIN_SIZE, $ENV{'CONTENT_LENGTH'}); # split form data @entry = split(/&/, $STDIN_SIZE); # translate + and % encoding foreach $entry (@entry) { ($name, $value) = split(/=/, $entry); $name =~ tr/+/ /; $value =~ tr/+/ /; $name =~ s/%(..)/pack("c",hex($1))/ge; $value =~ s/%(..)/pack("c",hex($1))/ge; $in{$name} = $value; } $adding = $in{adding} ; if ($adding){ if (! $unix){ print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html \n\n"; require 'ctime.pl'; $Date = &ctime(time); } else{ $Date = `$datepath`; } chop($Date); $answer = $in{answer} ; $name = $in{name} ; $email = $in{email} ; # Read the Log File open (FAME,"$logfile") || die "Can't Open $logfile: $!\n"; @LINES=; close(FAME); $SIZE=@LINES; # Write new data open (FAME,">$logfile") || die "Can't Open $logfile: $!\n"; for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; if (//) { print FAME "\n"; print FAME ""; print FAME "

$Date $name " ; print FAME "e-mail: $email " ; } else { print FAME $_; } } close (FAME); # Write immediate view of log if ($unix){ print "Content-Type: text/html\n\n"; } for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; if (//) { print "\n"; print ""; print "

$Date $name " ; print "e-mail: $email " ; } else { print $_; } } exit; } else { if (! $unix){ print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html \n\n"; } $answer = $in{answer} ; $name = $in{name} ; $email = $in{email} ; $answer =~ tr/[A-Z]/[a-z]/; # Rewrite trivia.html $arg = @ARGV[0]; if ($arg=~ /h/) { open (QUIZ, ">trivia.html") || die "Can't Open trivia.html: $!\n"; print QUIZ "Trivia Game\n" ; print QUIZ "\n"; print QUIZ "
\n"; print QUIZ "

\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "

Today's Question Is:

$question
\n"; print QUIZ "\n"; print QUIZ "
Name:
\n"; print QUIZ "\n"; print QUIZ "
E-mail:
\n"; print QUIZ "\n"; print QUIZ "
\n"; print QUIZ "\n"; print QUIZ "\n"; print QUIZ "
\n"; print QUIZ "
\n"; close (QUIZ); } if ($answer =~ /$solution/){ if ($unix){ print "Content-type: text/html\n\n"; } print ""; print ""; print "
"; print ""; print ""; print ""; print "

$comment

"; print "Your answer, $answer\, was correct.

"; print "Press the button to "; print ""; print " your name to the Webmaster's Trivia Hall of Fame "; print "

"; print "Visit the Webmaster's Hall of Fame.

"; print "Click here to return to the trivia question.
"; print ""; } else { if ($unix){ print "Content-type: text/html\n\n"; } print ""; print ""; print "

Not quite, $name...$answer, was not correct.

"; print "To try again use your browser back button
"; print "

or visit the Webmaster's Hall of Fame
"; print ""; } exit; }