#!/usr/local/bin/perl

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

$now=time ;

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

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


$now=time ;

print <<ENUF;
<HTML>
<SCRIPT Language="JavaScript">
function clearchat ()
{
document.forms[0].nextline.value=document.forms[0].showline.value ;
document.forms[0].showline.value='' ;
return (true) ;
}
</SCRIPT>
<BODY BGCOLOR=#eeeed4>
<CENTER>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">

  <TR>
      <TD COLSPAN=2>
        <FONT FACE=\"Arial, Helvetica, sans-serif\" size=\"2\">
        <B><FONT SIZE="2" COLOR="#999999">
        Welcome $FORM{requestor}</FONT></B><FONT SIZE="1" COLOR="#999999"><BR>
        Enter your questions about <b>$FORM{domain}</b> below then click
        <B>Send</B>.</FONT></TD>
    </TR>
	<TR>
		<TD COLSPAN=2>
		<CENTER>
		<FORM onSubmit="return(clearchat())" TARGET=requestorfooter METHOD=POST ACTION= "$URLdir_executables/requestor_footer.pl">
		<INPUT TYPE=hidden NAME=requestor VALUE=$FORM{requestor}>
		<INPUT TYPE=hidden NAME=domain VALUE=$FORM{domain}>
		<INPUT TYPE=hidden NAME=nextline SIZE=50 SELECTED>
		<INPUT TYPE=text NAME=showline size=50 SELECTED>
		</TD>
	</TR><TR>	
		<TD ALIGN=left>
		<INPUT TYPE="image" BORDER="0" NAME="submit2" SRC="http://www.chatsign.com/img/chat_chat.gif" width="32" height="12">
		</FORM>
		</TD>
		<TD ALIGN=right>
		<FORM onSubmit="window.close" TARGET=_parent METHOD=POST ACTION="$URLdir_executables/requestor_close.pl">
		<INPUT TYPE=hidden NAME=domain VALUE=$FORM{domain}>
		<INPUT TYPE=hidden NAME=requestor VALUE=$FORM{requestor}>
		<INPUT TYPE="image" BORDER="0" NAME="imageField" SRC="http://www.chatsign.com/img/chat_end.gif" width="32" height="12">
		</FORM>
		</FONT>
      </TD>
    </TR>
    <TR> 
    	<TD ALIGN=left>
	<FONT FACE="Arial, Helvetica, sans-serif" SIZE="1" COLOR="#999999">
	The frame below will automatically update every 10 seconds.
	</FONT>
	</TD>

	<TD ALIGN=right>
	<FONT FACE="Arial, Helvetica, sans-serif" SIZE="1" COLOR="#999999">
	Another <A TARGET=_blank HREF="http://www.chatsign.com">ChatSign</A> Chat</FONT>
	</FONT>
	</TD>
    </TR>
</TABLE>
</CENTER>
</FONT>
</BODY>
</HTML>
ENUF
exit (0) ;
