home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / cgi-bin / form-mail.fairmaster.old < prev    next >
Text File  |  2017-09-21  |  7KB  |  201 lines

  1. #!/usr/local/bin/perl -- -*-perl-*-
  2.  
  3. # ------------------------------------------------------------
  4. # Form-mail.pl, by Reuven M. Lerner (reuven@the-tech.mit.edu).
  5. #
  6. # Last updated: March 2, 1994
  7. #
  8. # Form-mail provides a mechanism by which users of a World-
  9. # Wide Web browser may submit comments to the webmasters
  10. # (or anyone else) at a site.  It should be compatible with
  11. # any CGI-compatible HTTP server.
  12. # Please read the README file that came with this distribution
  13. # for further details.
  14. # ------------------------------------------------------------
  15.  
  16. # ------------------------------------------------------------
  17. # This package is Copyright 1994 by The Tech. 
  18.  
  19. # Form-mail is free software; you can redistribute it and/or modify it
  20. # under the terms of the GNU General Public License as published by the
  21. # Free Software Foundation; either version 2, or (at your option) any
  22. # later version.
  23.  
  24. # Form-mail is distributed in the hope that it will be useful, but
  25. # WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  27. # General Public License for more details.
  28.  
  29. # You should have received a copy of the GNU General Public License
  30. # along with Form-mail; see the file COPYING.  If not, write to the Free
  31. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  32. # ------------------------------------------------------------
  33.  
  34. # Define fairly-constants
  35.  
  36. # This should match the mail program on your system.
  37. $mailprog = '/usr/lib/sendmail -odq';
  38.  
  39. # This should be set to the username or alias that runs your
  40. # WWW server.
  41. $recipient = 'fairmaster@park.org';
  42.  
  43.  
  44. # Print out a content-type for HTTP/1.0 compatibility
  45. print "Content-type: text/html\n\n";
  46.  
  47. if ($ENV{'CONTENT_LENGTH'} <= 0) {
  48.     $reference = $ENV{'QUERY_STRING'} ;
  49.     $reference =~ tr/+/ /s;
  50.  
  51.     print <<EoI;
  52.  
  53. <head><title>Comments to Fair Administration</title></head>
  54. <BODY BGCOLOR="#FFFFFF" background="/Images/expo_hbk_01.gif" TEXT="#000000" LINK="#97694F" VLINK="#42426f">
  55.  
  56. <a href="/cgi-bin/imagemap/Images/htoolbar.map">
  57. <img align="left" width="486" height="101" 
  58. SRC="/Images/htoolbar.gif" ISMAP border="0"></a>
  59. <br clear="all">
  60.  
  61. <table width="600" height="0"  border="0" cellpadding="0" cellspacing="0">
  62.     <tr>
  63.         <td align="left" valign="top" width="100" height="26" colspan="2">
  64.     </td></tr>
  65. <tr>
  66. <td align="left" valign="top" width="100" >
  67. <td align="left" valign="top" width="500"  >
  68. <p>
  69.  
  70. <Head><Title>Comments to the Internet 1996 World Exposition</Title></Head>
  71. <Body>
  72. <font size="+2"><b>Comments to Fair Administration</font size="+2"></b>
  73.  
  74. <p>
  75. Please enter any comments you might have in the space below, and
  76. select the "Send comments" button when you are through.
  77. If your browser doesn't support forms, 
  78. <a href="mailto:fairmaster@park.org">mail</a> us your comments.
  79. <p>
  80.  
  81. <Form method=POST action="/cgi-bin/form-mail.fairmaster">
  82.  
  83. <inPUT NAME="username"> Your E-Mail Address<br>
  84. <inPUT NAME="realname"> Your Name<br>
  85. <inPUT NAME="url"> Relevant URL<br>
  86. <inPUT NAME="subject" Value="$reference" > Subject<P>
  87. <inPUT NAME="about" Value="$ENV{'HTTP_REFERER'}" Type="hidden">
  88. Please enter any comments you might have in the space below:<P>
  89.  
  90. <TEXTAREA NAME="comments" ROWS="10" COLS="70"></TEXTAREA><P>
  91.  
  92. <P>
  93.  
  94. <Input TYPE="submit" VALUE="Send comments">
  95. <Input TYPE="reset" VALUE="Erase comments"><p>
  96. </Form>
  97.  
  98.     </td>
  99.     </tr>
  100. </table>
  101. </body>
  102. </HTML>
  103.  
  104. EoI
  105.  
  106. } else {
  107.     # Print a title and initial heading
  108.     print "<Head><Title>Thank you</Title></Head>";
  109.  
  110.     # Make the person feel good for writing to us
  111.  
  112. print "<BODY BGCOLOR=\"#FFFFFF\" background=\"/Images/expo_hbk_01.gif\" TEXT=\"#000000\" LINK=\"#97694F\" VLINK=\"#42426f\">";
  113. print "";
  114. print "<a href=\"/cgi-bin/imagemap/Images/htoolbar.map\">";
  115. print "<img align=\"left\" width=\"486\" height=\"101\" ";
  116. print "SRC=\"/Images/htoolbar.gif\" ISMAP border=\"0\"></a>";
  117. print "<br clear=\"all\">";
  118. print "";
  119. print "<table width=\"600\" height=\"0\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
  120. print "    <tr>";
  121. print "        <td align=\"left\" valign=\"top\" width=\"100\" height=\"26\" colspan=\"2\">";
  122. print "    </td></tr>";
  123. print "<tr>";
  124. print "<td align=\"left\" valign=\"top\" width=\"100\" >";
  125. print "<td align=\"left\" valign=\"top\" width=\"500\"  >";
  126. print "<p>";
  127. print "<font size=\"+2\"><b>Thank You!</font size=\"+2\"></b>";
  128. print "";
  129. print "<p>";
  130.  
  131.  
  132.     # Get the input
  133.         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  134.         # Split the name-value pairs
  135.         @pairs = split(/&/, $buffer);
  136.         foreach $pair (@pairs) {
  137.            ($name, $value) = split(/=/, $pair);
  138.  
  139.            # Un-Webify plus signs and %-encoding
  140.            $value =~ tr/+/ /;
  141.            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  142.  
  143.            # Stop people from using subshells to execute commands
  144.            $value =~ s/~!/ ~!/g;
  145.             $FORM{$name} = $value;
  146.         }
  147.  
  148. print "Thank you for your comments regarding:";
  149. print "<ul>  $FORM{'subject'} </ul><p>";
  150. print "";
  151.         if (! $FORM{'username'} || ! $FORM{'subject'} || ! $FORM{'comments'}) {
  152.                 print "<p>However, messages with no email address, subject or comments will not be sent.";
  153.                 print "<p>";
  154.         } else {
  155.                 # Now send mail to $recipient
  156.                 &send_mail;
  157.         }
  158.  
  159. print "    </td></tr></table>";
  160. print "";
  161. print "    </td>";
  162. print "    </tr>";
  163. print "</table>";
  164. print "";
  165. print "";
  166. print "</body>";
  167. print "</HTML>";
  168.  
  169. }
  170. exit 0;
  171.  
  172. #
  173. #  send mail message
  174. #
  175. sub send_mail {
  176.     local($about) = $FORM{'about'};
  177.  
  178.     open (MAIL, "|$mailprog $recipient ") || die "Can't open $mailprog!\n";
  179.     print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
  180.     print MAIL "Subject: $FORM{'subject'}\n\n";
  181.     print MAIL "$FORM{'username'} ($FORM{'realname'}) sent the following\n";
  182.     print MAIL "comment about $about:\n";
  183.     print MAIL  "------------------------------------------------------------\n";
  184.     print MAIL "URL: $FORM{'url'}\n";
  185.     print MAIL "$FORM{'comments'}";
  186.     print MAIL "\n------------------------------------------------------------\n";
  187.     print MAIL "Server name: $ENV{'SERVER_NAME'}\n";
  188.     print MAIL "Gateway Interface: $ENV{'GATEWAY_INTERFACE'}\n";
  189.     print MAIL "Path Info: $ENV{'PATH_INFO'}\n";
  190.     print MAIL "Path Translated: $ENV{'PATH_TRANSLATED'}\n";
  191.     print MAIL "Script Name: $ENV{'SCRIPT_NAME'}\n";
  192.     print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
  193.     print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
  194.     print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
  195.     print MAIL "User Agent: $ENV{'HTTP_USER_AGENT'}\n"
  196.       if defined($ENV{'HTTP_USER_AGENT'});
  197.     close (MAIL);
  198. }
  199.  
  200.