#!/usr/local/bin/perl # ############################################################################ # EZ Form Mailer Version 1.0 # # Copyright 1997, 3rd Coast Technologies, LLC # # http://www.3rdcoasttechnologies.com # support@3rdcoasttechnologies.com # # This CGI script takes the data entered in an HTML form # and sends it via e-mail to the specified location. # # EZ Form Mailer is available for anyone to use or modify for no charge. # All we ask is that you leave this copyright notice in the script # and readme.txt file. If someone asks where you got the script, # refer them to 3rd Coast Technologies. # # Selling or distributing this program without prior written approval # is forbidden. # ############################################################################ # Configuration Variables # # The following variables are used to define how your form data # will be processed. The data values can be defined here in the # script or optionally they can be sent from the form by hidden fields. # See the readme.txt file for information on using hidden fields. # ############################################################################ # # $SENDMAIL identifies the location of the send mail program on # your server. Verify this with your webmaster or isp. # ****************************************************** # *** This variable MUST be specified here and *** # *** cannot be sent using hidden fields. *** # ****************************************************** # # @AUTHURLS identifies the URL's that are authorized to use this # CGI Script. Be sure to include all possible variations. # ****************************************************** # *** This variable MUST be specified here and *** # *** cannot be sent using hidden fields. *** # ****************************************************** # # $TO the email address where the form data will be sent. # # $SUBJECT the text that will be used for the subject of the email. # # $REDIRECT identifies the page to be displayed to the user # after they submit the form. # # $SORT_TYPE defines the sort type for the form output. # Options are 'alphabetical', 'field', or 'none'. # # @SORT_FIELDS If the $SORT_TYPE is 'field', enter the field names # in the desired print sequence. # # When changing any of these values, be sure to include the single # quote marks around the values and the semi colon at the end of # each statement. # ############################################################################ $SENDMAIL = '/usr/sbin/sendmail'; @AUTHURLS = ('www.csua.berkeley.edu','csua.berkeley.edu'); $TO = 'askr@earthlink.net'; $SUBJECT = 'Form Data'; $REDIRECT = 'http://www.csua.berkeley.edu/~geek/aspire/thankyou.html'; $SORT_TYPE = 'none'; @SORT_FIELDS = ('Field1', 'Field2', 'Field3', 'Field4', 'Field5'); ############################################################################ # Check to make sure this script was called by an authorized URL(s) &check_url; # Format Local Date/Time for Email Message Date &get_date; # Reformat Form Contents &reformat_form_data; # Send the form data to the recipient via e-mail &send_email; # Redirect user to confirmation page print "Location: $REDIRECT\n\n"; exit(); ################################################################ sub check_url { if ($ENV{'HTTP_REFERER'}) { foreach $AUTHURL (@AUTHURLS) { if ($ENV{'HTTP_REFERER'} =~ /$AUTHURL/i) { $check_url = '1'; last; } } } else { $check_url = '1'; } if ($check_url != 1) { print "Content-type: text/html\n\n"; print "\n
\n\n"; print "Sorry!\n"; print "\n"; exit; } } sub get_date { @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); @months = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } $date = "$days[$wday], $months[$mon] $mday, 19$year at $hour\:$min\:$sec"; } sub reformat_form_data { if ($ENV{'REQUEST_METHOD'} eq 'POST') { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); } else { print "Content-type: text/html\n\n"; print "\n
\n\n"; print "