#!/usr/local/bin/perl

print "Content-type: text/html", "\n\n"  ;

$now=time ;


require ChatSign ;
$data_basedir=&ChatSign::data_basedir ;
$URLdir_executables=&ChatSign::URLdir_executables ;


$request_method=$ENV{'REQUEST_METHOD'} ;

if ($request_method eq "GET") {
$query_string=$ENV{'QUERY_STRING'}
} else {
$size_of_form=$ENV{'CONTENT_LENGTH'} ;
read(STDIN, $query_string, $size_of_form) ;
}

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

foreach $pair (@pairs) {
	($name, $value) = split(/=/, $pair);
	# Un-Webify plus signs and %-encoding
	$value =~ tr/+/ /;
	# Get rid of all non-alpha/numeric stuff esp " ' ,
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	# $value =~ s/['|"|`|,]//g;
	# Stop people from using subshells to execute commands
	# when using UCB mail (aka mailx).
	$value =~ s/~!/ ~!/g ;
	$FORM{$name}=$value ;
}

print <<ENUF;
<HTML>
<HEAD>
<TITLE>ChatSign for $FORM{requestor} about $FORM{domain}</TITLE>
</HEAD>
<FRAMESET rows="180,*">
        <FRAME SCROLLING=auto NAME="requestorheader" SRC="$URLdir_executables/requestor_header.pl?requestor=$FORM{requestor}&domain=$FORM{domain}">
        <FRAME SCROLLING=auto NAME="requestorfooter" SRC="$URLdir_executables/requestor_footer.pl?requestor=$FORM{requestor}&domain=$FORM{domain}">
</FRAMESET>
</HTML>
ENUF

exit (0);
