# This Perl CGI takes variables from the NKLA events.htm form.
# It tests for basic input errors. When input is properly entered,
# this script produces an acknowledgement html page and appends the
# input to a file called dkpost.htm. The acknowledgement page has a
# link to dkpost.htm.
#
# This script uses generic readin procedures that can handle GET and POST
# methods and any number of variables.
#
# This script was created by Danny Krouk (dkrouk@ucla.edu).
# First see if we're called by a GET or a POST, and get our data properly.
# "GET"s pass data to us via arguments.
# "POST"s pass data to us via an environment variable.
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
} else {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
# Now digest the data, putting it into a more useful format.
foreach $pair (@pairs) {
($key, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/\cM/\n/;
# print "$key = $value
\n";
eval("\$$key = \"$value\"");
$FORM{$key} = $value;
}
# Now let's generate a web page to display the data we've got.
# make sure no fields are blank
if (($FORM{fullname} eq "") || ($FORM{subtext} eq "") || ($FORM{killdate} eq "")) {
&PrintNoInput;
}
# make sure email address is correct format
elsif ($FORM{email} !~ /\w*@\w*/) {
&PrintBadEma;
}
# make sure date is valid mm/dd/yy format
elsif ($FORM{killdate} !~ /^\d{2}\/\d{2}\/96/) {
&PrintBadDate;
}
# print acknowledgement
else {
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime( time );
&PrintHeader;
print "\n";
print "
\n"; print "Here is your message: ", $FORM{subtext}, ". It is a: ", $FORM{subtype}, "Announcement.
\n"; print "Your message will be posted until:
\n"; print "Site vistors will be able to send you mail at: ", $FORM{email}, " .
\n"; print "You may view the submissions here
\n";
&PrintButts;
&PrintFooter;
&AppendSub;
}
# Append submission to events posting html page dkpost.htm
sub AppendSub {
open (SUBMISS, ">>dkpadv.htm");
print SUBMISS "
![]() | \n";
print "![]() | \n";
print "$title | \n";
print "