#!/usr/bin/perl # Accept data from our Directory Changes form and mail it # to directory@comfsm.fm # sub uncgi; # Collect data from form: # $varcount=0; if ($ENV{"REQUEST_METHOD"} eq "POST") { # Read POST-type variables read STDIN, $query, $ENV{"CONTENT_LENGTH"}; foreach $pair (split /&/, $query) { # Variables separted with : ($name, $value)=split /=/, $pair; # in form of name=value $parms{$name}=uncgi $value; $varcount+=length($parms{$name}); } } if ($varcount<10) { # Just Submit and the radio button... print "Location: /\n\n"; # Go back to home page if nothing entered. } else { $from=$parms{"myemail"}; if (length($from)==0) { # They didn't list a return e-mail address $from='directory@comfsm.fm'; } open(SM,'|/usr/sbin/sendmail directory@comfsm.fm'); print SM "From: ".$from."\n"; print SM "To: directory\@comfsm.fm\n"; print SM "Subject: COM-FSM Directory Changes\n\n"; print SM "The following information was submitted for the directory:\n\n"; print SM "Name: ".$parms{"name"}."\n"; print SM "Title: ".$parms{"title"}."\n"; print SM "Phone: ".$parms{"phone"}."\n"; print SM "Division: ".$parms{"division"}."\n"; print SM "E-Mail: ".$parms{"email"}."\n"; if ($parms{"change"} eq 'new') { print SM "This information is for a new entry.\n"; } elsif ($parms{"change"} eq 'fix') { print SM "This information is a correction to an existing entry.\n"; } print SM "\nThis information was submitted by:\n\n"; print SM "Name: ".$parms{"myname"}."\n"; print SM "Phone: ".$parms{"myphone"}."\n"; print SM "E-Mail: ".$parms{"myemail"}."\n"; close(SM); print "Location: /directory/thanks.html\n\n"; # Thank you page } sub uncgi { my $result=''; $data=$_[0]; $data =~ tr/+/ /; # Replace + with space. Easy! $i=0; # Find and replace %xx stuff $p=index $data, '%', $i; while ($p>=0) { $result.=substr($data,$i,$p-$i); # Data up to the % $result.=chr(hex(substr($data,$p+1,2))); $i=$p+3; $p=index $data, '%', $i; } $result.=substr($data,$i); # Whatever is left at the end return $result; }