#!/usr/local/bin/perl ######################################################################## ########## Configurable variables ###################################### $SENDMAIL = '/usr/sbin/sendmail'; # The location of your sendmail binary @AUTHDOMAINS = (''); # List of lower-case Internet domains that can use this script # such as ('ncsa.uiuc.edu', 'domain.com') ## Also, make sure the first line of this script points ## to your PERL binary ########## Nothing else to change ###################################### ######################################################################## $ENV{'SCRIPT_NAME'} =~ m#(/.*/)(.*)$#; $SCRIPTDIR = $1; $SCRIPT = $2; #### Do standard HTTP stuff #### &cgi_receive; &cgi_decode; &cgi_header; #### Load mail.list into associative array #### open (MAILNAMES, "mail.list") || die ("$SCRIPT: Can't open mail.list: $!\n"); while () { chop; ($nick, $addr) = split(/:/, $_); $ADDRESS{$nick} = $addr; } close (MAILNAMES); #### Figure out who the information should be sent to #### if ($ENV{'QUERY_STRING'} =~ /\@/) { #### User specified a full email address #### ($machine = $') =~ tr/A-Z/a-z/; undef $FLAG{'authorized'}; for ($[ .. $#AUTHDOMAINS) { $FLAG{'authorized'} = $AUTHDOMAINS[$_], last if ($ENV{'QUERY_STRING'} =~ /$AUTHDOMAINS[$_]$/); } &error_blank_field('an authorized email address') unless ($FLAG{'authorized'}); $recipient = $ENV{'QUERY_STRING'}; $extraaction = "?$recipient"; } elsif ($ENV{'QUERY_STRING'}) { #### User specified a nickname #### $nickname = $ENV{'QUERY_STRING'}; &error_blank_field('a valid recipient nickname') unless ($ADDRESS{$nickname}); $recipient = $ADDRESS{$nickname}; $extraaction = "?$nickname"; } elsif ($FORM{'nickname'}) { #### Input is coming from listbox, ready for forwarding #### $nickname = $FORM{'nickname'}; &error_blank_field('a valid recipient nickname') unless ($ADDRESS{$nickname}); $recipient = $ADDRESS{$FORM{'nickname'}}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { #### I don't know who the information was for #### &error_blank_field('a valid recipient'); } #### Output a default email form if not POSTing already #### &print_form unless ($ENV{'REQUEST_METHOD'} eq "POST"); #### Check for require fields foreach $field (@requirefields) { &error_blank_field($field) unless ($FORM{$field}); } #### Fill in missing fields for forwarding FORM results #### ($FORM{'subject'}) || ($FORM{'subject'} = "FORM results"); ($FORM{'from-email'}) || ($FORM{'from-email'} = $recipient); ($FORM{'from-name'}) || ($FORM{'from-name'} = "WebMonitor mail"); #($FORM{'from-phone'}) || ($FORM{'from-phone'} = "WebMonitor phone"); #### increment counter sofeab-count #### open (TSC, '; $COUNT = $COUNT + 1; open (TSC, '>sofeab-count'); print TSC "$COUNT"; close (TSC); #### compose mail message to sofe-sec #### open (MAIL, "| $SENDMAIL $recipient") || die ("$SCRIPT: Can't open $mailprog: $!\n"); print MAIL "Reply-to: $FORM{'from-email'} ($FORM{'from-name'})\n"; print MAIL "From: $FORM{'from-email'} ($FORM{'from-name'})\n"; print MAIL "To: $recipient\n"; print MAIL "Subject: $FORM{'subject'}\n"; print MAIL "X-Comments: =============================================================\n"; print MAIL "X-Comments: NOTE: This message was sent through the WebMonitor mail form\n"; print MAIL "X-Comments: PLEASE FILE WITH SOFE ABSTRACTS\n"; print MAIL "X-Comments: LOG NUMBER: WA-$COUNT\n"; print MAIL "X-Comments: =============================================================\n"; print MAIL "X-Comments: HOST: $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'})\n"; #print MAIL "X-Comments: BROWSER: $ENV{'HTTP_USER_AGENT'}\n"; print MAIL "X-Comments: REFERER: $FORM{'previous-url'}\n" if ($FORM{'previous-url'}); print MAIL "X-Comments: =============================================================\n"; print MAIL "\n"; #&dump_values(FORM, MAIL); #print MAIL "\n"; print MAIL "$FORM{'title'}\n"; print MAIL "\n"; print MAIL "$FORM{'authors'}\n"; print MAIL "\n"; print MAIL "$FORM{'orgs'}\n"; print MAIL "\n"; print MAIL "$FORM{'abstract'}\n"; print MAIL "\n"; print MAIL "$FORM{'from-name'}\n"; print MAIL "$FORM{'from-address1'}\n"; print MAIL "$FORM{'from-address2'}\n"; print MAIL "$FORM{'from-address3'}\n"; print MAIL "$FORM{'country'}\n"; print MAIL "$FORM{'from-phone'}\n"; print MAIL "$FORM{'from-fax'}\n"; print MAIL "$FORM{'from-email'}\n"; print MAIL "\n"; print MAIL "Session number: $FORM{'session'}\n"; print MAIL "\n"; print MAIL "Additional instructions:\n"; print MAIL " $FORM{'message'}\n"; close (MAIL); #### Now, redirect if "next-url" is included if ($FORM{'next-url'}) { print "Location: $FORM{'next-url'}\n"; print "\n"; exit; } #### Prevent HTML output foreach $key (keys %FORM) { $FORM{$key} =~ s//\>/g; } #### Output confirmation message #### print qq|Abstract Sent\n|; print qq|

Your abstract has been sent.

\n|; print "(please note your Log number: WA-$COUNT)\n"; print qq|
\n|; print "
\n";
print "    Name: $FORM{'title'}\n";
print "    Name: $FORM{'from-name'}\n";
print "  e-mail: $FORM{'from-email'}\n";
print "\n";
#&dump_values(FORM, STDOUT);
print qq|

\n|; print qq|You may now return to the SOFE97 Home Page\n|; print "

\n"; print "\n"; exit; ##################################################################### #### SUBROUTINES #################################################### sub error_blank_field { local($variable) = @_; print "\n" if ($FORM{'next-url'}); print "WebMonitor-Email Error\n"; print "

Error!

\n"; print "You did not fill in $variable.\n"; print "\n"; exit; } sub cgi_header { print "Content-type: text/html\n"; print "\n" unless ($FORM{'next-url'}); } sub cgi_receive { if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $incoming, $ENV{'CONTENT_LENGTH'}); } else { $incoming = $ENV{'QUERY_STRING'}; } } sub cgi_decode { @pairs = split(/&/, $incoming); foreach (@pairs) { ($name, $value) = split(/=/, $_); $name =~ tr/+/ /; $value =~ tr/+/ /; $name =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie; $value =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie; #### Strip out semicolons unless for special character $value =~ s/;/$$/g; $value =~ s/&(\S{1,6})$$/&\1;/g; $value =~ s/$$/ /g; $value =~ s/\|/ /g; $value =~ s/^!/ /g; ## Allow exclamation points in sentences #### Split apart any directive prefixes #### NOTE: colons are reserved to delimit these prefixes @parts = split(/:/, $name); $name = $parts[$#parts]; if (grep(/^require$/, @parts)) { push (@requirefields, $name); } if (grep(/^ignore$/, @parts)) { push (@ignorefields, $name); } if (grep(/^dynamic$/, @parts)) { #### For simulating a checkbox #### It may be dynamic, but useless if nothing entered next if ($value eq ""); $name = $value; $value = "on"; } #### Skip generally blank fields next if ($value eq ""); #### Allow for multiple values of a single name $FORM{$name} .= ", " if ($FORM{$name}); $FORM{$name} .= $value; #### Add to ordered list if not on list already push (@fields, $name) unless (grep(/^$name$/, @fields)); } } sub dump_values { local($env, $handle) = @_; ($handle eq "STDOUT") && (print $handle "
\n");
    foreach $field (@fields) {
	next if (grep(/^$field$/, @ignorefields));
	if ($FORM{$field} =~ /[\cM\n]/) {
	    print $handle "($field)\n";
	    print $handle "-" x 75, "\n", $FORM{$field}, "\n", "-" x 75, "\n";
	}
	else {
            print $handle "($field)  $FORM{$field}\n";
	}
    }
    ($handle eq "STDOUT") && (print $handle "
\n"); } sub print_form { print qq|SOFE'97 Abstract Submission Form\n|; print qq|
\n|; print qq|

SOFE'97 Abstract Submission Form

\n|; print qq|(See sample\n|; print qq|of format for guidance)\n|; print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq|Title:
\n|; print qq|
\n|; print qq|

Author List:

\n|; print qq|
\n|; print qq|

Organization:

\n|; print qq|
\n|; print qq|

Body of Abstract

\n|; print qq|\n|; print qq|

Contact Name:
\n|; print qq|

Address: \n|; print qq|
Address: \n|; print qq|
Address: \n|; print qq|
Country: \n|; print qq|
Phone: \n|; print qq|
FAX: \n|; print qq|
Email Address: \n|; print qq|

Session Number: \n|; print qq|

Additional instructions

\n|; print qq|\n|; print qq|\n|; print qq|


\n|; print qq|
\n|; print qq|
\n|; print qq|\n|; print qq|
\n|; print qq|\n|; exit; }