#!/usr/local/bin/perl

# ------------------------------------------------------------
#register.pl
#
#Created 7/29/94 Marc Shuster
#to Act as a registration program
# ------------------------------------------------------------

# Define fairly-constants


$prog = '/usr/bin/cat /com/doc/web/projects/iiip/colab/interest.html - > /tmp/glog';

$cop = '/usr/bin/cp /tmp/glog /com/doc/web/projects/iiip/colab/interest.html';

$today= localtime;

# This should be set to the username or alias that runs your
# WWW server.

# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";

# Print a title and initial heading
print "<Head><Title>Interest Registration</Title></Head>";
print "<Body><H1>Interest Registration</H1>";

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

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

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);

    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;


    # $value =~ s/~!/ ~!/g; 

    # Uncomment for debugging purposes
    # print "Setting $name to $value<P>";

    $FORM{$name} = $value;
}

# If the comments are blank, then give a "blank form" response
#&blank_response unless $FORM{'comments'};

# Now send post entry

open (LOGF, "|$prog ; $cop") || die "Can't open $prog!\n";

local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)
= localtime;

local($mname) = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
		     "Aug", "Sep", "Oct", "Nov", "Dec")[$mon];
local($dname) = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
		     "Sat")[$wday]; 
print LOGF "<b>Date:</b>   $mname  $mday, $year<p>\n";

print LOGF "<b>Name:</b> $FORM{'name'} <p> \n";
print LOGF "<b><a href=$FORM{'home'}>Personal Homepage</a>  \n"

print LOGF "<b>Institution:</b> $FORM{'insti'} <p> \n";
print LOGF "<b><a href=$FORM{'homei'}>Institution's Homepage</a>  \n"
print LOGF "<b>E-Mail:</b> $FORM{'email'} <p> \n";
print LOGF "<p> <b>Title of Interest Statement:</a> $FORM{'title'}<p> \n"

print LOGF "<b>Interest Statement:</b> $FORM{'comments'} <p> <p> <hr> \n"; 
close (LOGF);




print "Thank you for registering interest!<P>";
print "View the <A href=\"/about/GuestLog.html\">Interest Statement Record</a> or return to the <A HREF=/com/docs/web/projects/iiip/home-page.html>home page</A>.<P>";

# ------------------------------------------------------------
# subroutine blank_response
sub blank_response
{
#    print "Your comments appear to be blank, and thus were not added";
#    print "Please re-enter your comments, or ";
#    print "return to the <A HREF=\"/\">home page</A>.<P>";
#    exit;
}


sub get_date {

}
