#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<html><Head><Title> </Title></Head>";
print "<BODY VLINK=#00FF00 TEXT=#00FF00 BGCOLOR=#ffffff>";


# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);

    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    # $value =~ s/~!/ ~!/g; 

    # Uncomment for debugging purposes
    # print "Setting $name to $value<P>";

    $FORM{$name} = $value;
}


open (LOGFILE, ">>/usr/local/etc/httpd/logs/httpdip.log");
 
$t = localtime(time);
print LOGFILE "$ENV{'REMOTE_HOST'}--";
print LOGFILE "<font color=lightgreen>$t</font>-------<font color=green>Name:</font><font color=red>$FORM{'comments'}</font>";
print LOGFILE ">>>> <font color=green>Email:</font><font color=blue>$FORM{'to'}</font> ";
close (LOGFILE);


open (LOGFILE, ">/kasra/gotip");
 
print LOGFILE "$ENV{'REMOTE_HOST'}";

close (LOGFILE);


$t = localtime(time);

# ====================================================================

print <<"EOF";




<center>
<table width=604  height=350 border=0 cellpadding=10>
<tr valign=top><td bgcolor="#ffffff"><font face="Times Roman" size=2>

<center><img src="http://solar.ezenet.com/images/hslc/blueline.gif"><p>
<h2><font color="#ff0000">Please reload your page<br></font></h2>
<img src="http://solar.ezenet.com/images/rad.gif"></center>
<p>
<table border=0>

<center><b><font color="#ff0000"><font size=1><sup>TM</sup></font>.</font></b></center>
<p>
<center>
<p>

</font></td></tr>
</table>
</center>
</body>
</html> 
EOF
