#!/usr/bin/perl # Guestbook for the World Wide Web # Created by Matt Wright Version 2.3.1 # Created on: 4/21/95 Last Modified: 10/29/95 #Modified by Kim Jahn on: 6/17/97 ############################################################################# # Set Variables $guestbookurl="http://www.pionet.net/~nwcc/test.htm"; $guestbookreal="/data/Lkr_Usr_/nwcc/public_html/test.htm"; $guestlog = "/data/Lkr_Usr_/nwcc/public_html/adlog.htm"; $cgiurl = "http://www.pionet.net/pionet-cgi-bin/users/nwcc/autoent.pl"; $date_command = "/usr/bin/date"; # Set Your Options: $mail = 1; # 1 = Yes; 0 = No $uselog = 1; # 1 = Yes; 0 = No $linkmail = 1; # 1 = Yes; 0 = No $separator = 1; # 1 =
$redirection = 1; # 1 = Yes; 0 = No
$entry_order = 1; # 1 = Newest entries added first;
# 0 = Newest Entries added last.
$remote_mail = 1; # 1 = Yes; 0 = No
$allow_html = 1; # 1 = Yes; 0 = No
$line_breaks = 0; # 1 = Yes; 0 = No
# If you answered 1 to $mail or $remote_mail you will need to fill out
# these variables below:
$mailprog = '/usr/sbin/sendmail';
$recipient = 'nwcc@pionet.net';
# Done
#############################################################################
# Get the Date for Entry
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
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;
$value =~ s///g;
if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
$FORM{$name} = $value;
}
# Print the Blank Response Subroutines
&no_comments unless $FORM{'comments'};
&no_phone unless $FORM{'phone'};
# Begin the Editing of the Ad File
open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
@LINES= \n\n";
}
if ($entry_order eq '0') {
print GUEST "\n";
}
}
else {
print GUEST $_;
}
}
close (GUEST);
# Log The Entry
if ($uselog eq '1') {
&log('entry');
}
#########
# Options
# Mail Option
if ($mail eq '1') {
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
print MAIL "From: $FORM{'username'} ($FORM{'realname'})\n";
print MAIL "Subject: Entry NWCC's Ad Site\n\n";
print MAIL "You have a new entry on your site:\n\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "$FORM{'realname'}";
if ( $FORM{'username'} ){
print MAIL " <$FORM{'username'}>";
}
print MAIL "\n";
if ( $FORM{'city'} ){
print MAIL "$FORM{'city'},";
}
if ( $FORM{'state'} ){
print MAIL " $FORM{'state'}";
}
if ( $FORM{'country'} ){
print MAIL " $FORM{'country'}";
}
print MAIL " - $date\n";
print MAIL "------------------------------------------------------\n";
close (MAIL);
}
if ($remote_mail eq '1' && $FORM{'username'}) {
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $FORM{'username'}\n";
print MAIL "From: $recipient\n";
print MAIL "Subject: Entry to NWCC Site\n\n";
print MAIL "Thank you for adding to our site.\n\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "$FORM{'realname'}";
if ( $FORM{'username'} ){
print MAIL " <$FORM{'username'}>";
}
print MAIL "\n";
if ( $FORM{'city'} ){
print MAIL "$FORM{'city'},";
}
if ( $FORM{'state'} ){
print MAIL " $FORM{'state'}";
}
if ( $FORM{'country'} ){
print MAIL " $FORM{'country'}";
}
print MAIL " - $date\n";
print MAIL "------------------------------------------------------\n";
close (MAIL);
}
# Print Out Initial Output Location Heading
if ($redirection eq '1') {
print "Location: $guestbookurl\n\n";
}
else {
&no_redirection;
}
#######################
# Subroutines
sub no_comments {
print "Content-type: text/html\n\n";
print " \n";
print " \n";
print "
\n/g;
}
print GUEST "$FORM{'comments'}
\n";
if ($FORM{'url'}) {
print GUEST "$FORM{'realname'}";
}
else {
print GUEST "$FORM{'realname'}";
}
print GUEST "$FORM{'phone'}";
if ( $FORM{'username'} ){
if ($linkmail eq '1') {
print GUEST " \<";
print GUEST "$FORM{'username'}\>";
}
else {
print GUEST " <$FORM{'username'}>";
}
}
print GUEST "
\n";
if ( $FORM{'city'} ){
print GUEST "$FORM{'city'},";
}
if ( $FORM{'state'} ){
print GUEST " $FORM{'state'}";
}
if ( $FORM{'country'} ){
print GUEST " $FORM{'country'}";
}
if ($separator eq '1') {
print GUEST " - $date
\n\n";
}
else {
print GUEST " - $dateYour Description appears to be blank
\n";
print "The Description section in the fillout form appears\n";
print "to be blank and therefore the addition was not\n";
print "added. Please enter your Description below.
\n";
print "Return to the Ad Page.";
print "\n\n";
# Log The Error
if ($uselog eq '1') {
&log('no_decription');
}
exit;
}
sub no_phone {
print "Content-type: text/html\n\n";
print "Your Phone Number appears to be blank
\n";
print "The Phone Number Section in the fillout form appears to\n";
print "be blank and therefore your entry was not\n";
print "added. Please add your Phone Number in the blank below.