********BJSubmit********
#!/bin/perl
 
#
# BJsumbit  - perl script which allows submittals 
#             of "Big Johnson" T-shirt phrases
#
# by: Eric Hall
#
 
unshift(@INC,'/usr/local/etc/httpd/cgi-bin');
 
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 
# Split the name-value pairs
@pairs = split(/&/, $buffer);
 
# Uncommend for debugging purposes
#print "Content-type: text/html\n\n";
 
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
 
    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 
    #want to skip submissions of default values
    next if (grep(/\?\?\?\?\?/,$value));
 
    # Stop people from using subshells to execute commands
    # Not a big deal when using sendmail, but very important
    # when using UCB mail (aka mailx).
    $value =~ s/~!/ ~!/g;
 
    # Uncomment for debugging purposes
    #print "Setting $name to $value<P>";
 
    $FORM{$name} = $value;
}
 
# If the comments are blank, then give a "blank form" response
&blank_response unless $FORM{'name'};
&blank_response unless $FORM{'phrase'};
 
# Print a title and initial heading
print "Content-type: text/html\n\n";
print "<Head><Title>Thank you</Title></Head>\n";
print "<Body><H1><img src=http:/duck/gifs/Judit1.gif>Thank you</H1>\n";
print "<p>Big Johnson is greatly appreciative of your suggestion.<br>\n";
print "Click <a href=http:/duck/BigJohn.html>here</a> to see it active.\n";
 
$BJdir = "/usr/local/etc/httpd/htdocs/duck";
rename("$BJdir/BigJohn.html","$BJdir/BigJohn.old");
open (INS,"$BJdir/BigJohn.old");
open (OUTS,">$BJdir/BigJohn.html");
 
#echo original to new
while(<INS>) {
 
    #only when we've reached the end do we tack on the new stuff
    if(grep(/--the end--/,$_)) {
        print OUTS "<li><b>$FORM{'name'}</b> -\n";
        print OUTS "$FORM{'phrase'}\n\n";
    }
    print OUTS;
 
} #end while
 
close(INS); close(OUTS);
 
chmod 0666, "$BJdir/BigJohn.old";
chmod 0666, "$BJdir/BigJohn.html";
 
exit;
