#!/usr/bin/perl $mailprog = '/usr/lib/sendmail'; $recipient = 'wxycmgmt@metalab.unc.edu'; # 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; # Stop people from using subshells to execute commands # Not a big deal when using sendmail, but very important # when using UCB mail (aka mailx). # $value =~ s/~!/ ~!/g; # Uncomment for debugging purposes # print "Setting $name to $value

"; $FORM{$name} = $value; } # If the comments or address is blank, then give a "blank form" response &blank_response unless $FORM{'comments'}; # Now send mail to $recipient open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n"; print MAIL "To: $recipient\n"; print MAIL "From: $FORM{'address'}\n"; print MAIL "Subject: [WWW survey]\n\n"; print MAIL "------------------------------------------------------------\n\n"; print MAIL "$FORM{'comments'}"; print MAIL "\n\n------------------------------------------------------------\n"; close (MAIL); # # This redirects the browser to look for an html file called thanks.html # after it sends the message. # print "Location: /contact/survey-thanks.html\n\n"; # ------------------------------------------------------------ # subroutine blank_response sub blank_response { print "Location: /contact/error.html\n\n"; exit; }