home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / waygate / mail-HG.pl < prev    next >
Perl Script  |  1995-04-21  |  4KB  |  107 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 14, 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';
  38.  
  39. # This should be set to the username or alias that runs your
  40. # WWW server.
  41. $recipient = 'Helmut.Geyer@IWR.Uni-Heidelberg.de';
  42.  
  43. # Print out a content-type for HTTP/1.0 compatibility
  44. print "Content-type: text/html\n\n";
  45.  
  46. # Print a title and initial heading
  47. print "<Head><Title>Thank you</Title></Head>";
  48. print "<Body><H1>Thank you</H1>";
  49.  
  50. # Get the input
  51. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  52.  
  53. # Split the name-value pairs
  54. @pairs = split(/&/, $buffer);
  55.  
  56. foreach $pair (@pairs)
  57. {
  58.     ($name, $value) = split(/=/, $pair);
  59.  
  60.     # Un-Webify plus signs and %-encoding
  61.     $value =~ tr/+/ /;
  62.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  63.  
  64.     # Stop people from using subshells to execute commands
  65.     # Not a big deal when using sendmail, but very important
  66.     # when using UCB mail (aka mailx).
  67.     # $value =~ s/~!/ ~!/g; 
  68.  
  69.     # Uncomment for debugging purposes
  70.     # print "Setting $name to $value<P>";
  71.  
  72.     $FORM{$name} = $value;
  73. }
  74.  
  75. # If the comments are blank, then give a "blank form" response
  76. &blank_response unless $FORM{'comments'};
  77.  
  78. # Now send mail to $recipient
  79.  
  80. open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
  81. print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
  82. print MAIL "Subject: Jordan WWW comments (Forms submission)\n\n";
  83. print MAIL "$FORM{'username'} ($FORM{'realname'}) sent the following\n";
  84. print MAIL "comment about the Jordan Homepage:\n\n";
  85. print MAIL  "------------------------------------------------------------\n";
  86. print MAIL "$FORM{'comments'}";
  87. print MAIL "\n------------------------------------------------------------\n";
  88. print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
  89. print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
  90. print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
  91. close (MAIL);
  92.  
  93. # Make the person feel good for writing to us
  94. print "Thank you for sending comments!<P>";
  95. print "Return to the <A HREF=\"/jordan/jordan.html\">Jordan home page</A>, if you want.<P>";
  96.  
  97. # ------------------------------------------------------------
  98. # subroutine blank_response
  99. sub blank_response
  100. {
  101.     print "Your comments appear to be blank, and thus were not sent ";
  102.     print "to me.  Please re-enter your comments, or ";
  103.     print "return to the <A HREF=\"/jordan/jordan.html\">Jordan home page</A>, if you want.<P>";
  104.     exit;
  105. }
  106.