home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / the_web / documents / html / files / perl1.txt < prev    next >
Encoding:
Text File  |  1994-08-22  |  2.0 KB  |  78 lines

  1. ********BJSubmit********
  2. #!/bin/perl
  3.  
  4. #
  5. # BJsumbit  - perl script which allows submittals 
  6. #             of "Big Johnson" T-shirt phrases
  7. #
  8. # by: Eric Hall
  9. #
  10.  
  11. unshift(@INC,'/usr/local/etc/httpd/cgi-bin');
  12.  
  13. # Get the input
  14. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  15.  
  16. # Split the name-value pairs
  17. @pairs = split(/&/, $buffer);
  18.  
  19. # Uncommend for debugging purposes
  20. #print "Content-type: text/html\n\n";
  21.  
  22. foreach $pair (@pairs)
  23. {
  24.     ($name, $value) = split(/=/, $pair);
  25.  
  26.     # Un-Webify plus signs and %-encoding
  27.     $value =~ tr/+/ /;
  28.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  29.  
  30.     #want to skip submissions of default values
  31.     next if (grep(/\?\?\?\?\?/,$value));
  32.  
  33.     # Stop people from using subshells to execute commands
  34.     # Not a big deal when using sendmail, but very important
  35.     # when using UCB mail (aka mailx).
  36.     $value =~ s/~!/ ~!/g;
  37.  
  38.     # Uncomment for debugging purposes
  39.     #print "Setting $name to $value<P>";
  40.  
  41.     $FORM{$name} = $value;
  42. }
  43.  
  44. # If the comments are blank, then give a "blank form" response
  45. &blank_response unless $FORM{'name'};
  46. &blank_response unless $FORM{'phrase'};
  47.  
  48. # Print a title and initial heading
  49. print "Content-type: text/html\n\n";
  50. print "<Head><Title>Thank you</Title></Head>\n";
  51. print "<Body><H1><img src=http:/duck/gifs/Judit1.gif>Thank you</H1>\n";
  52. print "<p>Big Johnson is greatly appreciative of your suggestion.<br>\n";
  53. print "Click <a href=http:/duck/BigJohn.html>here</a> to see it active.\n";
  54.  
  55. $BJdir = "/usr/local/etc/httpd/htdocs/duck";
  56. rename("$BJdir/BigJohn.html","$BJdir/BigJohn.old");
  57. open (INS,"$BJdir/BigJohn.old");
  58. open (OUTS,">$BJdir/BigJohn.html");
  59.  
  60. #echo original to new
  61. while(<INS>) {
  62.  
  63.     #only when we've reached the end do we tack on the new stuff
  64.     if(grep(/--the end--/,$_)) {
  65.         print OUTS "<li><b>$FORM{'name'}</b> -\n";
  66.         print OUTS "$FORM{'phrase'}\n\n";
  67.     }
  68.     print OUTS;
  69.  
  70. } #end while
  71.  
  72. close(INS); close(OUTS);
  73.  
  74. chmod 0666, "$BJdir/BigJohn.old";
  75. chmod 0666, "$BJdir/BigJohn.html";
  76.  
  77. exit;
  78.