home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 April / comcd0402.iso / homepage / artikel / hp11_01 / formulare / FormMail.pl < prev    next >
Encoding:
Perl Script  |  2001-08-02  |  25.8 KB  |  681 lines

  1. #!/usr/bin/perl
  2. ##############################################################################
  3. # FormMail                        Version 1.9                                #
  4. # Copyright 1995-2001 Matt Wright mattw@worldwidemart.com                    #
  5. # Created 06/09/95                Last Modified 08/03/01                     #
  6. # Matt's Script Archive, Inc.:    http://www.worldwidemart.com/scripts/      #
  7. ##############################################################################
  8. # COPYRIGHT NOTICE                                                           #
  9. # Copyright 1995-2001 Matthew M. Wright  All Rights Reserved.                #
  10. #                                                                            #
  11. # FormMail may be used and modified free of charge by anyone so long as this #
  12. # copyright notice and the comments above remain intact.  By using this      #
  13. # code you agree to indemnify Matthew M. Wright from any liability that      #
  14. # might arise from its use.                                                  #
  15. #                                                                            #
  16. # Selling the code for this program without prior written consent is         #
  17. # expressly forbidden.  In other words, please ask first before you try and  #
  18. # make money off of my program.                                              #
  19. #                                                                            #
  20. # Obtain permission before redistributing this software over the Internet or #
  21. # in any other medium.    In all cases copyright and header must remain intact #
  22. ##############################################################################
  23. # ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
  24. #                     http://www.securityfocus.com/archive/1/62033           #
  25. ##############################################################################
  26. # Define Variables                                                           #
  27. #     Detailed Information Found In README File.                          #
  28.  
  29. # $mailprog defines the location of your sendmail program on your unix       #
  30. # system.                                                                    #
  31.  
  32. $mailprog = '/usr/lib/sendmail';
  33.  
  34. # @referers allows forms to be located only on servers which are defined     #
  35. # in this field.  This security fix from the last version which allowed      #
  36. # anyone on any server to use your FormMail script on their web site.        #
  37.  
  38. @referers = ('worldwidemart.com','206.31.72.203');
  39.  
  40. # @recipients defines the e-mail addresses or domain names that e-mail can   #
  41. # be sent to.  This must be filled in correctly to prevent SPAM and allow    #
  42. # valid addresses to receive e-mail.  Read the documentation to find out how #
  43. # this variable works!!!  It is EXTREMELY IMPORTANT.                         #
  44. @recipients = @referers;
  45.  
  46. # ACCESS CONTROL FIX: Peter D. Thompson Yezek                                #
  47. # @valid_ENV allows the sysadmin to define what environment variables can    #
  48. # be reported via the env_report directive.  This was implemented to fix     #
  49. # the problem reported at http://www.securityfocus.com/bid/1187              #
  50.  
  51. @valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
  52.  
  53. # Done                                                                       #
  54. ##############################################################################
  55.  
  56. # Check Referring URL
  57. &check_url;
  58.  
  59. # Retrieve Date
  60. &get_date;
  61.  
  62. # Parse Form Contents
  63. &parse_form;
  64.  
  65. # Check Required Fields
  66. &check_required;
  67.  
  68. # Send E-Mail
  69. &send_mail;
  70.  
  71. # Return HTML Page or Redirect User
  72. &return_html;
  73.  
  74. sub check_url {
  75.  
  76.     # Localize the check_referer flag which determines if user is valid.     #
  77.     local($check_referer) = 0;
  78.  
  79.     # If a referring URL was specified, for each valid referer, make sure    #
  80.     # that a valid referring URL was passed to FormMail.                     #
  81.  
  82.     if ($ENV{'HTTP_REFERER'}) {
  83.         foreach $referer (@referers) {
  84.             if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
  85.                 $check_referer = 1;
  86.                 last;
  87.             }
  88.         }
  89.     }
  90.     else {
  91.         $check_referer = 1;
  92.     }
  93.  
  94.     # If the HTTP_REFERER was invalid, send back an error.                   #
  95.     if ($check_referer != 1) { &error('bad_referer') }
  96. }
  97.  
  98. sub get_date {
  99.  
  100.     # Define arrays for the day of the week and month of the year.           #
  101.     @days   = ('Sunday','Monday','Tuesday','Wednesday',
  102.                'Thursday','Friday','Saturday');
  103.     @months = ('January','February','March','April','May','June','July',
  104.              'August','September','October','November','December');
  105.  
  106.     # Get the current time and format the hour, minutes and seconds.  Add    #
  107.     # 1900 to the year to get the full 4 digit year.                         #
  108.     ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
  109.     $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec);
  110.     $year += 1900;
  111.  
  112.     # Format the date.                                                       #
  113.     $date = "$days[$wday], $months[$mon] $mday, $year at $time";
  114.  
  115. }
  116.  
  117. sub parse_form {
  118.  
  119.     # Define the configuration associative array.                            #
  120.     %Config = ('recipient','',          'subject','',
  121.                'email','',              'realname','',
  122.                'redirect','',           'bgcolor','',
  123.                'background','',         'link_color','',
  124.                'vlink_color','',        'text_color','',
  125.                'alink_color','',        'title','',
  126.                'sort','',               'print_config','',
  127.                'required','',           'env_report','',
  128.                'return_link_title','',  'return_link_url','',
  129.                'print_blank_fields','', 'missing_fields_redirect','');
  130.  
  131.     # Determine the form's REQUEST_METHOD (GET or POST) and split the form   #
  132.     # fields up into their name-value pairs.  If the REQUEST_METHOD was      #
  133.     # not GET or POST, send an error.                                        #
  134.     if ($ENV{'REQUEST_METHOD'} eq 'GET') {
  135.         # Split the name-value pairs
  136.         @pairs = split(/&/, $ENV{'QUERY_STRING'});
  137.     }
  138.     elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
  139.         # Get the input
  140.         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  141.  
  142.         # Split the name-value pairs
  143.         @pairs = split(/&/, $buffer);
  144.     }
  145.     else {
  146.         &error('request_method');
  147.     }
  148.  
  149.     # For each name-value pair:                                              #
  150.     foreach $pair (@pairs) {
  151.  
  152.         # Split the pair up into individual variables.                       #
  153.         local($name, $value) = split(/=/, $pair);
  154.  
  155.         # Decode the form encoding on the name and value variables.          #
  156.         $name =~ tr/+/ /;
  157.         $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  158.  
  159.         $value =~ tr/+/ /;
  160.         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  161.  
  162.         # If they try to include server side includes, erase them, so they
  163.         # aren't a security risk if the html gets returned.  Another 
  164.         # security hole plugged up.
  165.         $value =~ s/<!--(.|\n)*-->//g;
  166.  
  167.         # If the field name has been specified in the %Config array, it will #
  168.         # return a 1 for defined($Config{$name}}) and we should associate    #
  169.         # this value with the appropriate configuration variable.  If this   #
  170.         # is not a configuration form field, put it into the associative     #
  171.         # array %Form, appending the value with a ', ' if there is already a #
  172.         # value present.  We also save the order of the form fields in the   #
  173.         # @Field_Order array so we can use this order for the generic sort.  #
  174.         if (defined($Config{$name})) {
  175.             $Config{$name} = $value;
  176.         }
  177.         else {
  178.             if ($Form{$name} && $value) {
  179.                 $Form{$name} = "$Form{$name}, $value";
  180.             }
  181.             elsif ($value) {
  182.                 push(@Field_Order,$name);
  183.                 $Form{$name} = $value;
  184.             }
  185.         }
  186.     }
  187.  
  188.     # The next six lines remove any extra spaces or new lines from the       #
  189.     # configuration variables, which may have been caused if your editor     #
  190.     # wraps lines after a certain length or if you used spaces between field #
  191.     # names or environment variables.                                        #
  192.     $Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  193.     $Config{'required'} =~ s/(\s+)?\n+(\s+)?//g;
  194.     $Config{'env_report'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  195.     $Config{'env_report'} =~ s/(\s+)?\n+(\s+)?//g;
  196.     $Config{'print_config'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  197.     $Config{'print_config'} =~ s/(\s+)?\n+(\s+)?//g;
  198.  
  199.     # Split the configuration variables into individual field names.         #
  200.     @Required = split(/,/,$Config{'required'});
  201.     @Env_Report = split(/,/,$Config{'env_report'});
  202.     @Print_Config = split(/,/,$Config{'print_config'});
  203.  
  204.     # ACCESS CONTROL FIX: Only allow ENV variables in @valid_ENV in          #
  205.     # @Env_Report for security reasons.                                      #
  206.     foreach $env_item (@Env_Report) {
  207.         foreach $valid_item (@valid_ENV) {
  208.             if ( $env_item eq $valid_item ) { push(@temp_array, $env_item) }
  209.         }
  210.     } 
  211.     @Env_Report = @temp_array;
  212. }
  213.  
  214. sub check_required {
  215.  
  216.     # Localize the variables used in this subroutine.                        #
  217.     local($require, @error);
  218.  
  219.     if ($Config{'subject'} =~ /(\n|\r)/m || 
  220.         $Config{'recipient'} =~ /(\n|\r)/m) {
  221.         &error('no_recipient');
  222.     }
  223.  
  224.     if (!$Config{'recipient'}) {
  225.         if (!defined(%Form)) { &error('bad_referer') }
  226.         else                 { &error('no_recipient') }
  227.     }
  228.     else {
  229.         # This block of code requires that the recipient address end with    #
  230.         # a valid domain or e-mail address as defined in @recipients.        #
  231.         $valid_recipient = 0;
  232.         foreach $send_to (split(/,/,$Config{'recipient'})) {
  233.             foreach $recipient (@recipients) {
  234.                 if ($send_to =~ /$recipient$/i) {
  235.                     push(@send_to,$send_to); last;
  236.                 }
  237.             }
  238.         }
  239.         if ($#send_to < 0) { &error('no_recipient') }
  240.         $Config{'recipient'} = join(',',@send_to);
  241.     }
  242.  
  243.     # For each require field defined in the form:                            #
  244.     foreach $require (@Required) {
  245.  
  246.         # If the required field is the email field, the syntax of the email  #
  247.         # address if checked to make sure it passes a valid syntax.          #
  248.         if ($require eq 'email' && !&check_email($Config{$require})) {
  249.             push(@error,$require);
  250.         }
  251.  
  252.         # Otherwise, if the required field is a configuration field and it   #
  253.         # has no value or has been filled in with a space, send an error.    #
  254.         elsif (defined($Config{$require})) {
  255.             if (!$Config{$require}) {
  256.                 push(@error,$require);
  257.             }
  258.         }
  259.  
  260.         # If it is a regular form field which has not been filled in or      #
  261.         # filled in with a space, flag it as an error field.                 #
  262.         elsif (!$Form{$require}) {
  263.             push(@error,$require);
  264.         }
  265.     }
  266.  
  267.     # If any error fields have been found, send error message to the user.   #
  268.     if (@error) { &error('missing_fields', @error) }
  269. }
  270.  
  271. sub return_html {
  272.     # Local variables used in this subroutine initialized.                   #
  273.     local($key,$sort_order,$sorted_field);
  274.  
  275.     # If redirect option is used, print the redirectional location header.   #
  276.     if ($Config{'redirect'}) {
  277.         print "Location: $Config{'redirect'}\n\n";
  278.     }
  279.  
  280.     # Otherwise, begin printing the response page.                           #
  281.     else {
  282.  
  283.         # Print HTTP header and opening HTML tags.                           #
  284.         print "Content-type: text/html\n\n";
  285.         print "<html>\n <head>\n";
  286.  
  287.         # Print out title of page                                            #
  288.         if ($Config{'title'}) { print "  <title>$Config{'title'}</title>\n" }
  289.         else                  { print "  <title>Thank You</title>\n"        }
  290.  
  291.         print " </head>\n <body";
  292.  
  293.         # Get Body Tag Attributes                                            #
  294.         &body_attributes;
  295.  
  296.         # Close Body Tag                                                     #
  297.         print ">\n  <center>\n";
  298.  
  299.         # Print custom or generic title.                                     #
  300.         if ($Config{'title'}) { print "   <h1>$Config{'title'}</h1>\n" }
  301.         else { print "   <h1>Thank You For Filling Out This Form</h1>\n" }
  302.  
  303.         print "</center>\n";
  304.  
  305.         print "Below is what you submitted to $Config{'recipient'} on ";
  306.         print "$date<p><hr size=1 width=75\%><p>\n";
  307.  
  308.         # Sort alphabetically if specified:                                  #
  309.         if ($Config{'sort'} eq 'alphabetic') {
  310.             foreach $field (sort keys %Form) {
  311.  
  312.                 # If the field has a value or the print blank fields option  #
  313.                 # is turned on, print out the form field and value.          #
  314.                 if ($Config{'print_blank_fields'} || $Form{$field}) {
  315.                     print "<b>$field:</b> $Form{$field}<p>\n";
  316.                 }
  317.             }
  318.         }
  319.  
  320.         # If a sort order is specified, sort the form fields based on that.  #
  321.         elsif ($Config{'sort'} =~ /^order:.*,.*/) {
  322.  
  323.             # Set the temporary $sort_order variable to the sorting order,   #
  324.             # remove extraneous line breaks and spaces, remove the order:    #
  325.             # directive and split the sort fields into an array.             #
  326.             $sort_order = $Config{'sort'};
  327.             $sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  328.             $sort_order =~ s/(\s+)?\n+(\s+)?//g;
  329.             $sort_order =~ s/order://;
  330.             @sorted_fields = split(/,/, $sort_order);
  331.  
  332.             # For each sorted field, if it has a value or the print blank    #
  333.             # fields option is turned on print the form field and value.     #
  334.             foreach $sorted_field (@sorted_fields) {
  335.                 if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
  336.                     print "<b>$sorted_field:</b> $Form{$sorted_field}<p>\n";
  337.                 }
  338.             }
  339.         }
  340.  
  341.         # Otherwise, default to the order in which the fields were sent.     #
  342.         else {
  343.  
  344.             # For each form field, if it has a value or the print blank      #
  345.             # fields option is turned on print the form field and value.     #
  346.             foreach $field (@Field_Order) {
  347.                 if ($Config{'print_blank_fields'} || $Form{$field}) {
  348.                     print "<b>$field:</b> $Form{$field}<p>\n";
  349.                 }
  350.             }
  351.         }
  352.  
  353.         print "<p><hr size=1 width=75%><p>\n";
  354.  
  355.         # Check for a Return Link and print one if found.                    #
  356.         if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
  357.             print "<ul>\n";
  358.             print "<li><a href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
  359.             print "</ul>\n";
  360.         }
  361.  
  362.         # Print the page footer.                                             #
  363.         print <<"(END HTML FOOTER)";
  364.         <hr size=1 width=75%><p> 
  365.         <center><font size=-1><a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9 © 1995 - 2001  Matt Wright<br>
  366. A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a></font></center>
  367.         </body>
  368.        </html>
  369. (END HTML FOOTER)
  370.     }
  371. }
  372.  
  373. sub send_mail {
  374.     # Localize variables used in this subroutine.                            #
  375.     local($print_config,$key,$sort_order,$sorted_field,$env_report);
  376.  
  377.     # Open The Mail Program
  378.     open(MAIL,"|$mailprog -t");
  379.  
  380.     print MAIL "To: $Config{'recipient'}\n";
  381.     print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
  382.  
  383.     # Check for Message Subject
  384.     if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  385.     else                    { print MAIL "Subject: WWW Form Submission\n\n" }
  386.  
  387.     print MAIL "Below is the result of your feedback form.  It was submitted by\n";
  388.     print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  389.     print MAIL "-" x 75 . "\n\n";
  390.  
  391.     if (@Print_Config) {
  392.         foreach $print_config (@Print_Config) {
  393.             if ($Config{$print_config}) {
  394.                 print MAIL "$print_config: $Config{$print_config}\n\n";
  395.             }
  396.         }
  397.     }
  398.  
  399.     # Sort alphabetically if specified:                                      #
  400.     if ($Config{'sort'} eq 'alphabetic') {
  401.         foreach $field (sort keys %Form) {
  402.  
  403.             # If the field has a value or the print blank fields option      #
  404.             # is turned on, print out the form field and value.              #
  405.             if ($Config{'print_blank_fields'} || $Form{$field} ||
  406.                 $Form{$field} eq '0') {
  407.                 print MAIL "$field: $Form{$field}\n\n";
  408.             }
  409.         }
  410.     }
  411.  
  412.     # If a sort order is specified, sort the form fields based on that.      #
  413.     elsif ($Config{'sort'} =~ /^order:.*,.*/) {
  414.  
  415.         # Remove extraneous line breaks and spaces, remove the order:        #
  416.         # directive and split the sort fields into an array.                 #
  417.         $Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
  418.         $Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
  419.         $Config{'sort'} =~ s/order://;
  420.         @sorted_fields = split(/,/, $Config{'sort'});
  421.  
  422.         # For each sorted field, if it has a value or the print blank        #
  423.         # fields option is turned on print the form field and value.         #
  424.         foreach $sorted_field (@sorted_fields) {
  425.             if ($Config{'print_blank_fields'} || $Form{$sorted_field} ||
  426.                 $Form{$sorted_field} eq '0') {
  427.                 print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
  428.             }
  429.         }
  430.     }
  431.  
  432.     # Otherwise, default to the order in which the fields were sent.         #
  433.     else {
  434.  
  435.         # For each form field, if it has a value or the print blank          #
  436.         # fields option is turned on print the form field and value.         #
  437.         foreach $field (@Field_Order) {
  438.             if ($Config{'print_blank_fields'} || $Form{$field} ||
  439.                 $Form{$field} eq '0') {
  440.                 print MAIL "$field: $Form{$field}\n\n";
  441.             }
  442.         }
  443.     }
  444.  
  445.     print MAIL "-" x 75 . "\n\n";
  446.  
  447.     # Send any specified Environment Variables to recipient.                 #
  448.     foreach $env_report (@Env_Report) {
  449.         if ($ENV{$env_report}) {
  450.             print MAIL "$env_report: $ENV{$env_report}\n";
  451.         }
  452.     }
  453.  
  454.     close (MAIL);
  455. }
  456.  
  457. sub check_email {
  458.     # Initialize local email variable with input to subroutine.              #
  459.     $email = $_[0];
  460.  
  461.     # If the e-mail address contains:                                        #
  462.     if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
  463.  
  464.         # the e-mail address contains an invalid syntax.  Or, if the         #
  465.         # syntax does not match the following regular expression pattern     #
  466.         # it fails basic syntax verification.                                #
  467.  
  468.         $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/) {
  469.  
  470.         # Basic syntax requires:  one or more characters before the @ sign,  #
  471.         # followed by an optional '[', then any number of letters, numbers,  #
  472.         # dashes or periods (valid domain/IP characters) ending in a period  #
  473.         # and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers    #
  474.         # (for IP addresses).  An ending bracket is also allowed as it is    #
  475.         # valid syntax to have an email address like: user@[255.255.255.0]   #
  476.  
  477.         # Return a false value, since the e-mail address did not pass valid  #
  478.         # syntax.                                                            #
  479.         return 0;
  480.     }
  481.  
  482.     else {
  483.  
  484.         # Return a true value, e-mail verification passed.                   #
  485.         return 1;
  486.     }
  487. }
  488.  
  489. sub body_attributes {
  490.     # Check for Background Color
  491.     if ($Config{'bgcolor'}) { print " bgcolor=\"$Config{'bgcolor'}\"" }
  492.  
  493.     # Check for Background Image
  494.     if ($Config{'background'}) { print " background=\"$Config{'background'}\"" }
  495.  
  496.     # Check for Link Color
  497.     if ($Config{'link_color'}) { print " link=\"$Config{'link_color'}\"" }
  498.  
  499.     # Check for Visited Link Color
  500.     if ($Config{'vlink_color'}) { print " vlink=\"$Config{'vlink_color'}\"" }
  501.  
  502.     # Check for Active Link Color
  503.     if ($Config{'alink_color'}) { print " alink=\"$Config{'alink_color'}\"" }
  504.  
  505.     # Check for Body Text Color
  506.     if ($Config{'text_color'}) { print " text=\"$Config{'text_color'}\"" }
  507. }
  508.  
  509. sub error { 
  510.     # Localize variables and assign subroutine input.                        #
  511.     local($error,@error_fields) = @_;
  512.     local($host,$missing_field,$missing_field_list);
  513.  
  514.     if ($error eq 'bad_referer') {
  515.         if ($ENV{'HTTP_REFERER'} =~ m|^https?://([\w\.]+)|i) {
  516.             $host = $1;
  517.             print <<"(END ERROR HTML)";
  518. Content-type: text/html
  519.  
  520. <html>
  521.  <head>
  522.   <title>Bad Referrer - Access Denied</title>
  523.  </head>
  524.  <body bgcolor=#FFFFFF text=#000000>
  525.   <center>
  526.    <table border=0 width=600 bgcolor=#9C9C9C>
  527.     <tr><th><font size=+2>Bad Referrer - Access Denied</font></th></tr>
  528.    </table>
  529.    <table border=0 width=600 bgcolor=#CFCFCF>
  530.     <tr><td>The form attempting to use
  531.      <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a>
  532.      resides at <tt>$ENV{'HTTP_REFERER'}</tt>, which is not allowed to access
  533.      this cgi script.<p>
  534.  
  535.      If you are attempting to configure FormMail to run with this form, you need
  536.      to add the following to \@referers, explained in detail in the README file.<p>
  537.  
  538.      Add <tt>'$host'</tt> to your <tt><b>\@referers</b></tt> array.<hr size=1>
  539.      <center><font size=-1>
  540.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9 © 1995 - 2001  Matt Wright<br>
  541.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  542.      </font></center>
  543.     </td></tr>
  544.    </table>
  545.   </center>
  546.  </body>
  547. </html>
  548. (END ERROR HTML)
  549.         }
  550.         else {
  551.             print <<"(END ERROR HTML)";
  552. Content-type: text/html
  553.  
  554. <html>
  555.  <head>
  556.   <title>FormMail v1.9</title>
  557.  </head>
  558.  <body bgcolor=#FFFFFF text=#000000>
  559.   <center>
  560.    <table border=0 width=600 bgcolor=#9C9C9C>
  561.     <tr><th><font size=+2>FormMail</font></th></tr>
  562.    </table>
  563.    <table border=0 width=600 bgcolor=#CFCFCF>
  564.     <tr><th><tt><font size=+1>Copyright 1995 - 2001 Matt Wright<br>
  565.         Version 1.9 - Released August 3, 2001<br>
  566.         A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive,
  567.         Inc.</a></font></tt></th></tr>
  568.    </table>
  569.   </center>
  570.  </body>
  571. </html>
  572. (END ERROR HTML)
  573.         }
  574.     }
  575.  
  576.     elsif ($error eq 'request_method') {
  577.             print <<"(END ERROR HTML)";
  578. Content-type: text/html
  579.  
  580. <html>
  581.  <head>
  582.   <title>Error: Request Method</title>
  583.  </head>
  584.  <body bgcolor=#FFFFFF text=#000000>
  585.   <center>
  586.    <table border=0 width=600 bgcolor=#9C9C9C>
  587.     <tr><th><font size=+2>Error: Request Method</font></th></tr>
  588.    </table>
  589.    <table border=0 width=600 bgcolor=#CFCFCF>
  590.     <tr><td>The Request Method of the Form you submitted did not match
  591.      either <tt>GET</tt> or <tt>POST</tt>.  Please check the form and make sure the
  592.      <tt>method=</tt> statement is in upper case and matches <tt>GET</tt> or <tt>POST</tt>.<p>
  593.  
  594.      <center><font size=-1>
  595.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9 © 1995 - 2001  Matt Wright<br>
  596.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  597.      </font></center>
  598.     </td></tr>
  599.    </table>
  600.   </center>
  601.  </body>
  602. </html>
  603. (END ERROR HTML)
  604.     }
  605.  
  606.     elsif ($error eq 'no_recipient') {
  607.             print <<"(END ERROR HTML)";
  608. Content-type: text/html
  609.  
  610. <html>
  611.  <head>
  612.   <title>Error: Bad/No Recipient</title>
  613.  </head>
  614.  <body bgcolor=#FFFFFF text=#000000>
  615.   <center>
  616.    <table border=0 width=600 bgcolor=#9C9C9C>
  617.     <tr><th><font size=+2>Error: Bad/No Recipient</font></th></tr>
  618.    </table>
  619.    <table border=0 width=600 bgcolor=#CFCFCF>
  620.     <tr><td>There was no recipient or an invalid recipient specified in the data sent to FormMail.  Please
  621.      make sure you have filled in the <tt>recipient</tt> form field with an e-mail
  622.      address that has been configured in <tt>\@recipients</tt>.  More information on filling in <tt>recipient</tt> form fields and variables can be
  623.      found in the README file.<hr size=1>
  624.  
  625.      <center><font size=-1>
  626.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9 © 1995 - 2001  Matt Wright<br>
  627.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  628.      </font></center>
  629.     </td></tr>
  630.    </table>
  631.   </center>
  632.  </body>
  633. </html>
  634. (END ERROR HTML)
  635.     }
  636.  
  637.     elsif ($error eq 'missing_fields') {
  638.         if ($Config{'missing_fields_redirect'}) {
  639.             print "Location: $Config{'missing_fields_redirect'}\n\n";
  640.         }
  641.         else {
  642.             foreach $missing_field (@error_fields) {
  643.                 $missing_field_list .= "      <li>$missing_field\n";
  644.             }
  645.  
  646.             print <<"(END ERROR HTML)";
  647. Content-type: text/html
  648.  
  649. <html>
  650.  <head>
  651.   <title>Error: Blank Fields</title>
  652.  </head>
  653.   <center>
  654.    <table border=0 width=600 bgcolor=#9C9C9C>
  655.     <tr><th><font size=+2>Error: Blank Fields</font></th></tr>
  656.    </table>
  657.    <table border=0 width=600 bgcolor=#CFCFCF>
  658.     <tr><td>The following fields were left blank in your submission form:<p>
  659.      <ul>
  660. $missing_field_list
  661.      </ul><br>
  662.  
  663.      These fields must be filled in before you can successfully submit the form.<p>
  664.      Please use your browser's back button to return to the form and try again.<hr size=1>
  665.      <center><font size=-1>
  666.       <a href="http://www.worldwidemart.com/scripts/formmail.shtml">FormMail</a> V1.9 © 1995 - 2001  Matt Wright<br>
  667.       A Free Product of <a href="http://www.worldwidemart.com/scripts/">Matt's Script Archive, Inc.</a>
  668.      </font></center>
  669.     </td></tr>
  670.    </table>
  671.   </center>
  672.  </body>
  673. </html>
  674. (END ERROR HTML)
  675.         }
  676.     }
  677.  
  678.     exit;
  679. }
  680.  
  681.