#!/usr/local/bin/perl

require "/usr/faculty/professor/cjlin/server-3.0/server/lib/cgi-lib.pl"; 

&ReadParse();

$name = $in{'name'};
$addr = $in{'address'};
$comments = $in{'comments'};
$type = $in{'type'};
$server = $in{'server'};


unless($addr)
{
    &blank_response;
    exit 0;
}

open(MAIL, "|/usr/lib/sendmail -oi -t") || die;

print MAIL <<END;
To: cjlin\@csie.ntu.edu.tw
cc: cjlin\@csie.ntu.edu.tw
From: $addr
Subject: $type comment from $server Web server
Reply-to: $addr

Name: $name
Email: $addr

$comments
END
close(MAIL);

print MAIL <<END;

$type comment from $server web server:

Name: $name
Email: $addr

$comments
END
close(MAIL);

print <<END;
Content-type: text/html


<HEADER>
<TITLE><SERVER> Comment Sent</TITLE>
</HEADER>
<BODY>
Thank you for your comment.
</BODY>
END


#
# No e-mail address
#

sub blank_response
{
  print <<END;
Content-type: text/html


<HEADER>
<TITLE> <SERVER> Comment </TITLE>
<BODY>
Please enter your e-mail address and resubmit.
</BODY>
END
  exit 0;
}
