home *** CD-ROM | disk | FTP | other *** search
- #!/user/a61/perl/bin/perl
- # #!/usr/local/bin/perl
-
- print "Location: over.html\n\n";
- exit 0;
-
- $input_error = "Cannot process input";
- $file_error = "Cannot open file";
-
- $form_message = "message";
- $form_postcard = "postcard";
- $form_sender = "sender";
- $form_receiver = "receiver";
- $form_text = "text";
-
- $dir = "../postcards/";
- $extension = ".html";
-
- # Read CGI input
- # split pairs in variables.
- #
- read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
- @pairs = split (/&/, $input);
- if (scalar(@pairs) == 5) {
- foreach $pair (@pairs) {
- ($attribute, $value) = split (/=/, $pair);
- $value =~ tr/+/ /;
- $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
-
- if ($attribute eq $form_message) {
- $message_input = $value;
- }
- if ($attribute eq $form_postcard) {
- $postcard_input = $value;
- }
- if ($attribute eq $form_sender) {
- $sender_input = $value;
- }
- if ($attribute eq $form_receiver) {
- $receiver_input = $value;
- }
- if ($attribute eq $form_text) {
- $text_input = $value;
- }
- }
- }
- else {
- print "$input_error\n";
- exit 0;
- }
-
-
- # Process Card
- #
- &makeFileName;
- &sendMail;
- &writeToFile;
-
- # HTML output
- #
- print "Content-Type: text/html \n\n";
- print "<HTML><HEAD><title>Postcard</title></HEAD>\n";
-
- print "<BODY background=\"/Images/expo_hbk_01.gif\" BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#97694F\" VLINK=\"#42426f\"> \n";
-
- print "<a href=\"/main.html\"><img align=\"left\" width=\"533\" height=\"127\" SRC=\"/Images/fair_header.gif\" border=\"0\"></a> <br clear=\"all\"> \n";
-
- print "<table cellspacing=\"10\" cellpadding=\"0\">\n";
- print "<tr>\n";
- print "<td rowspan=\"2\" width=\"75\">\n";
- print "</td>\n";
- print "<td align=\"left\" valign=\"center\">\n";
- print "<h2>Thanks</h2>\n";
- print "Thank you for sending a postcard!\n";
- print "<p>\n";
- print "\"$password\" is the password we send to $receiver_input.\n";
- print "<br><font size=\"-1\">(<a target=\"_top\" href=\"../receive/\">have a look yourself,</a>)</font>\n";
- print "</td>\n";
- print "</tr>\n";
- print "<tr>\n";
- print "<td align=\"left\" valign=\"center\">\n";
- print "<a target=\"_top\" href=\"../\">Back To The Postcards Page</a>\n";
- print "</td>\n";
- print "</tr>\n";
- print "</table>\n";
-
- print "</BODY></HTML>\n";
-
-
- sub makeFileName {
-
- if ( $receiver_input =~ /^([^\@]*)\@([^\.]*)\.(.*)/ ) {
- $base = $1;
- $domain = $2;
- $country = $3;
- }
- else {
- print "Location: try_again.html\n\n";
- exit 0;
- }
-
- if (! ((length($base) gt 0) && (length($domain) gt 0) && (length($country) gt 0)) ) {
- print "Location: try_again.html\n\n";
- exit 0;
- }
-
- srand();
- $status=1;
- while ($status) {
- $number = int(rand(9999)) + 1;
- $password = $base."_".$number;
- $file = $dir.$password;
- $file = $file.$extension;
- if ( !(-e $file) ) {
- # ***** possible LOOP, after 9999 files it looks further!
- $status=0;
- }
- }
- }
-
- sub sendMail {
-
- push (@out, "\n");
- push (@out, "$sender_input send you a postcard!\n\n");
- push (@out, "You can pick it up in the Internet 1996 World Exposition.\n");
- push (@out, "(http://park.org/)\n");
- push (@out, "The address were to find your postcard is:\n\n");
- push (@out, " http://amsterdam.park.org/Postcards/\n\n");
- push (@out, "Your password is:\n\n");
- push (@out, " $password\n\n");
- push (@out, "Thank You!\n\n\n");
- push (@out, "----------------------------------------------------------\n\n");
- push (@out, "This message is automatically generated from the web.\n");
- push (@out, "It is from the Internet 1996 World Exposition.\n");
- push (@out, "We are *not* responsible for this mail\n");
- push (@out, "and the content of your postcard.\n\n");
- push (@out, "----------------------------------------------------------\n\n");
-
- open(MAIL, "|/usr/ucb/mail -s postcard $receiver_input");
- print MAIL "@out";
- close(MAIL);
-
- }
-
- sub writeToFile {
-
- open (W_FILE, ">>$file");
-
- print W_FILE "<HTML><HEAD><title>Flower Postcards</title></HEAD>\n";
- print W_FILE "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#000000\" ALINK=\"#000000\" VLINK=\"#000000\"> \n";
-
- print W_FILE "<table cellspacing=\"10\" cellpadding=\"0\" width=\"100%\">\n";
- print W_FILE "<tr>\n";
- print W_FILE "<td rowspan=\"4\">\n";
- print W_FILE "</td>\n";
- print W_FILE "<td align=\"center\" valign=\"center\" width=\"60%\">\n";
- 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";
- print W_FILE "This is your postcard from <b>$sender_input</b>!<br>\n";
- print W_FILE "</td>\n";
- print W_FILE "<td rowspan=\"4\">\n";
- print W_FILE "</td>\n";
- print W_FILE "</tr>\n";
- print W_FILE "<tr>\n";
- print W_FILE "<td align=\"center\" valign=\"center\" width=\"60%\">\n";
- print W_FILE "<img src=\"../createPostcard.cgi?$message_input+$postcard_input\" alt=\"Generating postcard, please wait...\">\n";
- print W_FILE "</td>\n";
- print W_FILE "</tr>\n";
- print W_FILE "<tr>\n";
- print W_FILE "<td align=\"center\" valign=\"center\" width=\"525\">\n";
- print W_FILE "<pre><i>$text_input</i></pre>\n";
- print W_FILE "</td>\n";
- print W_FILE "</tr>\n";
- print W_FILE "<tr>\n";
- print W_FILE "<td align=\"left\" valign=\"center\" width=\"525\">\n";
- print W_FILE "<font size=\"-1\">\n";
- print W_FILE "<a href=\"../\">Back To The Postcards Page</a><br>\n";
- print W_FILE "<a href=\"/\">To The Internet 1996 World Exposition!</a><br>\n";
- print W_FILE "</font>\n";
- print W_FILE "</td>\n";
- print W_FILE "</tr>\n";
- print W_FILE "</table>\n";
-
- print W_FILE "</BODY></HTML>\n";
-
- close(W_FILE);
- }
-