#!/usr/bin/perl
#Look! Look! This is the password!!!! Shhhhhh! Don't tell anyone!
$password = "cow";
# The following code deals with the form data
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
# Load the FORM variables
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
# Does the password equal what the user wrote?
if($password eq $FORM{pw})
#If it does, open this file
{
$file = "correct.html";
open(FILE, $file);
while(<FILE>)
{
print $_;
}
close(FILE);
}
Otherwise, print out this page
else
{
print "Content-type: text/html\n\n";
print "<HTML>";
print "<TITLE>Wrong!</TITLE>";
print "<BODY BGCOLOR=#FFFFCC>";
print "<CENTER><FONT COLOR=red Size = +4> Nope!</FONT></CENTER><P>";
print "Click BACK to try again";
print "</BODY>";
print "</HTML>";
}