#!/usr/local/bin/perl

# Open a pipe to the mail command and send some info

sub moreInfo {
  printf ("<br><br>We need more information in order to send you the ");
  printf ("information you requested.<br><br>\n");
  printf ("Please fill in at <b>least</b> the following information:<br>\n");
  printf ("<ul><li>First name<li>Surname or family name\n");
  printf ("<li>Request for information from one or more departments\n");
  printf ("<li>one of the following<ul><li>email address<li>complete permanent address\n");
  printf ("<li>complete mailing address</ul></ul><br><br>\n");
  exit (0);
#  printf ("If you now go back
  }

%variables = ();

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($pair1, $pair2) = split(/=/, $pair);
    $pair2 =~ tr/+/ /;
    $pair2 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $pair1 =~ tr/+/ /;
    $pair1 =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $variables{$pair1} = "$pair2";

}

# First part is the header which must be here
printf ("Content-type: text/html%c",10);
printf ("%c",10);
printf ("<TITLE>Info verification</TITLE>\n");
printf ("<hr>\n");

# check to make sure they have submitted the minimal information
# don't care

# send mail to info-<dept> aliases
open(MAILCMD,"|/usr/lib/sendmail -t -oi");
print MAILCMD "To: walpolr\n";
if ($variables{"email"} ne "") {
  print MAILCMD "From: ", $variables{"email"}, "\n"; }
else {
  print MAILCMD "From: WWW\n"; }
print MAILCMD "Subject: repository feedback\n";
print MAILCMD "---------\n\n";

print MAILCMD "WWW submission\n";
printf MAILCMD ("Submitter:          %s\n",$variables{"email"});
printf MAILCMD ("Goal:               %s\n",$variables{"goal"});
printf MAILCMD ("   goal comment:    %s\n",$variables{"which1"});
printf MAILCMD ("Success:            %s\n",$variables{"success"});
print MAILCMD   "Tasks: \n";
foreach $task ("author","package","directory","key-name","key-contents","query-del","query-clear","query-negate","hid-high","hid-unhigh","load","popup","rearrange","overview","subgraph") 
{ if ($variables{$task} ne "") 
  {printf MAILCMD ("                    %s\n",$task);} }
printf MAILCMD ("Wish-list:\n    %s\n",$variables{"wish"});
printf MAILCMD ("Surprise:\n    %s\n",$variables{"surprise"});
printf MAILCMD ("Comments:\n    %s\n",$variables{"comments"});

close(MAILCMD);

# Return a page to the browser

printf ("<H3>Your information was successfully sent.</h3><br><br>\n");
printf ("<b>Thank you for your feedback!</b><br><br>\n");



