home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Postcards / send / send.cgi < prev    next >
Encoding:
Text File  |  2017-09-22  |  5.8 KB  |  187 lines

  1. #!/user/a61/perl/bin/perl
  2. # #!/usr/local/bin/perl
  3.  
  4.        print "Location: over.html\n\n";
  5.        exit 0;
  6.  
  7. $input_error = "Cannot process input";
  8. $file_error = "Cannot open file";
  9.  
  10. $form_message = "message";
  11. $form_postcard = "postcard";
  12. $form_sender = "sender";
  13. $form_receiver = "receiver";
  14. $form_text = "text";
  15.  
  16. $dir = "../postcards/";
  17. $extension = ".html";
  18.  
  19. # Read CGI input
  20. # split pairs in variables.
  21. #
  22. read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
  23. @pairs = split (/&/, $input);
  24. if (scalar(@pairs) == 5) {
  25.    foreach $pair (@pairs) {
  26.       ($attribute, $value) =  split (/=/, $pair);
  27.       $value =~ tr/+/ /;
  28.       $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
  29.  
  30.       if ($attribute eq $form_message) {
  31.          $message_input = $value;
  32.       }
  33.       if ($attribute eq $form_postcard) {
  34.          $postcard_input = $value;
  35.       }
  36.       if ($attribute eq $form_sender) {
  37.          $sender_input = $value;
  38.       }
  39.       if ($attribute eq $form_receiver) {
  40.          $receiver_input = $value;
  41.       }
  42.       if ($attribute eq $form_text) {
  43.          $text_input = $value;
  44.       }
  45.    }
  46. }
  47. else {
  48.    print "$input_error\n";
  49.    exit 0;
  50. }
  51.  
  52.  
  53. # Process Card
  54. #
  55. &makeFileName;
  56. &sendMail;
  57. &writeToFile;
  58.  
  59. # HTML output
  60. print "Content-Type: text/html \n\n";
  61. print "<HTML><HEAD><title>Postcard</title></HEAD>\n";
  62.  
  63. print "<BODY background=\"/Images/expo_hbk_01.gif\" BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#97694F\" VLINK=\"#42426f\"> \n";
  64.  
  65. print "<a href=\"/main.html\"><img align=\"left\" width=\"533\" height=\"127\" SRC=\"/Images/fair_header.gif\" border=\"0\"></a> <br clear=\"all\"> \n";
  66.  
  67. print "<table cellspacing=\"10\" cellpadding=\"0\">\n";
  68. print "<tr>\n";
  69. print "<td rowspan=\"2\" width=\"75\">\n";
  70. print "</td>\n";
  71. print "<td align=\"left\" valign=\"center\">\n";
  72. print "<h2>Thanks</h2>\n";
  73. print "Thank you for sending a postcard!\n";
  74. print "<p>\n";
  75. print "\"$password\" is the password we send to $receiver_input.\n";
  76. print "<br><font size=\"-1\">(<a target=\"_top\" href=\"../receive/\">have a look yourself,</a>)</font>\n";
  77. print "</td>\n";
  78. print "</tr>\n";
  79. print "<tr>\n";
  80. print "<td align=\"left\" valign=\"center\">\n";
  81. print "<a target=\"_top\" href=\"../\">Back To The Postcards Page</a>\n";
  82. print "</td>\n";
  83. print "</tr>\n";
  84. print "</table>\n";
  85.  
  86. print "</BODY></HTML>\n";
  87.  
  88.  
  89. sub makeFileName {
  90.  
  91.     if ( $receiver_input =~ /^([^\@]*)\@([^\.]*)\.(.*)/ ) {
  92.         $base = $1;
  93.         $domain = $2;
  94.         $country = $3;
  95.     }
  96.     else {
  97.        print "Location: try_again.html\n\n";
  98.        exit 0;
  99.     }
  100.  
  101.     if (! ((length($base) gt 0) &&  (length($domain) gt 0) && (length($country) gt 0)) ) {
  102.        print "Location: try_again.html\n\n";
  103.        exit 0;
  104.     }
  105.  
  106.     srand();
  107.     $status=1;
  108.     while ($status) {
  109.         $number = int(rand(9999)) + 1;
  110.         $password = $base."_".$number;
  111.         $file = $dir.$password;
  112.         $file = $file.$extension;
  113.         if ( !(-e $file) ) {
  114.             # ***** possible LOOP, after 9999 files it looks further!
  115.             $status=0;
  116.         }
  117.     }
  118. }
  119.  
  120. sub sendMail {
  121.  
  122.    push (@out, "\n");
  123.    push (@out, "$sender_input send you a postcard!\n\n");
  124.    push (@out, "You can pick it up in the Internet 1996 World Exposition.\n");
  125.    push (@out, "(http://park.org/)\n");
  126.    push (@out, "The address were to find your postcard is:\n\n");
  127.    push (@out, "    http://amsterdam.park.org/Postcards/\n\n");
  128.    push (@out, "Your password is:\n\n");
  129.    push (@out, "    $password\n\n");
  130.    push (@out, "Thank You!\n\n\n");
  131.    push (@out, "----------------------------------------------------------\n\n");
  132.    push (@out, "This message is automatically generated from the web.\n");
  133.    push (@out, "It is from the Internet 1996 World Exposition.\n");
  134.    push (@out, "We are *not* responsible for this mail\n");
  135.    push (@out, "and the content of your postcard.\n\n");
  136.    push (@out, "----------------------------------------------------------\n\n");
  137.  
  138.    open(MAIL, "|/usr/ucb/mail -s postcard $receiver_input");
  139.    print MAIL "@out";
  140.    close(MAIL);
  141.  
  142. }
  143.  
  144. sub writeToFile {
  145.  
  146.     open (W_FILE, ">>$file");
  147.  
  148.     print W_FILE "<HTML><HEAD><title>Flower Postcards</title></HEAD>\n";
  149.     print W_FILE "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#000000\" ALINK=\"#000000\" VLINK=\"#000000\"> \n";
  150.  
  151.     print W_FILE "<table cellspacing=\"10\" cellpadding=\"0\" width=\"100%\">\n";
  152.     print W_FILE "<tr>\n";
  153.     print W_FILE "<td rowspan=\"4\">\n";
  154.     print W_FILE "</td>\n";
  155.     print W_FILE "<td align=\"center\" valign=\"center\" width=\"60%\">\n";
  156.     print W_FILE "<a href=\"/About/index.text.html\"><img align=\"left\" width=\"533\" height=\"127\" ALT=\"[INTERNET 1996 WORLD EXPOSITION]\" SRC=\"/Images/fair_header.gif\" border=\"0\"></a><br clear=\"all\"><br>\n";
  157.     print W_FILE "This is your postcard from <b>$sender_input</b>!<br>\n";
  158.     print W_FILE "</td>\n";
  159.     print W_FILE "<td rowspan=\"4\">\n";
  160.     print W_FILE "</td>\n";
  161.     print W_FILE "</tr>\n";
  162.     print W_FILE "<tr>\n";
  163.     print W_FILE "<td align=\"center\" valign=\"center\" width=\"60%\">\n";
  164.     print W_FILE "<img src=\"../createPostcard.cgi?$message_input+$postcard_input\" alt=\"Generating postcard, please wait...\">\n";
  165.     print W_FILE "</td>\n";
  166.     print W_FILE "</tr>\n";
  167.     print W_FILE "<tr>\n";
  168.     print W_FILE "<td align=\"center\" valign=\"center\" width=\"525\">\n";
  169.     print W_FILE "<pre><i>$text_input</i></pre>\n";
  170.     print W_FILE "</td>\n";
  171.     print W_FILE "</tr>\n";
  172.     print W_FILE "<tr>\n";
  173.     print W_FILE "<td align=\"left\" valign=\"center\" width=\"525\">\n";
  174.     print W_FILE "<font size=\"-1\">\n";
  175.     print W_FILE "<a href=\"../\">Back To The Postcards Page</a><br>\n";
  176.     print W_FILE "<a href=\"/\">To The Internet 1996 World Exposition!</a><br>\n";
  177.     print W_FILE "</font>\n";
  178.     print W_FILE "</td>\n";
  179.     print W_FILE "</tr>\n";
  180.     print W_FILE "</table>\n";
  181.     
  182.     print W_FILE "</BODY></HTML>\n";
  183.  
  184.     close(W_FILE);
  185. }
  186.