#!/usr/bin/perl

$a = $_[0] ? $_[0] : \%in;
$i;
$meth = $_[1] ? $_[1] : $ENV{'REQUEST_METHOD'};
if ($meth eq 'POST') {
	read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
	}
if ($ENV{'QUERY_STRING'}) {
	if ($in) { $in .= "&".$ENV{'QUERY_STRING'}; }
	else { $in = $ENV{'QUERY_STRING'}; }
	}
@in = split(/\&/, $in);
foreach $i (@in) {
	local ($k, $v) = split(/=/, $i, 2);
	$k =~ s/\+/ /g; $k =~ s/%(..)/pack("c",hex($1))/ge;
	$v =~ s/\+/ /g; $v =~ s/%(..)/pack("c",hex($1))/ge;
	$a->{$k} = defined($a->{$k}) ? $a->{$k}."\0".$v : $v;
	}


print "Content-type: text/html\n\n";
print "<!doctype html public '-//w3c//dtd html 4.0 transitional//en'>\n";
print "<html>\n";
print "<head> </head>\n";
print "<body bgcolor='#FFFFFF'>\n";

while (($key, $val) = each %in) {
	print "$key = $val<BR>\n";
}
print "</body></html>\n";

