#!/usr/bin/perl # newapply.cgi (~majordom/public_html/cgi-bin) # Created: Wed Jul 2 08:27:39 PDT 1997 $listmaster = 'majordom'; $me='listmaster@machine.host.tld'; if ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); # Load the FORM variables foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Validate email address for evil characters if (($email=$FORM{owner}) !~ /^[a-zA-Z0-9_\-+@%.]+$/) { &evil_characters; exit; } else{ ($user,$host)=split(/@/,$email); unless($host=~/.uoregon.edu/){ &bad_email; exit; } else{ ($good_host)=(gethostbyname($host))[0]; unless($good_host || $OK{$host}){ &bad_host; exit; } } } if ($FORM{password} !~ /^[a-zA-Z0-9_\.]+$/||length($FORM{password})>12) { &bad_password; exit; } $listname=lc $FORM{listname}; if ($listname !~/^[\w\-]+$/||length($FORM{listname})>16){ &bad_listname; exit; } $description=$FORM{description}; if (length($description)<12||length($description)>40){ &bad_description; exit; } if (!$FORM{full_name}||!$FORM{dept}||!$FORM{phone}||!$FORM{camp_addr}){ &incomplete_form; exit; } $dept=uc $FORM{dept}; $authstring="\"$listname\" \"${description}\" \"${dept}\""; # grep for the existing username or alias chop($list_exists=`grep \^$listname: /etc/passwd /etc/aliases /home/majordom/aliases.majordomo`); if($list_exists){ &name_in_use; exit; } # Open up the email message to send the feedback # to the webmaster and the user. open (MESSAGE,"| /usr/sbin/sendmail -oi -t"); # Format email header information print MESSAGE "To: $listmaster\n"; if ($FORM{owner} ne "") { print MESSAGE "Reply-To: $FORM{owner}\n"; } # Write the actual email message print MESSAGE "Subject: list application for $FORM{listname} from $FORM{owner}\n\n"; print MESSAGE "begin_data:$FORM{listname}\n"; # flag beginning for doit while(($key,$value)=each(%FORM)){ if($key=~/^listname:/){ $value= lc $value;} # lowercase listname print MESSAGE "$key:$value\n"; } print MESSAGE "end_data\n"; close (MESSAGE); # Thank the user and acknowledge # the feedback &thank_you; } else { # Format an error message for the user print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Comment Form Error\n"; print "\n"; print "\n"; print "

Comment Form Error

\n"; print "
\n"; print "

\n"; print "Form input was not proccessed. Please mail your "; print "remarks to $listmaster\n"; print "\n"; print "\n"; } sub incomplete_form { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Incomplete Form\n"; print "\n"; print "\n"; print "

Incomplete Form

\n"; print "
\n"; print "

\n"; print "You did not supply all the requested information. "; print "Please back up and complete, then resubmit.\n"; print "\n"; print "\n"; } sub bad_description { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Bad Description\n"; print "\n"; print "\n"; print "

Bad Description

\n"; print "
\n"; print "

\n"; print "The description you entered was too short or "; print "too long. Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub bad_listname { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Bad Listname\n"; print "\n"; print "\n"; print "

Bad Listname

\n"; print "
\n"; print "

\n"; print "The listname you entered contains illegal characters or "; print "is too long. Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub name_in_use { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Name in use\n"; print "\n"; print "\n"; print "

Name in use

\n"; print "
\n"; print "

\n"; print "The listname you entered is in use. "; print "Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub evil_characters { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Illegal Email Address\n"; print "\n"; print "\n"; print "

Illegal Email Address

\n"; print "
\n"; print "

\n"; print "The Email address you entered contains illegal characters "; print "or was omitted. Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub bad_email{ print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Incorrect Email Address\n"; print "\n"; print "\n"; print "

Incorrect Email Address

\n"; print "
\n"; print "

\n"; print "The Email address you entered either was not in 'long form' ", "or was not in the '.uoregon.edu' domain.\n", "Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub bad_host{ print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Problem with Email Address\n"; print "\n"; print "\n"; print "

Problem with Email Address

\n"; print "
\n"; print "

\n"; print "There was a problem Email address you entered. ", "Contact the listmaster: ", "${me}, ", "or back up, change, and resubmit.\n"; print "\n"; print "\n"; } sub bad_password { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Bad Password\n"; print "\n"; print "\n"; print "

Bad Password

\n"; print "
\n"; print "

\n"; print "The password you entered contains illegal characters, is too long, "; print "or was omitted. Please back up and correct, then resubmit.\n"; print "\n"; print "\n"; } sub thank_you { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "Thank You\n"; print "\n"; print "\n"; print "

Thank You

\n"; print "
\n"; print "

\n"; print "Your application has been emailed to the listmaster. Please do\n"; print "not attempt to use your list until you receive email confirming "; print "that it is ready to go.

Please wait at least two working days "; print "without receiving confirmation before inquiring about its status.\n"; print "\n"; print "\n"; }