#!/local/bin/perl ################################################################# # This is for customer feedback on a number of devEdge forms. # # It checks for required fields, displays an error page # # if incomplete, displays a thank you page if complete, and # # sends the data to the interested parties. # # The script can be modified send email # # to different newsgroups; dependant on # # which form the request came from. # # By Tom Gibson 03/24/03 # # based on webmail_feedback.cgi # ################################################################# ############## # Parse Input Arguments. ############## &ReadParse(); ############## # Variables ############## $useragent = $in{'useragent'}; $subject = $in{'subject'}; $url = $in{'url'}; $message = $in{'message'}; $whichform = $in{'whichform'}; $email = $in{'email'}; $mailprog = '/usr/lib/sendmail -i'; $list_email = "devedge-feedback\@netscape.com"; print "Content-Type: text/html\r\n\n"; unless($useragent && $subject && $message && $url && $email) {&abort;} &mail_it; &print_thanks; ############## # subs...print_thanks ############## sub mail_it { open(MAIL,"| $mailprog $list_email") || die "Can't open $mailprog!\n"; print MAIL "From: $email\n"; print MAIL "To: $list_email\n"; print MAIL "Subject: $subject\n\n"; print MAIL "Subject: $subject\n"; print MAIL "URL: $url\n"; print MAIL "User Agent: $useragent\n\n"; print MAIL "Message: $message\n"; close(MAIL); } ############## # subs...print_thanks ############## sub print_thanks { print < Thank You EOF } ############## # subs...abort ############## sub abort { print < Form not sent!

Form Error

Your feedback has not been sent.

We would like to receive your feedback. Your comments and suggestions allow us to continually enhance and improve our service. We use your input to design and include the features that you want to see.

Please go back to the form and fill it in completely.

Thank you. EOF exit; } ############## # subs...ReadParse ############## sub ReadParse { $in = ""; if (@_) { local (*in) = @_; } local ($i, $loc, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { for ($i = 0; $i < $ENV{'CONTENT_LENGTH'}; $i++) { $in .= getc; } } @in = split(/&/,$in); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Convert %XX from hex numbers to alphanumeric $in[$i] =~ s/%(..)/pack("c",hex($1))/ge; # Split into key and value. $loc = index($in[$i],"="); $key = substr($in[$i],0,$loc); $val = substr($in[$i],$loc+1); if (!defined($in{$key})) { $in{$key} = ""; } else { $in{$key} .= '\0'; } #if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } }