#!/usr/local/bin/perl ## Mail Form Handler (mail_form.pl) Copyright 1998-2003 ## by Tim Stevenson, tstevens at employees.org ## Generic HTML form-processing CGI script ## Version 4.1 -- Modified September 2003 ## Version 4.0 -- Modified August 2003 ## Version 3.2 -- Modified April 2002 ## Version 3.1 -- Modified July 2000 ## Version 3.0 -- Modified July 1999 ## Version 2.0 -- Modified January 1998 ## Version 1.0 -- Modified March 1997 ## ReadParse subroutine by Steven E. Brenner $version = "4.1"; ####################################################################### ## HTTP Referer Control Block: ## ## Here is the "HTTP Referer" control block, which consists of: ## - Ignore Flag: if set to 1, the allowed list is ignored; otherwise, ## we compare $ENV(HTTP_REFERER) to the HTTP Allowed List ## - Allowed List: if Ignore Flag is not 1, then a regexp comparison is ## performed against this list ## Modify this block only if you want to limit the use of the script to ## certain referring domains. ## ## **Ignore Flag** ## The next line sets the Ignore Flag. Set to 0 to enable HTTP Referer ## Allowed List checking, set to 1 to disable checking: $ignoreHttpAllowedList = 1; ## **Allowed List** ## The next line defines the HTTP Referer Allowed List (a quoted, comma- ## separated list) containing the list of domains, IP addresses, and/or ## URLs you want to be able to submit forms to the script. Be sure to ## include all possible representations of the domain name (perhaps ## "example.com" as well as "www.example.com"): @httpAllowedList = ("www.example.com", "http://example.com", "10.99.113.4"); ## end of HTTP Referer control block ####################################################################### # Define the "special" form fields &specialFields; # Get misc script & server info &getScriptandServerInfo; # Set the defaults &setDefaults; # Print the HTTP header &httpHeader; # Gather the form input &ReadParse; # Make sure they use "POST" &checkForPOST; # Check for input &checkForInput; # Print the help file if need be if ( $errorState == 1 ) { &printHelpFile; } # Check whether we can find the sendmail executable $sendmail_found = &locateSendmail; # Abort if we cannot find sendmail if ($sendmail_found != "1") { &noSendmailError; } # Check the HTTP_REFERER $referer_allowed = &checkHttpReferer; # Abort if referer is not in allowed list if ($referer_allowed != "1") { &httpRefererError; } # Check which fields are flagged as required &idRequiredFields; # Replace defaults based on form input &replaceDefaults; # Make sure required fields are populated &checkRequiredFields; # Check for title centered requirement &isTitleCentered; # If some required fields aren't filled in, complain if ($errormsg ne "") { &requiredFieldsMissingError; } # ...Otherwise, generate the final output... else { &generateFinalOutput; } # ...and then exit gracefully exit (0); ########################################################################################### # Subroutines follow sub specialFields { # Supported "special" form fields and their "required" versions are contained # in the array \@specials (except the special case for "Full Name", which sometimes # should be displayed) @special_fields = ("Recipient Address", "Cc Address", "Auto Cc", "Email Subject Line", "Email HTML", "Background Color", "Link Color", "ActiveLink Color", "VisitedLink Color", "Text Color", "Toggle Graphics", "Required Graphic", "Graphic", "Magic Word", "Response Page Title", "Greeting", "Return URL", "Return Link Text", "Show Blanks", "Show Results", "Debug Flag"); foreach (@special_fields) { push (@specials, $_); $_ =~ s/$/*/; push (@specials, $_); } } sub getScriptandServerInfo { # Get info about the script and server $script_filename = $script_path = $ENV{SCRIPT_NAME}; $script_filename =~ s#.*/([^/]+)$#\1#; $script_path =~ s#^//#/#; $server = $ENV{SERVER_NAME}; $server =~ s#/##g; $referer = $ENV{HTTP_REFERER}; } sub setDefaults { # Set default values for all the variables $ADDRESS = $DEF_ADDRESS = "nobody\@example.com"; $EMAIL_ADDRESS = $DEF_EMAIL_ADDRESS = $RETURN_ADDRESS = "nobody"; $COPY_ADDRESS = $DEF_COPY_ADDRESS = ""; $AUTO_COPY = $DEF_AUTO_COPY = "No"; $FULL_NAME = $DEF_FULL_NAME = "exclude;Mail Form Handler"; $SUBJECT = $DEF_SUBJECT = "Form Submission"; $EMAIL_HTML = $DEF_EMAIL_HTML = "No"; $BKGD_COLOR = $DEF_BKGD_COLOR = "white"; $LINK_COLOR = $DEF_LINK_COLOR = ""; #unspecified $ALINK_COLOR = $DEF_ALINK_COLOR = ""; #unspecified $VLINK_COLOR = $DEF_VLINK_COLOR = ""; #unspecified $TEXT_COLOR = $DEF_TEXT_COLOR = "black"; $REQUIRED_URL = $DEF_REQUIRED_URL = "http://www.example.com/imglib/some.gif"; $TOGGLE_GRAPHICS = $DEF_TOGGLE_GRAPHICS = "On"; $GRAPHIC_URL = $DEF_GRAPHIC_URL = "http://www.example.com/imglib/some_other.gif"; $MAGIC = $DEF_MAGIC = ""; $TITLE = $DEF_TITLE = "Mail Form Handler Response"; $GREETING = $DEF_GREETING = "Thank you for your form submission."; $RETURN_URL = $DEF_RETURN_URL = ""; $RETURN_LINK_TEXT = $DEF_RETURN_LINK_TEXT = ""; $SHOW_BLANKS = $DEF_SHOW_BLANKS = "No"; $SHOW_RESULTS = $DEF_SHOW_RESULTS = "No"; $DEBUG_FLAG = $DEF_DEBUG_FLAG = "No"; $errorState = 0; } sub httpHeader { # Print the HTTP header print "Content-type: text/html", "\n\n"; } sub ReadParse { # ReadParse subroutine # Courtesy of Steven E. Brenner's cgi-lib.pl # If the code in this subroutine isn't working well with your server, # visit the cgi-lib.pl home page on the web to find a version that works better. local (*in) = @_ if @_; local ($i, $loc, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } @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. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. $in{$key} .= '\0' if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } return 1;# just for fun } sub checkForPOST { # If they don't use "POST", return the help file if ($ENV{'REQUEST_METHOD'} eq "GET") { $errorState = 1; $TITLE = "Mail Form Handler Help"; } } sub checkForInput { # If there is no input to the script, return the help file if ($ENV{'CONTENT_LENGTH'} == 0) { $errorState = 1; $TITLE = "Mail Form Handler Help"; } } sub printHelpFile { # Look for the sendmail executable, then print the Help File &locateSendmail; &helpFile; exit (0); } sub idRequiredFields { # Check input names to see which fields are required, which are optional for ($x=0; $x<=$#in; $x++) { @form_input = split (/=/ , $in[$x] , 2); if ($form_input[0] =~ /\*$/) { push (@required_fields, $form_input[0]); } } } sub checkRequiredFields { # Make sure required fields have values assigned to them foreach $item (@required_fields) { $value = $item; chop ($item); if ($in{$value} eq "" || $in{$value} eq $MAGIC) { $TITLE = "Required Fields"; $errormsg .= "
  • $item\n"; } } } sub isTitleCentered { # Check the Title for formatting info if ($TITLE =~ /^center;/) { $TITLE =~ s/^center;//; $center = 1; } } sub requiredFieldsMissingError { # Prints error screen if some required fields are not completed &pageHeader; if ($center == 1) { print "
    \n"; } if ($TOGGLE_GRAPHICS eq "On") { print "$REQUIRED_GRAPHIC\n"; } if ($center == 1) { print "
    \n"; } print <<"error_message";

    The following field(s) have to be completed before this form can be processed.

    Use your browser's Back button to return to the form and complete the field(s) as required. error_message &footerCode; print "\n\n"; exit (0); } sub generateFinalOutput { # If you don't put sendmail in one of the default locations, the next is one of two lines # to modify with the alternative path -- replace "$sendmail_location" with your path if ( open (EMAIL, "|$sendmail_location \"-f${RETURN_ADDRESS}\" -t") != 0 ) { # ^^^^^^^^^^^^^^^^^^ $blank = 1; # Prepare the email header &emailHeader; # Print the page header &pageHeader; if ($EMAIL_HTML eq "Yes") { &emailPageHeader; } # Print submission details &printSubmissionInfo; # Center heading elements of HTML page if requested if ($center == 1) { print "

    \n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "
    \n"; } } # If graphics are enabled, print the header graphic if ($TOGGLE_GRAPHICS eq "On") { print "$GRAPHIC\n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "

    $GRAPHIC
    \n"; } } print "
    \n

    $TITLE

    \n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "
    \n

    $TITLE

    \n"; } if ($center == 1) { print "
    \n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "
    \n"; } } print "$GREETING\n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "$GREETING\n"; } if ($SHOW_RESULTS eq "Yes") { print "

    \n\n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "

    \n

    \n"; } } # Now print the name/value pairs submitted via the form &nameValuePairs; # Finish the page up if ($SHOW_RESULTS eq "Yes") { print "
    \n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "\n"; } } if ($RETURN_URL ne "" && $RETURN_LINK_TEXT ne "") { print "

    $RETURN_LINK_TEXT\n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "

    $RETURN_LINK_TEXT\n"; } } # Print the footer &footerCode; if ($EMAIL_HTML eq "Yes") { &emailFooterCode; } print "\n\n"; if ($EMAIL_HTML eq "Yes") { print EMAIL "\n\n"; } # Handle case where script is run from the command line. if ( $blank == 1 ) { $server = `hostname` unless $! != 0; if ($server eq "") { $server = ""; } ($cmdline_user, $j1, $j2, $j3, $j4, $cmdline_users_host) = split (/\s+/, `who am i`); $cmdline_users_host =~ s#\((.+)\)#\1#; print EMAIL "Message from the Mail Form Handler on $server:\n"; print EMAIL "There was no form input received. Looks like " . $cmdline_user . " at " . $cmdline_users_host . " is running this script from the command-line.\n"; } close (EMAIL); $blank == 1 ? "No input! " : ""; } else { # If you don't put sendmail in one of the default locations, the next is the second of two lines # to modify with the alternative path -- replace "$sendmail_location" with your path print "$sendmail_location: $!

    \n"; # ^^^^^^^^^^^^^^^^^^ print "Comment failed.

    \n"; } } sub emailHeader { # Prepare the email header print EMAIL <<"email_header"; To: $ADDRESS From: $EMAIL_ADDRESS ($FULL_NAME) Subject: $SUBJECT Errors-To: $ADDRESS email_header # Print email header to HTML page if debugging on if ($DEBUG_FLAG eq "Yes") { print <<"html_version";

    Debug Flag is ON!

     

    Email Headers:

    To: $ADDRESS
    From: $EMAIL_ADDRESS ($FULL_NAME)
    Subject: $SUBJECT
    Errors-To: $ADDRESS
    html_version } if ($COPY_ADDRESS ne "") { print EMAIL "Cc: $COPY_ADDRESS\n"; if ($DEBUG_FLAG eq "Yes") { print "Cc: $COPY_ADDRESS
    \n"; } } if ($RETURN_ADDRESS ne "nobody") { print EMAIL "Reply-To: $RETURN_ADDRESS\n"; if ($DEBUG_FLAG eq "Yes") { print "Reply-To: $RETURN_ADDRESS
    \n"; } } } sub printSubmissionInfo { # Print particulars about when & where the form was submitted print EMAIL "\n"; # Print the date and time of form submission in the email body $date_string = `date`; chop($date_string); if ($EMAIL_HTML eq "Yes") { print EMAIL "

    Form location: $ENV{HTTP_REFERER}
    \nSubmitted: $date_string from $server\n\n"; } else { print EMAIL "Form location: $ENV{HTTP_REFERER}\nSubmitted: $date_string from $server\n\n"; } if ($DEBUG_FLAG eq "Yes") { print "\n

     \n

    Submission Details:\n"; print "

    Form location: $ENV{HTTP_REFERER}\n
    Submitted: $date_string from $server\n"; } # Print HTTP referer debugs to HTML page if debugging on if ($DEBUG_FLAG eq "Yes") { for ($x=0; $x < @referer_debugs; $x++) { print "$referer_debugs[$x]"; } } # Print sendmail debugs to HTML page if debugging on if ($DEBUG_FLAG eq "Yes") { for ($x=0; $x < @sendmail_debugs; $x++) { print "$sendmail_debugs[$x]"; } } } sub nameValuePairs { # FORLOOP block reads each input name/value pair and prints it to the email and to the screen FORLOOP: for ( $x=0; $x<=$#in; $x++) { $blank = 0; @form = split (/=/ , $in[$x] , 2); push (@form_names, $form[0]); push (@form_values, $form[1]); # Exclude the "special" form fields from output foreach $special_test (@specials) { if ($form_names[$x] eq $special_test) { next FORLOOP; } } # If Show Blanks equals No then skip any inputs with null values. if ($display_blanks == 1 && $form_values[$x] eq "") { next FORLOOP; } if ($exclude == 1 && $form_names[$x] =~ /Full Name/) { next FORLOOP; } $form_names[$x] =~ s/\*$//; &createEmail; &createHTMLPage; } } sub createEmail { if ($EMAIL_HTML eq "Yes") { # The form name/value pairs are placed in the email as HTML # Replace newlines with

    tags $form_values[$x] =~ s/\n/

    /g; print EMAIL "$form_names[$x]<\/b><\/td>\n $form_values[$x]<\/td><\/tr>\n"; } else { # The form name/value pairs are placed in the email as printf-formated text printf EMAIL ("%-22s %-s \n\n", "$form_names[$x]:", "$form_values[$x]"); } } sub createHTMLPage { # The form name/value pairs are returned onscreen, if Show Results eq Yes if ($SHOW_RESULTS eq "Yes") { # Replace newlines with

    tags $form_values[$x] =~ s/\n/

    /g; print "$form_names[$x]<\/b><\/td>\n $form_values[$x]<\/td><\/tr>\n"; } } sub locateSendmail { # Subroutine to search for the sendmail binary on the server # Need to save debug info for later in case Debug Flag is enabled push (@sendmail_debugs,"

     \n

    Sendmail Info:\n

    \n"); $sendmail_string = "Located the sendmail binary on this server in directory: "; $sendmail_defaults = "\n
    This is one of the default locations, no script modification necessary."; if (-e '/usr/lib/sendmail'){ $sendmail_location = "/usr/lib/sendmail"; $sendmail_bin = $sendmail_string . "/usr/lib/" . $sendmail_defaults; push (@sendmail_debugs,"Sendmail found in $sendmail_location\n

     \n

    "); return 1; } elsif (-e '/usr/bin/sendmail'){ $sendmail_location = "/usr/bin/sendmail"; $sendmail_bin = $sendmail_string . "/usr/bin/" . $sendmail_defaults; push (@sendmail_debugs,"Sendmail found in $sendmail_location\n

     \n

    "); return 1; } elsif (-e '/usr/sbin/sendmail') { $sendmail_location = "/usr/sbin/sendmail"; $sendmail_bin = $sendmail_string . "/usr/sbin/" . $sendmail_defaults; push (@sendmail_debugs,"Sendmail found in $sendmail_location\n

     \n

    "); return 1; } else { $sendmail_bin = "Could not locate the sendmail binary in /usr/lib, /usr/bin, or /usr/sbin/!
    You must modify the script to point to your sendmail executable, or install the sendmail executable in one of these directories."}; push (@sendmail_debugs,"Sendmail not found!!\n

     \n

    "); return 0; } sub noSendmailError { # Subroutine to handle case where sendmail is not in one of the default locations $TITLE = "No Sendmail Found!"; $BKGD_COLOR = "bgcolor=\"white\""; $TEXT_COLOR = "text=\"black\""; &pageHeader; print <<"sendmail_error_message";

    Error! No Sendmail Executable Found!

    Unable to locate sendmail executable in any of these locations:

    • /usr/lib/
    • /usr/bin/
    • /usr/sbin/

    You must modify the script to point to your sendmail executable, or install the sendmail executable in one of these directories. sendmail_error_message &footerCode; print "\n\n"; exit (0); } sub checkHttpReferer { # Subroutine to check the HTTP Referer against the allowed domain list $refererCheckPassed = 1; if ($ignoreHttpAllowedList != 1) { $refererCheckPassed = 0; # Need to save debug info for later in case Debug Flag is enabled push (@referer_debugs,"

     \n

    HTTP Referer Info:\n

    \n"); foreach $current_allowed (@httpAllowedList) { $current_allowed =~ s/\./\\./g; push (@referer_debugs,"Refererer String Tested: $current_allowed
    \n"); if ($referer =~ m%$current_allowed%) { # Matched allowed list! $refererCheckPassed = 1; push (@referer_debugs,"Matched? (0=no, 1=yes): $refererCheckPassed
    \n"); return $refererCheckPassed; } push (@referer_debugs,"Matched? (0=no, 1=yes): $refererCheckPassed
    \n"); } # end foreach } push (@referer_debugs,"Matched? (0=no, 1=yes): $refererCheckPassed
    \n"); return $refererCheckPassed; } sub httpRefererError { # Subroutine to handle case where HTTP Referer domain is not allowed $TITLE = "Unauthorized User!"; $BKGD_COLOR = "bgcolor=\"white\""; $TEXT_COLOR = "text=\"black\""; &pageHeader; print <<"referer_error_message";

    Error! Unauthorized User!

    You are not authorized to submit form data to this script. referer_error_message print "\n\n"; exit (0); } sub pageHeader { # Print the page header and body statement print <<"page_header_and_body_statement"; $TITLE page_header_and_body_statement } sub emailPageHeader { # Print the page header and body statement to the Email print EMAIL <<"page_header_and_body_statement"; $TITLE page_header_and_body_statement } sub fixAntiSpamEmail { # Replace anti-spam address with valid address local ($ADDRESS_STRING_ARG) = $_[0]; $ADDRESS_STRING_ARG =~ s/\s+at\s+/@/gi; return $ADDRESS_STRING_ARG; } sub emailCheck { # Subroutine to verify validity of Email address local ($bad_email) = 0; local ($ADDRESS_STRING_ARG) = $_[0]; local (@addresses) = split (/ *, */, $ADDRESS_STRING_ARG); foreach $current_address (@addresses) { # Check for wacky characters and other no-nos in the email address if (($current_address =~ /[\[\]\{\};><\(\):&#\$^*\\\/`%!\s]/) || ($current_address !~ /@/) || ($current_address =~ /^@/) || ($current_address =~ /\@$/) || ($current_address =~ /@.*@/)) { $TITLE = "Invalid Email Address"; $current_address =~ s//>/g; &pageHeader; print <<"bad_email_address_message";

    $TITLE

    The email address specified in the "$special_field" field, $current_address, is invalid.

    Use your browser's Back button to return to the form and specify a valid email address (user\@domain). bad_email_address_message &footerCode; print "\n\n"; exit(0); } } } sub replaceDefaults { ## Replace Default values as necessary # REPLACE DEFAULT BACKGROUND COLOR, IF REQUIRED if ($in{'Background Color'} ne "") { $BKGD_COLOR = "bgcolor=\"$in{'Background Color'}\""; } elsif ($in{'Background Color*'} ne "") { $BKGD_COLOR = "bgcolor=\"$in{'Background Color*'}\""; } # REPLACE DEFAULT LINK COLOR, IF REQUIRED if ($in{'Link Color'} ne "") { $LINK_COLOR = "link=\"$in{'Link Color'}\""; } elsif ($in{'Link Color*'} ne "") { $LINK_COLOR = "link=\"$in{'Link Color*'}\""; } # REPLACE DEFAULT ACTIVE LINK COLOR, IF REQUIRED if ($in{'ActiveLink Color'} ne "") { $ALINK_COLOR = "alink=\"$in{'ActiveLink Color'}\""; } elsif ($in{'ActiveLink Color*'} ne "") { $ALINK_COLOR = "alink=\"$in{'ActiveLink Color*'}\""; } # REPLACE DEFAULT VISITED LINK COLOR, IF REQUIRED if ($in{'VisitedLink Color'} ne "") { $VLINK_COLOR = "vlink=\"$in{'VisitedLink Color'}\""; } elsif ($in{'VisitedLink Color*'} ne "") { $VLINK_COLOR = "vlink=\"$in{'VisitedLink Color*'}\""; } # REPLACE DEFAULT TEXT COLOR, IF REQUIRED if ($in{'Text Color'} ne "") { $TEXT_COLOR = "text=\"$in{'Text Color'}\""; } elsif ($in{'Text Color*'} ne "") { $TEXT_COLOR = "text=\"$in{'Text Color*'}\""; } # REPLACE DEFAULT ADDRESS, IF REQUIRED $special_field = "Recipient Address"; if ($in{'Recipient Address'} ne "") { $ADDRESS = "$in{'Recipient Address'}"; $ADDRESS = &fixAntiSpamEmail ($ADDRESS); &emailCheck ($ADDRESS); } elsif ($in{'Recipient Address*'} ne "") { $ADDRESS = "$in{'Recipient Address*'}"; $ADDRESS = &fixAntiSpamEmail ($ADDRESS); &emailCheck ($ADDRESS); } # REPLACE DEFAULT EMAIL ADDRESS, IF REQUIRED $special_field = "Email Address"; if ($in{'Email Address'} ne "") { $EMAIL_ADDRESS = "$in{'Email Address'}"; $EMAIL_ADDRESS = &fixAntiSpamEmail ($EMAIL_ADDRESS); &emailCheck ($EMAIL_ADDRESS); } elsif ($in{'Email Address*'} ne "") { $EMAIL_ADDRESS = "$in{'Email Address*'}"; $EMAIL_ADDRESS = &fixAntiSpamEmail ($EMAIL_ADDRESS); &emailCheck ($EMAIL_ADDRESS); } # REPLACE DEFAULT FULL NAME, IF REQUIRED $exclude = 0; if ($in{'Full Name'} ne "") { $FULL_NAME = "$in{'Full Name'}"; } elsif ($in{'Full Name*'} ne "") { $FULL_NAME = "$in{'Full Name*'}"; } if ($FULL_NAME =~ /^exclude;/) { $FULL_NAME =~ s/^exclude;//; $exclude = 1; } # REPLACE DEFAULT CC ADDRESS, IF REQUIRED $special_field = "Cc Address"; if ($in{'Cc Address'} ne "") { $COPY_ADDRESS = "$in{'Cc Address'}"; $COPY_ADDRESS = &fixAntiSpamEmail ($COPY_ADDRESS); &emailCheck ($COPY_ADDRESS); $COPY_FLAG = 1; } elsif ($in{'Cc Address*'} ne "") { $COPY_ADDRESS = "$in{'Cc Address*'}"; $COPY_ADDRESS = &fixAntiSpamEmail ($COPY_ADDRESS); &emailCheck ($COPY_ADDRESS); $COPY_FLAG = 1; } # REPLACE DEFAULT AUTO CC VALUE, IF REQUIRED if ($in{'Auto Cc'} ne "") { $AUTO_COPY = "$in{'Auto Cc'}"; } elsif ($in{'Auto Cc*'} ne "") { $AUTO_COPY = "$in{'Auto Cc*'}"; } if ($AUTO_COPY eq "Yes") { if ($COPY_FLAG == 1){ $COPY_ADDRESS .= ", "; } $COPY_ADDRESS .= $EMAIL_ADDRESS; } # REPLACE DEFAULT SUBJECT, IF REQUIRED if ($in{'Email Subject Line'} ne "") { $SUBJECT = "$in{'Email Subject Line'}"; } elsif ($in{'Email Subject Line*'} ne "") { $SUBJECT = "$in{'Email Subject Line*'}"; } # REPLACE DEFAULT TITLE, IF REQUIRED if ($in{'Response Page Title'} ne "") { $TITLE = "$in{'Response Page Title'}"; } elsif ($in{'Response Page Title*'} ne "") { $TITLE = "$in{'Response Page Title*'}"; } # REPLACE DEFAULT TOGGLE GRAPHICS VALUE, IF REQUIRED if ($in{'Toggle Graphics'} ne "") { $TOGGLE_GRAPHICS = "$in{'Toggle Graphics'}"; } elsif ($in{'Toggle Graphics*'} ne "") { $TOGGLE_GRAPHICS = "$in{'Toggle Graphics*'}"; } # REPLACE DEFAULT GRAPHIC, IF REQUIRED if ($in{'Graphic'} ne "") { $GRAPHIC_URL = "$in{'Graphic'}"; } elsif ($in{'Graphic*'} ne "") { $GRAPHIC_URL = "$in{'Graphic*'}"; } $GRAPHIC = ""; # REPLACE DEFAULT REQUIRED GRAPHIC, IF REQUIRED if ($in{'Required Graphic'} ne "") { $REQUIRED_URL = "$in{'Required Graphic'}"; } elsif ($in{'Required Graphic*'} ne "") { $REQUIRED_URL = "$in{'Required Graphic*'}"; } $REQUIRED_GRAPHIC = ""; # REPLACE DEFAULT MAGIC WORD, IF REQUIRED if ($in{'Magic Word'} ne "") { $MAGIC = "$in{'Magic Word'}"; } elsif ($in{'Magic Word*'} ne "") { $MAGIC = "$in{'Magic Word*'}"; } # REPLACE DEFAULT SHOW BLANKS, IF REQUIRED if ($in{'Show Blanks'} ne "") { $SHOW_BLANKS = "$in{'Show Blanks'}"; } elsif ($in{'Show Blanks*'} ne "") { $SHOW_BLANKS = "$in{'Show Blanks*'}"; } $display_blanks = 0; if ($SHOW_BLANKS eq "No") { $display_blanks = 1; } # REPLACE DEFAULT SHOW RESULTS, IF REQUIRED if ($in{'Show Results'} ne "") { $SHOW_RESULTS = "$in{'Show Results'}"; } elsif ($in{'Show Results*'} ne "") { $SHOW_RESULTS = "$in{'Show Results*'}"; } # REPLACE DEFAULT DEBUG FLAG, IF REQUIRED if ($in{'Debug Flag'} ne "") { $DEBUG_FLAG = "$in{'Debug Flag'}"; } elsif ($in{'Debug Flag*'} ne "") { $DEBUG_FLAG = "$in{'Debug Flag*'}"; } # REPLACE DEFAULT EMAIL HTML, IF REQUIRED if ($in{'Email HTML'} ne "") { $EMAIL_HTML = "$in{'Email HTML'}"; } elsif ($in{'Email HTML*'} ne "") { $EMAIL_HTML = "$in{'Email HTML*'}"; } # REPLACE DEFAULT RETURN URL, IF REQUIRED if ($in{'Return URL'} ne "") { $RETURN_URL = "$in{'Return URL'}"; } elsif ($in{'Return URL*'} ne "") { $RETURN_URL = "$in{'Return URL*'}"; } # REPLACE DEFAULT RETURN_LINK_TEXT, IF REQUIRED if ($in{'Return Link Text'} ne "") { $RETURN_LINK_TEXT = "$in{'Return Link Text'}"; } elsif ($in{'Return Link Text*'} ne "") { $RETURN_LINK_TEXT = "$in{'Return Link Text*'}"; } # REPLACE DEFAULT GREETING, IF REQUIRED if ($in{'Greeting'} ne "") { $in{'Greeting'} =~ s/\*/

    /g; $GREETING = "$in{'Greeting'}"; } elsif ($in{'Greeting*'} ne "") { $in{'Greeting'} =~ s/\*/

    /g; $GREETING = "$in{'Greeting*'}"; } # End default replacements } sub helpFile { # Subroutine that prints out the Help page if ($ignoreHttpAllowedList == 1) { $referer_checking_status = "Disabled"; } else { $referer_checking_status = "Enabled"; } print <<"help_file"; $TITLE

    Mail Form Handler Built-In Help


    Version

    Version $version

    Overview

    The Mail Form Handler ($script_filename) is a generic CGI script designed to email HTML form input to a specified user or users. All your forms can point to a single instance of the script because the script can support any number of HTML forms while providing customizable output for each.

    Detailed help, including functional descriptions of each special form field, is available at the Mail Form Handler home page.

    Sendmail Location

    $sendmail_bin

    HTTP Referer Checking

    HTTP referer checking is $referer_checking_status.

    Special Form Field Default Values

    Special Field Name Default Value
    Recipient Address $DEF_ADDRESS
    Email Address $DEF_EMAIL_ADDRESS
    Cc Address $DEF_COPY_ADDRESS
    Auto Cc $DEF_AUTO_COPY
    Full Name $DEF_FULL_NAME
    Email Subject Line $DEF_SUBJECT
    Email HTML $DEF_EMAIL_HTML
    Background Color $DEF_BKGD_COLOR
    Link Color $DEF_LINK_COLOR
    ActiveLink Color $DEF_ALINK_COLOR
    VisitedLink Color $DEF_VLINK_COLOR
    Text Color $DEF_TEXT_COLOR
    Toggle Graphics $DEF_TOGGLE_GRAPHICS
    Required Graphic $DEF_REQUIRED_URL
    Graphic $DEF_GRAPHIC_URL
    Magic Word $DEF_MAGIC
    Response Page Title $DEF_TITLE
    Greeting $DEF_GREETING
    Return URL $DEF_RETURN_URL
    Return Link Text $DEF_RETURN_LINK_TEXT
    Show Results $DEF_SHOW_RESULTS
    Show Blanks $DEF_SHOW_BLANKS

    Credits

    Mail Form Handler $version ($script_filename) by Tim Stevenson
    Generic HTML form-processing CGI script
    Send bug reports, feature requests, and other correspondence to tstevens at employees.org
    Visit the Mail Form Handler home page.

    ReadParse subroutine by Steven E. Brenner

    This script may be distributed freely as long as this message remains intact.

    Disclaimer

    The Mail Form Handler is provided as-is. I shall not be held responsible for its performance, nor the manner of its use by another party, in any respect.

    In addition, use of this script is subject to the privacy and usage policy posted on the Mail Form Handler home page. help_file &footerCode; print "\n"; print "\n\n"; } sub footerCode { # Subroutine that prints out the page footer print <<"footer_end";


    This page dynamically generated by the Mail Form Handler $version ($script_filename), by Tim Stevenson.
    For more information about this script, visit http://$server$script_path

    footer_end } sub emailFooterCode { # Subroutine that prints out the page footer print EMAIL <<"footer_end";


    This email dynamically generated by the Mail Form Handler $version ($script_filename), by Tim Stevenson.
    For more information about this script, visit http://$server$script_path

    footer_end }