#!/usr/local/bin/perl -- -*-perl-*-

#$mailprog = '/usr/lib/sendmail -odq';

#$recipient = 'fairmaster@park.org';


# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";

if ($ENV{'CONTENT_LENGTH'} <= 0) {
	$reference = $ENV{'QUERY_STRING'} ;
	$reference =~ tr/+/ /s;

	print <<EoI;

<head><title>Comments about the Internet 1996 World Exposition </title></head>
<BODY BGCOLOR="#FFFFFF" background="/Images/expo_hbk_01.gif" TEXT="#000000" LINK="#97694F" VLINK="#42426f">

<a href="/">
<img align="left" width="545" height=127
SRC="/Images/fair_header.gif" border="0">
</a>
<br clear="all">

<table width="600" height="0"  border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td align="left" valign="top" width="100" height="26" colspan="2">
	</td></tr>
<tr>
<td align="left" valign="top" width="100" >
<td align="left" valign="top" width="500"  >
<p>

<Head><Title>Comments to the Internet 1996 World Exposition</Title></Head>
<Body>
<font size="+2"><b>The Internet 1996 World Exposition is closed </font size="+2"></b><br><p>
Thank you for your interest in the 1996 World Exposition.  For
the past year, this world's fair for the information age has
provided a meeting point for artists, engineers, corporate
executives, and people in all walks of life.  Several thousand
pavilions from 75 countries have participated in this fair
and we've had 5 million visitors from 130 countries and
territories.
<p>
Unfortunately, the world's fair has come to an end.  We appreciate
your interest, but we won't be adding any more pavilions to the fair.  
Please don't feel that this is the only way you can participate in the
network: we encourage you to join thousands of your colleagues
around the world dedicated to building public parks in the
global village.
<p>
Regards,
<p>
Dr. Rob Blokzijl<br>
Secretary-General<br>
The Internet 1996 World Exposition <br>        
	</td>
	</tr>
</table>

   <p><a href="/Images/low_speed.map"><img align="left" width="638" height="87" alt="[Unreadable Image]" SRC="/Images/low_speed.gif" ISMAP border="0"></a>
   <br clear="all">

</body>
</HTML>

EoI

} else {
	# Print a title and initial heading
	print "<Head><Title>Thank you</Title></Head>";

	# Make the person feel good for writing to us

print "<BODY BGCOLOR=\"#FFFFFF\" background=\"/Images/expo_hbk_01.gif\" TEXT=\"#000000\" LINK=\"#97694F\" VLINK=\"#42426f\">";
print "";
print "<a href=\"/\">";
print "<img align=\"left\" width=\"545\" height=\"127\" SRC=\"/Images/fair_header.gif\" border=\"0\"></a>";
print "<br clear=\"all\">";
print "";
print "<table width=\"600\" height=\"0\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
print "	<tr>";
print "		<td align=\"left\" valign=\"top\" width=\"100\" height=\"26\" colspan=\"2\">";
print "	</td></tr>";
print "<tr>";
print "<td align=\"left\" valign=\"top\" width=\"100\" >";
print "<td align=\"left\" valign=\"top\" width=\"500\"  >";
print "<p>";
print "<font size=\"+2\"><b>Thank You!</font size=\"+2\"></b>";
print "";
print "<p>";


    # 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
           $value =~ s/~!/ ~!/g;
            $FORM{$name} = $value;
        }

print "Thank you for your comments regarding:";
print "<ul>  $FORM{'subject'} </ul><p>";
print "";
        if (! $FORM{'username'} || ! $FORM{'subject'} || ! $FORM{'comments'}) {
                print "<p>However, messages with no email address, subject or comments will not be sent.";
                print "<p>";
        } else {
                # Now send mail to $recipient
                &send_mail;
        }

print "	</td></tr></table>";
print "";
print "	</td>";
print "	</tr>";
print "</table>";
print "";
print "";
print "<p><a href=\"/Images/low_speed.map\"><img align=\"left\" width=\"638\" height=\"87\" alt=\"[Unreadable Image]\" SRC=\"/Images/low_speed.gif\" ISMAP border=\"0\"></a>";
print "<br clear=\"all\">";
print "</body>";
print "</HTML>";

}
exit 0;

#
#  send mail message
#
sub send_mail {
	local($about) = $FORM{'about'};

	open (MAIL, "|$mailprog $recipient ") || die "Can't open $mailprog!\n";
	print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
	print MAIL "Subject: $FORM{'subject'}\n\n";
	print MAIL "$FORM{'username'} ($FORM{'realname'}) sent the following\n";
	print MAIL "comment about $about:\n";
	print MAIL  "------------------------------------------------------------\n";
	print MAIL "URL: $FORM{'url'}\n";
	print MAIL "$FORM{'comments'}";
	print MAIL "\n------------------------------------------------------------\n";
	print MAIL "Server name: $ENV{'SERVER_NAME'}\n";
	print MAIL "Gateway Interface: $ENV{'GATEWAY_INTERFACE'}\n";
	print MAIL "Path Info: $ENV{'PATH_INFO'}\n";
	print MAIL "Path Translated: $ENV{'PATH_TRANSLATED'}\n";
	print MAIL "Script Name: $ENV{'SCRIPT_NAME'}\n";
	print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
	print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
	print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
	print MAIL "User Agent: $ENV{'HTTP_USER_AGENT'}\n"
	  if defined($ENV{'HTTP_USER_AGENT'});
	close (MAIL);
}

