#!/usr/local/bin/perl 

$mailprog = '/usr/bin/mail';
$recipient = 'thomas.mccann.portland.or@worldnet.att.net';

print "Content-type: text/html\n\n";
print "<Head><Title>Oregon Operation Lifesaver</Title></Head>";
print "<Body><H1>Thanks for your assistance!</H1></Body>";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

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;
}

 if ($FORM{'e-mail'} eq "") {$FORM{'e-mail'} = '';}
 if ($FORM{'name'} eq "") {$FORM{'name'} = '';}

open (MAIL, "|$mailprog $recipient $FORM{'e-mail'} $FORM{'NAME'}") || die "Can't open $mailprog!\n";
print MAIL "This is a Web page evaluation from $FORM{'name'} who is reachable at $FORM{'e-mail'}:\n";
print MAIL "\n";
print MAIL "I would say the most useful item on the Main Menu is: $FORM{'most'}\n";
print MAIL "\n";
print MAIL "I would say the least useful item on the Main Menu is: $FORM{'least'}\n"; 
print MAIL "\n";
print MAIL "I give the content of these pages a rating of: $FORM{'rate1'}\n";
print MAIL "\n";
print MAIL "I give the organization of these pages a rating of: $FORM{'rate2'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "Here is what else $FORM{'name'} had to say:\n";
print MAIL "\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "\n";
print MAIL "---------------------------------------------------------------------------\n";
print MAIL "\n";
print MAIL "The browser used to access my Web page: $ENV{'HTTP_USER_AGENT'}\n";
close (MAIL);

print "Your comments will help improve the Oregon Operation Lifesaver web site.<P>\n";
print MAIL "\n";
print "Return to the <A HREF=\"http://trainweb.com/olif/index.htm\">OOL Home Page</a>\n";
