#!/usr/local/bin/perl # ######################################################################### # # Perl Guestbook: By Ackbar # # ######################################################################### # # This is a simple guestbook script (configured specificly for # # http://rebeccasghost.cjb.net # # ######################################################################### # # This code is free and may be redistributed as you please as long as these # # comments remain. Otherwise you will be asked to remove it. (unless I say # # you can take credits out :) # # ######################################################################### # # all options (0 = no) (1 = yes) $url = "http://rebeccasghost.cjb.net"; # This is the address of the homepage $faq = "faq.html"; # This is the address of the faq $datafile = "guests.dat"; # Where to guests info is stored :) $data_file = "datastore.dat"; # Where to read the options that aren't hardcoded $cntfile = "guests.cnt"; # Where the # of guests is stored :) $gbookurl = "sign.html"; # Address of the guestbook. $owneremail = "you\@you.com"; # Email addy of the owner of the guestbook :) $mailprog = '/usr/lib/sendmail'; $showfaq = 1; # Whether or not to show the faq $showurl = 1; # Whether or not to show the url $logip = 1; # This logs the ip. $emailowner = 0; # Owner will recieve an email when a guest submits a comment $personalmsg = 1; # Personal message (allows users to post a message only # the owner may see. # These are the requirements. Set what you do and don't want required here. 0 = not required # 1 = required # don't bother with the owner only comments cause thats optional to the user. # Read_Request function. This will let me strip appart pieces and read them so # I know what is being passed for each piece of info. Then we write it all to # a nice file. sub Read_Request{ if ($ENV{'CONTENT_LENGTH'} > 0){ read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @fields = split (/&/, $buffer); } else { $_ = "$ENV{'QUERY_STRING'}"; @fields = split (/&/, $_); } foreach $field (@fields){ ($name, $value) = split (/=/, $field); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } &Read_Request; $email = $reqemail; $name = $reqname; $url = $requrl; $age = $reqwwwname; $how = $reqhow; $comments = $reqcomments; # Right away we check to see if the person submitted a name and comments. # if not we give them an error cause that info is sort of neccisary. open (FILES,"$data_file") || die("Can't Open $datafile - for input\n"); $data=; chop($data); ($email, $title, $toptable, $bottomtable, $toptext, $bottomtext, $gnumber, $reqemail, $reqname, $requrl, $reqwwwname, $reqfound, $reqcomments, $sendemail, $logip, $topbanner, $bannerwidth, $bannerheight, $banneralt, $viewgrx, $viewwidth, $viewheight, $viewalt, $signgrx, $signwidth, $signheight, $signalt)=split(/õ/,$data); close(FILES); &no_name unless $FORM{name}; &no_email unless $FORM{email}; &no_url unless $FORM{url}; &no_how unless $FORM{how}; &no_age unless $FORM{age}; &no_comments unless $FORM{comments}; # Lets open the data file and see how many lines there are :) open (FILE,"$datafile") || die ("Can't Open $datafile.\n"); @LINES=; close(FILE); $SIZE=@LINES; # Now it's time to add onto the actual guestbook dat file :) # PS. syntax in dat file =: # NameõEmailõEmailõHome PageõHow FoundõAgeõCommentsõOwnerOnly # The OwnerOnly will be either a true or a false # if true then anyone can see the commnet, else only owner can view it # Read the options data sub no_comments { if ($reqcomments eq '1'){ print "Content-type: text/html\n\n"; print "No Comments\n"; print "
Make your own free website on Tripod.com

Your Comments appear to be blank

\n"; print "The comment section in the guestbook fillout form appears\n"; print "to be blank and therefore the guestbook addition was not\n"; print "added.

\n"; print "


\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } sub no_name { if ($reqname eq '1'){ print "Content-type: text/html\n\n"; print "No Name\n"; print "

Your Name appears to be blank

\n"; print "The Name Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added."; print "
\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } sub no_email { if ($reqemail eq '1'){ print "Content-type: text/html\n\n"; print "No Email\n"; print "

Your Email appears to be blank

\n"; print "The email Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added."; print "
\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } sub no_url { if ($requrl eq '1'){ print "Content-type: text/html\n\n"; print "No URL\n"; print "

Your url appears to be blank

\n"; print "The url Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added."; print "
\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } sub no_age { if ($reqwwwname eq '1'){ print "Content-type: text/html\n\n"; print "No Age\n"; print "

Your Age appears to be blank

\n"; print "The Age Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added."; print "
\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } sub no_how { if ($reqhow eq '1'){ print "Content-type: text/html\n\n"; print "No How you found this site\n"; print "

Your How you found the site appears to be blank

\n"; print "The How Found Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added."; print "
\n"; print "Return to the Guestbook."; print "\n\n"; exit; } } open(OLDGUESTS, "$datafile") || die("Can't open guestbook data file: $datafile - for input."); for($i=0;$i<=$SIZE;$i++){ $tmp_str=; $new_str = "$new_str$tmp_str"; } close(OLDGUESTS); $FORM{comments} =~ s/\n/
/ig; $FORM{comments} =~ s/\r//g; $DATA =~ s/\r//g; open(GUESTS, ">$datafile") || die("Can't open guestbook data file: $datafile - for output."); print GUESTS "$FORM{name}õ$FORM{email}õ$FORM{url}õ$FORM{how}õ$FORM{age}õ$FORM{comments}õ$FORM{forowner}õ$ENV{'REMOTE_ADDR'}\n"; print GUESTS "$new_str"; close(GUESTS); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "$title\n"; print "\n"; print "\n"; print "
\n"; print "$banneralt
\n"; print "\n"; print "\n"; print ""; print "
\n"; print "$signalt\n"; print "\n"; print "$viewalt\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "Name: $FORM{name}
"; print "
\n"; print "
\n"; print "\n"; print "Website: $FORM{age}
"; print "How You Found: $FORM{how}
"; print "Comments:
$FORM{comments}"; print "

\n"; print "
\n"; print "\n"; print ""; if ($sendemail == 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 to Guestbook\n\n"; print MAIL "You have a new entry in your guestbook:\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: $email\n"; print MAIL "From: $FORM{email}\n"; print MAIL "Subject: A User Has Signed Your Guestbook\n\n"; print MAIL "The Following Info Was submitted to your guestbook\n\n"; print MAIL "------------------------------------------------------\n"; print MAIL "$FORM{name}\n"; print MAIL "$FORM{email}\n"; print MAIL "$FORM{url}\n"; print MAIL "$FORM{age}\n"; print MAIL "$FORM{how}\n"; print MAIL "$FORM{comments}\n"; print MAIL "$ENV{'REMOTE_ADDR'}\n"; print MAIL "------------------------------------------------------\n"; close (MAIL); }