home *** CD-ROM | disk | FTP | other *** search
/ csi.uticak12.org / csi.uticak12.org.tar / csi.uticak12.org / FormMail / README < prev   
Text File  |  2002-05-16  |  36KB  |  758 lines

  1. ##############################################################################
  2. # FormMail                        Version 1.92                               #
  3. # Copyright 1996-2002 Matt Wright mattw@scriptarchive.com                    #
  4. # Created 06/09/95                Last Modified 04/21/02                     #
  5. # Matt's Script Archive, Inc.:    http://www.scriptarchive.com/              #
  6. ##############################################################################
  7. # If you run into any problems while trying to configure this scripts, help  #
  8. # is available.  The steps you should take to get the fastest results, are:  #
  9. #       1) Read this file thoroughly.                                        #
  10. #       2) Consult the Matt's Script Archive Frequently Asked Questions:     #
  11. #               http://www.scriptarchive.com/faq/                            #
  12. #       3) If you are still having difficulty installing this script,        #
  13. #          you may wish to look at the resources listed here:                #
  14. #               http://www.scriptarchive.com/help/                           #
  15. #                                                                            #
  16. # Hopefully that will be able to help you solve your problems.  Due to time  #
  17. # constraints I can no longer offer technical support for this code.         #
  18. ##############################################################################
  19. # COPYRIGHT NOTICE                                                           #
  20. # Copyright 1995 - 2002 Matthew M. Wright  All Rights Reserved.              #
  21. #                                                                            #
  22. # FormMail may be used and modified free of charge by anyone so long as this #
  23. # copyright notice and the comments above remain intact.  By using this      #
  24. # code you agree to indemnify Matthew M. Wright from any liability that      #
  25. # might arise from its use.                                                  #
  26. #                                                                            #
  27. # Selling the code for this program without prior written consent is         #
  28. # expressly forbidden.  In other words, please ask first before you try and  #
  29. # make money off of my program.                                              #
  30. #                                                                            #
  31. # Obtain permission before redistributing this software over the Internet or #
  32. # in any other medium.    In all cases copyright and header must remain intact #
  33. ##############################################################################
  34.  
  35. FormMail is a universal WWW form to E-mail gateway.  There is only one
  36. required form input tag which must be specified in order for this script to
  37. work with your existing forms.  Other hidden configuration fields can also
  38. be used to enhance the operation of FormMail on your site.  The end of this
  39. file has a history that will explain the various changes FormMail has made
  40. throughout its lifetime.  Version 1.91 was an update attempting to get rid
  41. of the worst problems that have been made public in:
  42.         http://www.monkeys.com/anti-spam/formmail-advisory.pdf
  43. Version 1.92 fixed a couple more bugs, which you can read about in the
  44. history located at the end of this file.
  45.  
  46. The script, FormMail.pl, needs to be placed in your server's cgi-bin and the 
  47. anonymous WWW user must have the ability to read/execute the script.  If 
  48. you do not have access to your server's cgi-bin, yet you can execute cgi 
  49. scripts, you may want to try adding a .cgi extension to the FormMail.pl, 
  50. renaming it to FormMail.cgi. This is probably the more common option.
  51.  
  52. Setting Up the FormMail Script:
  53. ===============================
  54.  
  55. The FormMail.pl script does not have to be extensively configured in order 
  56. to work.  There are only two variables in the perl file which you will 
  57. need to define along with changing the top line of your script to match 
  58. the location of you Perl interpreter.
  59.  
  60. Necessary Variables:
  61. --------------------
  62.  
  63.   $mailprog = '/usr/lib/sendmail -i -t';
  64.     This variable must define the location to your server's sendmail 
  65.     program.  If this is incorrect, form results will not be mailed to you.
  66.     Specifying the parameters in this variable is new in v1.91, and we have
  67.     included the -i parameter so that a single period on a line by itself
  68.     will not end the message. -t instructs sendmail to read the recipient list
  69.     from the message text.
  70.  
  71.   @referers = ('scriptarchive.com','YOUR_IP');
  72.     This array allows you to define the domains one which you allow forms
  73.     to reside and use this installation of FormMail.  If a user tries to 
  74.     put a form on another server, that is not scriptarchive.com, they 
  75.     will receive an error message when someone tries to fill out their form.
  76.     By placing scriptarchive.com in the @referers array, this also allows
  77.     www.scriptarchive.com, ftp.scriptarchive.com, any other http address
  78.     with scriptarchive.com in it and scriptarchive.com's IP address to access
  79.     this script as well, so no users will be turned away.
  80.  
  81.     NOTE: This is not a security check. Referer headers can EASILY be faked.
  82.           Rather, it prevents someone on xyznotyou.com from using the FormMail
  83.           on your server to process forms on their server on a regular basis.
  84.           It remains in the script as a remnant of earlier versions when it
  85.           was used for security, but the @recipients variable is now used
  86.           to specify exactly who can receive e-mail from this installation.
  87.  
  88.     As of version 1.7, the domains listed here are also used as the defaults
  89.     when checking valid recipient e-mail addresses.  You should either
  90.     include all domain names that you wish to have FormMail send e-mails to
  91.     in your @referers array or tailor the @recipients array by hand.
  92.  
  93.   @valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');
  94.     This array allows the administrator to specify a list of environment
  95.     variables that the user may request be added into the e-mail.  This is
  96.     a security patch that was advised at http://www.securityfocus.com/bid/1187
  97.     and was implemented by Peter D. Thompson Yezek at 
  98.     http://www.securityfocus.com/archive/1/62033.
  99.  
  100.     Only environment variables listed in this array may be included in the
  101.     form field env_report.  So if you wanted to also know what URL a user was
  102.     submitting from, you could change @valid_ENV to:
  103.        @valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER',
  104.                      'HTTP_USER_AGENT','HTTP_REFERER');
  105.     and then include HTTP_REFERER in your env_report form field.
  106.  
  107.   @recipients = &fill_recipients(@referers);
  108.     If you wish to only allow e-mail addresses at the domain names in 
  109.     @referers to receive form results, you probably do not need to change this
  110.     variable.  However, if you get any 'Error: Bad/No Recipient' messages when
  111.     running FormMail, you may have to revisit @recipients and make sure you
  112.     have correctly listed all domains or configured this variable.
  113.  
  114.     @recipients is the most important variable you need to configure.  It is an
  115.     array of regular expressions defining all valid recipients that can be 
  116.     specified.  In order for an e-mail to be sent to the recipient defined in
  117.     a form, the recipient e-mail address must match one of the elements in the
  118.     @recipients array.
  119.  
  120.     SIMPLE SETUP:
  121.  
  122.     For the most simple setup, place any domain name that you wish to send
  123.     form results to in the @referers array.  Warning: This allows those domains
  124.     to also access your FormMail script and utilize it to process their own
  125.     forms, but likely this is what you intended anyway.  If so, you can leave:
  126.  
  127.     @recipients = &fill_recipients(@referers);
  128.  
  129.     NO, THAT IS NOT WHAT I INTENDED!
  130.  
  131.     Another alternative, then, is to set @recipients equal to the return value
  132.     of the fill-recipients function and pass this function all of the domains
  133.     to which e-mail may be addressed:
  134.  
  135.     @recipients = &fill_recipients('domain.com','sub.domain.com','another.com');
  136.  
  137.     You are now allowing e-mail to any username (provided it contains only A-Z,
  138.     a-z, 0-9, _, - or .) at those three domains.
  139.  
  140.     Similarly, since @recipients is just an array, you could even do:
  141.  
  142.     @recipients = (&fill_recipients('domain.com','sub.domain.com'),
  143.                    '^otheruser1@otherhost\.com','^otheruser2@otherhost\.com');
  144.  
  145.     This would allow any recipient at domain.com and sub.domain.com similar
  146.     to the previous example, but would also allow your friends otheruser1 and
  147.     otheruser2 on otherhost.com to use your FormMail! Of course, you will need
  148.     to add otherhost.com into your @referers array if a form is on their host!
  149.  
  150.     HOW DOES THAT WORK?
  151.  
  152.     When the fill_recipients function is called on an array of domain names,
  153.     it turns them into regular expressions. These regular expressions will only
  154.     allow e-mail messages to go to a recipient with an e-mail address in the
  155.     following format:
  156.  
  157.         [A-Za-z0-9_-\.]+@domain.com
  158.  
  159.     where domain.com is specified in @referers. For any IP addresses
  160.     in @referers, the following address formats are valid:
  161.  
  162.         [A-Za-z0-9_-\.]+@[192.168.1.1]
  163.  
  164.     where 192.168.1.1 is the specified IP address in @referers.
  165.  
  166.     What this means in english is that the only valid addresses are those
  167.     to usernames that include only letters, numbers, underscores, dashes or 
  168.     periods and an exact domain name or IP address that was specified in the
  169.     @referers array.  Depending on your needs, this may be too broad or not
  170.     broad enough.
  171.  
  172.     WHAT IF YOU NEED MORE FLEXIBILITY??
  173.  
  174.     The way FormMail validates a recipient address is to check the supplied
  175.     recipient(s) in the submitted form against each element in the array
  176.     @recipients (which is a list of Perl regular expressions). If any valid
  177.     recipients are found, they will receive a copy of the message.
  178.  
  179.     Using the examples of @referers = ('domain.com','192.168.1.1'); and the
  180.     default usage of setting @recipients = &fill_recipients(@referers), the
  181.     contents of @recipients are now the same as if you had written:
  182.  
  183.     @recipients = ('^[\w\-\.]+\@domain\.com', '^[\w\-\.]+\@\[192\.168\.1\.1\]');
  184.  
  185.     What these regular expressions instruct FormMail to do is require that any
  186.     e-mail address passed in as a recipient of the form submission match at
  187.     least one of those two formats. The following are examples of valid
  188.     and invalid recipients for this exact setup:
  189.  
  190.        VALID:
  191.          user@domain.com, First.Last@domain.com, Last-First@domain.com
  192.          user_name@domain.com, user023@domain.com, etc.
  193.          user@[192.168.1.1], First.Last@[192.168.1.1], Last-First@[192.168.1.1]
  194.          user_name@[192.168.1.1], user023@[192.168.1.1], etc.
  195.  
  196.        INVALID: (using these in your form field 'recipient' will trigger error)
  197.          user%name@domain.com, user(name)@domain.com, first:last@domain.com
  198.          <user@domain.com>, <user@other.com>domain.com, user@192.168.1.1
  199.          user@newdomain.com, user@sub.domain.com, user@domainname.com
  200.  
  201.     Essentially, it only allows A-Z, a-z, 0-9, _, - and . in the local address
  202.     area (before the @, represented as [\w\-\.]+ in regular expression speak)
  203.     and requires the domain name to match exactly. When mailing to an IP 
  204.     address, it must be enclosed in [].
  205.  
  206.     BUT I NEED TO MATCH MORE CHARACTERS IN THE USERNAME!
  207.  
  208.     Let's say you need to be able to deliver e-mail to an address like:
  209.         last:first@domain.com
  210.  
  211.     This requires that the ':' character now be allowed into the portion of
  212.     the recipient field before the domain name.  You could then modify
  213.     @recipients to read:
  214.  
  215.     @recipients = ('^[\w\-\.\:]+\@domain\.com');
  216.  
  217.     BUT BE CAREFUL!!!!
  218.  
  219.     Allowing certain characters could be VERY dangerous, especially if the
  220.     characters are: %, <, >, (, ) or any newlines.  You can read:
  221.         http://web.nps.navy.mil/~miller/percent-hack.html
  222.     for information on exactly why the % character could be dangerous. And
  223.     the document that prompted 1.91 explains why some of the others could
  224.     lead to problems:
  225.         http://www.monkeys.com/anti-spam/formmail-advisory.pdf
  226.  
  227.     I ONLY WANT CERTAIN ADDRESSES TO WORK!
  228.  
  229.     Let's say you only want yourself@yourdomain.com to be able to receive
  230.     any form submissions.  You should then set the @recipients array to:
  231.  
  232.     @recipients = ('^yourself\@yourdomain\.com');
  233.  
  234.     Now the only valid recipient is that one e-mail address.
  235.  
  236.     If there are several, simply do:
  237.  
  238.     @recipients = ('^user1\@yourdomain\.com','^user2\@their\.domain\.com');
  239.  
  240.     CAN I USE SOMETHING EASIER?
  241.  
  242.     Prior versions of FormMail recommended settings for @recipients like:
  243.  
  244.         @recipients = ('domain.com','192.168.1.1');  OR
  245.         @recipients = ('^joe@somewhereelse.com');
  246.  
  247.     The first is bad because it can be easily tricked by submitting a recipient
  248.     such as spamvictim%elsewhere.com@domain.com.  The second is MUCH better,
  249.     but since it is used as a regular expression, and '.' can mean ANY
  250.     character, a hacker could use joe@somewhereelseXcom to get past a valid
  251.     recipient check. This is not a very big deal in most cases.
  252.  
  253.     WHAT IS THIS ^ CHARACTER AND WHY SO MANY \'s??
  254.  
  255.     In regular expressions, the ^ means "beginning of string". By default,
  256.     FormMail places a $ at the end of the match, which means "end of string".
  257.     By using both ^ and $ in regular expression matching, FormMail can match a
  258.     string exactly.  You only need to worry about including the ^, which is
  259.     STRONGLY recommended for all regular expressions in the array.
  260.  
  261.     The \ character is used to escape a character that otherwise means 
  262.     something special in regular expressions. For instance, you now see every
  263.     '.' being escaped with a '\', as '.' means ANY CHARACTER, whereas '\.'
  264.     requires that it match ONLY a period.
  265.  
  266.     If you need a regular expression matching solution even more specific than
  267.     the above examples explain, I recommend picking up a book on Perl.
  268.  
  269. Your FormMail program is now configured.
  270.  
  271. -----------------------------------------------------------------------------
  272.  
  273. Form Configuration:
  274. ===================
  275.  
  276. The action of your form needs to point towards this script (obviously), and 
  277. the method must be POST or GET in capital letters.  Version 1.5 of FormMail 
  278. offers many new ways to code your form to tailor the resulting HTML page 
  279. and the way the script performs.  Below is a list of form fields you can 
  280. use and how to implement them.
  281.  
  282. Necessary Form Fields:
  283. ======================
  284.  
  285. There is only one form field that you must have in your form, for 
  286. FormMail to work correctly.  This is the recipient field.
  287.  
  288. Field:       recipient
  289.  
  290. Description: This form field allows you to specify to whom you wish for your
  291.              form results to be mailed.  Most likely you will want to
  292.              configure this option as a hidden form field with a value equal
  293.              to that of your e-mail address. 
  294.              As of version 1.8, You can include multiple recipients by 
  295.              separating the values with commas. 
  296.  
  297. Syntax:
  298.              <input type=hidden name="recipient" value="email@your.host.com">
  299.              OR  <input type=hidden name="recipient" 
  300.                                 value="user@yourhost.com,user2@yourhost.com">
  301.  
  302. -----------------------------------------------------------------------------
  303.  
  304. Optional Form Fields:
  305. =====================
  306.  
  307. Field:       subject
  308.  
  309. Description: The subject field will allow you to specify the subject that you
  310.              wish to appear in the e-mail that is sent to you after this form
  311.              has been filled out.  If you do not have this option turned on,
  312.              then the script will default to a message subject: WWW Form
  313.              Submission
  314.  
  315. Syntax:
  316.              If you wish to choose what the subject is:
  317.               <input type=hidden name="subject" value="Your Subject">
  318.  
  319.              To allow the user to choose a subject:
  320.               <input type=text name="subject">
  321.  
  322. -----------------------------------------------------------------------------
  323.  
  324. Field:       email
  325.  
  326. Description: This form field will allow the user to specify their return
  327.              e-mail address.  If you want to be able to return e-mail to your
  328.              user, I strongly suggest that you include this form field and
  329.              allow them to fill it in.  This will be put into the From:
  330.              field of the message you receive.  If you want to require an
  331.              email address with valid syntax, add this field name to the
  332.              'required' field.
  333.  
  334. Syntax:
  335.              <input type=text name="email">
  336.  
  337. -----------------------------------------------------------------------------
  338.  
  339. Field:       realname
  340.  
  341. Description: The realname form field will allow the user to input their real
  342.              name.  This field is useful for identification purposes and will
  343.              also be put into the From: line of your message header.
  344.  
  345. Syntax: 
  346.              <input type=text name="realname">
  347.  
  348. -----------------------------------------------------------------------------
  349.  
  350. Field:       redirect
  351.  
  352. Description: If you wish to redirect the user to a different URL, rather than
  353.              having them see the default response to the fill-out form, you
  354.              can use this hidden variable to send them to a pre-made HTML
  355.              page.
  356.  
  357. Syntax:
  358.              To choose the URL they will end up at:
  359.                <input type=hidden name="redirect" 
  360.                                   value="http://your.host.com/to/file.html">
  361.  
  362.              To allow them to specify a URL they wish to travel to once the
  363.              form is filled out:
  364.                <input type=text name="redirect">
  365.  
  366. -----------------------------------------------------------------------------
  367.  
  368. Field:       required
  369.  
  370. Version:     1.3 & Up
  371.  
  372. Description: You can now require for certain fields in your form to be filled
  373.              in before the user can successfully submit the form.  Simply
  374.              place all field names that you want to be mandatory into this
  375.              field.  If the required fields are not filled in, the user will
  376.              be notified of what they need to fill in, and a link back to
  377.              the form they just submitted will be provided.
  378.  
  379.              To use a customized error page, see 'missing_fields_redirect'
  380.  
  381. Syntax:
  382.              If you want to require that they fill in the email and phone
  383.              fields in your form, so that you can reach them once you have
  384.              received the mail, use a syntax like:
  385.  
  386.                <input type=hidden name="required" value="email,phone">
  387.  
  388. -----------------------------------------------------------------------------
  389.  
  390. Field:       env_report
  391.  
  392. Version:     1.3 & Up
  393.  
  394. Description: Allows you to have Environment variables included in the
  395.              e-mail message you receive after a user has filled out your
  396.              form.  Useful if you wish to know what browser they were using,
  397.              what domain they were coming from or any other attributes
  398.              associated with environment variables.  The following is a short
  399.              list of valid environment variables that might be useful:
  400.  
  401.              REMOTE_HOST     - Sends the hostname making a request.
  402.              REMOTE_ADDR     - Sends the IP address of the remote host making
  403.                                the request.
  404.              REMOTE_USER     - If server supports authentication and script
  405.                                is protected, this is the username they have
  406.                                authenticated as. *This is not usually set.*
  407.              HTTP_USER_AGENT - The browser the client is using to send the
  408.                                request.  
  409.  
  410.              There are others, but these are a few of the most useful.  For
  411.              more information on environment variables, see:
  412.  
  413.             http://www.cgi-resources.com/Documentation/Environment_Variables/
  414.  
  415. Syntax:
  416.              If you wanted to find the remote host and browser sending the
  417.              request, you would put the following into your form:
  418.  
  419.               <input type=hidden name="env_report" value="REMOTE_HOST,
  420.                                                            HTTP_USER_AGENT">
  421.  
  422. -----------------------------------------------------------------------------
  423.  
  424. Field:       sort
  425.  
  426. Version:     1.4 & Up
  427.  
  428. Description: This field allows you to choose the order in which you wish 
  429.              for your variables to appear in the e-mail that FormMail
  430.              generates.  You can choose to have the field sorted
  431.              alphabetically or specify a set order in which you want the
  432.              fields to appear in your mail message.  By leaving this field
  433.              out, the order will simply default to the order in which the 
  434.              browsers sends the information to the script (which is usually
  435.              the exact same order as they appeared in the form.)  When
  436.              sorting by a set order of fields, you should include the phrase
  437.              "order:" as the first part of your value for the sort field, and
  438.              then follow that with the field names you want to be listed in
  439.              the e-mail message, separated by commas.  Version 1.6 allows a
  440.              little more flexibility in the listing of ordered fields, in
  441.              that you can include spaces and line breaks in the field without
  442.              it messing up the sort.  This is helpful when you have many form
  443.              fields and need to insert a line wrap.
  444.  
  445. Syntax:
  446.              To sort alphabetically:
  447.                <input type=hidden name="sort" value="alphabetic">
  448.  
  449.              To sort by a set field order:
  450.                <input type=hidden name="sort" value="order:name1,name2,
  451.                                                    name3,etc...">
  452.  
  453. -----------------------------------------------------------------------------
  454.  
  455. Field:       print_config
  456.  
  457. Version:     1.5 & Up
  458.  
  459. Description: print_config allows you to specify which of the config 
  460.              variables you would like to have printed in your e-mail message.
  461.              By default, no config fields are printed to your e-mail.  This
  462.              is because the important form fields, like email, subject, etc.
  463.              are included in the header of the message.  However some users
  464.              have asked for this option so they can have these fields printed
  465.              in the body of the message.  The config fields that you wish to
  466.              have printed should be in the value attribute of your input tag
  467.              separated by commas.
  468.  
  469. Syntax:
  470.              If you want to print the email and subject fields in the body of
  471.              your message, you would place the following form tag:
  472.  
  473.               <input type=hidden name="print_config" value="email,subject">
  474.  
  475. -----------------------------------------------------------------------------
  476.  
  477. Field:       print_blank_fields
  478.  
  479. Version:     1.6
  480.  
  481. Description: print_blank_fields allows you to request that all form fields
  482.              are printed in the return HTML, regardless of whether or not
  483.              they were filled in.  FormMail defaults to turning this off, so
  484.              that unused form fields aren't e-mailed.
  485.  
  486. Syntax:
  487.  
  488.              If you want to print all blank fields:
  489.               <input type=hidden name="print_blank_fields" value="1">
  490.  
  491. ----------------------------------------------------------------------------
  492.  
  493. Field:       title
  494.  
  495. Version:     1.3 & Up
  496.  
  497. Description: This form field allows you to specify the title and header that
  498.              will appear on the resulting page if you do not specify a
  499.              redirect URL.
  500.  
  501. Syntax:
  502.              If you wanted a title of 'Feedback Form Results':
  503.               <input type=hidden name="title" value="Feedback Form Results">
  504.  
  505. -----------------------------------------------------------------------------
  506.  
  507. Field:       return_link_url
  508.  
  509. Version:     1.3 & Up
  510.  
  511. Description: This field allows you to specify a URL that will appear, as
  512.              return_link_title, on the following report page.  This field
  513.              will not be used if you have the redirect field set, but it is
  514.              useful if you allow the user to receive the report on the
  515.              following page, but want to offer them a way to get back to
  516.              your main page.
  517.  
  518. Syntax:
  519.              <input type=hidden name="return_link_url" 
  520.                              value="http://your.host.com/main.html">
  521.  
  522. -----------------------------------------------------------------------------
  523.  
  524. Field:       return_link_title
  525.  
  526. Version:     1.3 & Up
  527.  
  528. Description: This is the title that will be used to link the user back to the
  529.              page you specify with return_link_url.  The two fields will be
  530.              shown on the resulting form page as:
  531.  
  532.              <ul>
  533.               <li><a href="return_link_url">return_link_title</a>
  534.              </ul>
  535.  
  536. Syntax:
  537.              <input type=hidden name="return_link_title"
  538.                                                   value="Back to Main Page">
  539.  
  540. -----------------------------------------------------------------------------
  541.  
  542. Field:       missing_fields_redirect
  543.  
  544. Version:     1.6
  545.  
  546. Description: This form field allows you to specify a URL that users will be
  547.              redirected to if there are fields listed in the required form
  548.              field that are not filled in.  This is so you can customize an
  549.              error page instead of displaying the default.
  550.  
  551. Syntax:
  552.              <input type=hidden name="missing_fields_redirect"
  553.                                     value="http://your.host.com/error.html">
  554.  
  555. -----------------------------------------------------------------------------
  556.  
  557. Field:       background
  558.  
  559. Version:     1.3 & Up
  560.  
  561. Description: This form field allow you to specify a background image that
  562.              will appear if you do not have the redirect field set.  This
  563.              image will appear as the background to the form results page.
  564.  
  565. Syntax:
  566.              <input type=hidden name="background"
  567.                                      value="http://your.host.com/image.gif">
  568.  
  569. -----------------------------------------------------------------------------
  570.  
  571. Field:       bgcolor
  572.  
  573. Version:     1.3 & Up
  574.  
  575. Description: This form field allow you to specify a bgcolor for the form
  576.              results page in much the way you specify a background image.
  577.              This field should not be set if the redirect field is.
  578.  
  579. Syntax:
  580.              For a background color of White:
  581.               <input type=hidden name="bgcolor" value="#FFFFFF">
  582.  
  583. -----------------------------------------------------------------------------
  584.  
  585. Field:       text_color
  586.  
  587. Version:     1.3 & Up
  588.  
  589. Description: This field works in the same way as bgcolor, except that it
  590.              will change the color of your text.
  591.  
  592. Syntax:
  593.              For a text color of Black:
  594.               <input type=hidden name="text_color" value="#000000">
  595.  
  596. -----------------------------------------------------------------------------
  597.  
  598. Field:       link_color
  599.  
  600. Version:     1.3 & Up
  601.  
  602. Description: Changes the color of links on the resulting page.  Works in the
  603.              same way as text_color.  Should not be defined if redirect is.
  604.  
  605. Syntax:
  606.              For a link color of Red:
  607.               <input type=hidden name="link_color" value="#FF0000">
  608.  
  609. -----------------------------------------------------------------------------
  610.  
  611. Field:       vlink_color
  612.  
  613. Version:     1.3 & Up
  614.  
  615. Description: Changes the color of visited links on the resulting page. Works
  616.              exactly the same as link_color.  Should not be set if redirect
  617.              is.
  618.  
  619. Syntax:
  620.              For a visited link color of Blue:
  621.               <input type=hidden name="vlink_color" value="#0000FF">
  622.  
  623. -----------------------------------------------------------------------------
  624.  
  625. Field:       alink_color
  626.  
  627. Version:     1.4 & Up
  628.  
  629. Description: Changes the color of active links on the resulting page. Works
  630.              exactly the same as link_color.  Should not be set if redirect
  631.              is.
  632.  
  633. Syntax:
  634.              For a visited link color of Blue:
  635.               <input type=hidden name="alink_color" value="#0000FF">
  636.  
  637. -----------------------------------------------------------------------------
  638.  
  639. Any other form fields that appear in your script will be mailed back to 
  640. you and displayed on the resulting page if you do not have the redirect 
  641. field set.  There is no limit as to how many other form fields you can 
  642. use with this form, except the limits imposed by browsers and your server.
  643.  
  644. -----------------------------------------------------------------------------
  645.  
  646. Some of the possible uses of this script are:
  647.  
  648. 1) You want to have a form that will be mailed to you, but aren't sure how to 
  649.    write the CGI script for it.
  650. 2) You are the webmaster of your site and want to allow users to use forms, 
  651.    but not to have their own cgi-bin directories, which can cause 
  652.    security risks to your system.  You can set this script up and then 
  653.    allow all users to run off of it.
  654. 3) Want to have one script to parse all of your html forms and mail them 
  655.    to you.
  656.  
  657. -----------------------------------------------------------------------------
  658.  
  659. History:
  660. Version 1.0     06/11/95  -  This script was created.
  661. Version 1.1     08/03/95  -  A major hole in the script which allowed users 
  662.                              to run commands under your server's uid was 
  663.                              disabled, thanks to Paul Phillips, who noticed
  664.                              the error.
  665.                           -  The ability to redirect the user to a specified
  666.                              HTML file after they filled out a form was 
  667.                              added.
  668. Version 1.2     09/23/95  -  If the form field is one of the required or 
  669.                              optional 'special' fields, such as redirect, 
  670.                              recipient, subject, email, realname, etc... the
  671.                              script will not print these fields to either
  672.                              your mail message or to the user's screen when
  673.                              they are returned to a generic form response.
  674.                              It helps you so that things do not get 
  675.                              duplicated.
  676. Version 1.3     01/21/96  -  Much needed update finally completed
  677.                           -  Added form fields: env_report, bgcolor, 
  678.                              background, link_color, vlink_color, title,
  679.                              text_color, return_link_title, return_link_url 
  680.                              and required.
  681.                           -  Security hole, which allowed any user on any 
  682.                              system to bum off of your FormMail script, has
  683.                              been plugged up with the @referers variable.
  684.                           -  Report style in return html and e-mail touched 
  685.                              up a bit.
  686. Version 1.4     01/23/96  -  Added options: sort, alink_color 
  687.                           -  Fixed a few bugs from Version 1.3, namely the 
  688.                              fact that the link_colors weren't working well.
  689.                           -  FormMail now supports both the GET and POST 
  690.                              methods.
  691. Version 1.5     02/05/96  -  Sorting of Fields in E-Mail Response Fixed.
  692.                           -  print_config option added.
  693. Version 1.6     05/02/97  -  Sorting of fields by default was fixed to now
  694.                              sort in the order the fields are passed to
  695.                              FormMail from the web browser, which is usually
  696.                              the same order as they appear in the HTML form.
  697.                           -  The sort order: directive, env_report and 
  698.                              print_config parsing routines were made to 
  699.                              better compensate for line breaks and extra
  700.                              spaces in input for ease of use.
  701.                           -  Redirect error causing the redirect option to
  702.                              incorrectly work with https (secure servers)
  703.                              was fixed.
  704.                           -  Input of a '0' in a regular form field now
  705.                              recognized as input and sent back to user.
  706.                           -  Output of non-filled in form fields suppressed.
  707.                           -  E-mail addresses checked for correct syntax if
  708.                              designated a required field.
  709.                           -  Fields only printed if they contain a value or
  710.                              if the print_blank_fields option is set to 1.
  711.                           -  missing_fields_redirect added so you can route
  712.                              users who don't completely fill out the form to
  713.                              a pre-made HTML page.
  714.                           -  Parts of code optimized, especially in respect
  715.                              to the way config variables are handled.
  716. Version 1.7     07/27/01  -  Added in @recipients to defeat spamming attempts
  717.                           -  Added in @valid_ENV to allow administrators to
  718.                              specify what environment variables can be sent.
  719. Version 1.8     08/02/01  -  Fixed the recipients code to allow multiple
  720.                              recipients using the 'recipients' form field and
  721.                              commas. Under certain cases in v1.7, spam could
  722.                              still get through by appending a legit recipient
  723.                              to the list of intended spam victims.
  724.                           -  Moved send_email subroutine in front of 
  725.                              return_html as many people reported their web
  726.                              server would kill the FormMail process after the
  727.                              redirect command was issued and no e-mail would
  728.                              be sent.
  729. Version 1.9     08/03/01  -  Added in a further anti-spam check which would
  730.                              take advantage of newline characters in the 
  731.                              subject to send invalid e-mail.
  732.                           -  Removed a restriction when checking e-mail 
  733.                              addresses for validity that required a 2 - 3
  734.                              character domain extension.  With the new TLD's
  735.                              becoming available, it can no longer apply.
  736. Version 1.91    04/19/02  -  The same vulnerability that was patched in 1.9
  737.                              with the subject field still existed in the email
  738.                              and realname fields. Newline characters are no
  739.                              longer allowed in any fields that are placed in
  740.                              the header of the message.
  741.                           -  Much stronger default regular expression checking
  742.                              in the @recipients array is now implemented.  This
  743.                              will combat the % hack and other known exploits.
  744.                           -  The options for sendmail were moved into the
  745.                              $mailprog variable and -i was added so that single
  746.                              periods on a line will not cause the end of the
  747.                              message.
  748. Version 1.92    04/21/02  -  Removed cross-site scripting vulerabilities
  749.                              by converting all <, >, & and " into their HTML
  750.                              equivalents when displayed on a web page. These
  751.                              characters are left intact in the e-mail message.
  752.                           -  Now removes any null bytes from form input.
  753.                           -  Fixed field recognition so that '0' is now a
  754.                              valid input.  Supposedly fixed in v1.6.
  755.                           -  Fixed print_blank_fields
  756. -----------------------------------------------------------------------------
  757. Matt Wright   -   mattw@scriptarchive.com   -   http://www.scriptarchive.com/
  758.