View Full Version : Guestbook troubles
summerrains
03-31-2002, 10:02 PM
I can't get my guestbook to work. It always comes up with an error message when you submit. The url is http://www.summerrains.com/addguest.html if someone could check it out and let me know what's wrong I'd be forever greatful!:D
Stewart
03-31-2002, 10:23 PM
hmmm, H:\MelissaWeb\summerrains\addguest.html is the url on your local machine, you need to upload it to your website so we can see the code.
summerrains
03-31-2002, 11:47 PM
woops... sorry, I didn't realize I posted that url (embarrassment). The url I meant to post is http://www.summerrains.com/addguest.html. Thanks.
Stewart
04-01-2002, 06:45 AM
i think you'll find that you have an error in the perl script you have got. an internal server error is usually caused by the actual perl script. Post the script, and I'll check it out to make sure its configured properly.
summerrains
04-06-2002, 10:40 PM
Do you want me to post the acctual script here? Or just give a link?
Stewart
04-06-2002, 10:50 PM
yeah, you'll need to post the source here, we cannot see it to check it if you dont post it here.
El_Nino
04-06-2002, 11:07 PM
Check your error log to see if that can give you any information on whats wrong with the script.
summerrains
04-11-2002, 04:20 PM
#!/usr/bin/perl
##############################################################################
# Guestbook Version 2.3.1 #
# Copyright 1996 Matt Wright mattw@worldwidemart.com #
# Created 4/21/95 Last Modified 10/29/95 #
# Scripts Archive at: http://www.worldwidemart.com/scripts/ #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1996 Matthew M. Wright All Rights Reserved. #
# #
# Guestbook may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from any liability that #
# might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact.#
##############################################################################
# Set Variables
$guestbookurl = "http://www.summerrains.com/gbook.htm";
$guestbookreal = "/home/summerr/public_html/gbook.htm";
$guestlog = "/home/summerr/public_html/guestlog.html";
$cgiurl = "http://www.summerrains.com/public_html/cgi-bin/guestbook.pl";
$date_command = "/usr/bin/date";
# Set Your Options:
$mail = 0; # 1 = Yes; 0 = No
$uselog = 1; # 1 = Yes; 0 = No
$linkmail = 1; # 1 = Yes; 0 = No
$separator = 1; # 1 = <hr>; 0 = <p>
$redirection = 0; # 1 = Yes; 0 = No
$entry_order = 1; # 1 = Newest entries added first;
# 0 = Newest Entries added last.
$remote_mail = 0; # 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/lib/sendmail';
$recipient = 'melissa@summerrains.com';
# 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/<!--(.|\n)*-->//g;
if ($allow_html != 1) {
$value =~ s/<([^>]|\n)*>//g;
}
$FORM{$name} = $value;
}
# Print the Blank Response Subroutines
&no_comments unless $FORM{'comments'};
&no_name unless $FORM{'realname'};
# Begin the Editing of the Guestbook File
open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
@LINES=<FILE>;
close(FILE);
$SIZE=@LINES;
# Open Link File to Output
open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (/<!--begin-->/) {
if ($entry_order eq '1') {
print GUEST "<!--begin-->\n";
}
if ($line_breaks == 1) {
$FORM{'comments'} =~ s/\cM\n/<br>\n/g;
}
print GUEST "<b>$FORM{'comments'}</b><br>\n";
if ($FORM{'url'}) {
print GUEST "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>";
}
else {
print GUEST "$FORM{'realname'}";
}
if ( $FORM{'username'} ){
if ($linkmail eq '1') {
print GUEST " \<<a href=\"mailto:$FORM{'username'}\">";
print GUEST "$FORM{'username'}</a>\>";
}
else {
print GUEST " <$FORM{'username'}>";
}
}
print GUEST "<br>\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<hr>\n\n";
}
else {
print GUEST " - $date<p>\n\n";
}
if ($entry_order eq '0') {
print GUEST "<!--begin-->\n";
}
}
else {
print GUEST $_;
}
}
close (GUEST);
summerrains
04-11-2002, 04:20 PM
# 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 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: $FORM{'username'}\n";
print MAIL "From: $recipient\n";
print MAIL "Subject: Entry to Guestbook\n\n";
print MAIL "Thank you for adding to my 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);
}
# 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 "<html><head><title>No Comments</title></head>\n";
print "<body><h1>Your Comments appear to be blank</h1>\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. Please enter your comments below.<p>\n";
print "<form method=POST action=\"$cgiurl\">\n";
print "Your Name:<input type=text name=\"realname\" size=30 ";
print "value=\"$FORM{'realname'}\"><br>\n";
print "E-Mail: <input type=text name=\"username\"";
print "value=\"$FORM{'username'}\" size=40><br>\n";
print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" ";
print "size=15>, State: <input type=text name=\"state\" ";
print "value=\"$FORM{'state'}\" size=15> Country: <input type=text ";
print "name=\"country\" value=\"$FORM{'country'}\" size=15><p>\n";
print "Comments:<br>\n";
print "<textarea name=\"comments\" COLS=60 ROWS=4></textarea><p>\n";
print "<input type=submit> * <input type=reset></form><hr>\n";
print "Return to the <a href=\"$guestbookurl\">Guestbook</a>.";
print "\n</body></html>\n";
# Log The Error
if ($uselog eq '1') {
&log('no_comments');
}
exit;
}
sub no_name {
print "Content-type: text/html\n\n";
print "<html><head><title>No Name</title></head>\n";
print "<body><h1>Your Name appears to be blank</h1>\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. Please add your name in the blank below.<p>\n";
print "<form method=POST action=\"$cgiurl\">\n";
print "Your Name:<input type=text name=\"realname\" size=30><br>\n";
print "E-Mail: <input type=text name=\"username\"";
print " value=\"$FORM{'username'}\" size=40><br>\n";
print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" ";
print "size=15>, State: <input type=text name=\"state\" ";
print "value=\"$FORM{'state'}\" size=2> Country: <input type=text ";
print "value=USA name=\"country\" value=\"$FORM{'country'}\" ";
print "size=15><p>\n";
print "Comments have been retained.<p>\n";
print "<input type=hidden name=\"comments\" ";
print "value=\"$FORM{'comments'}\">\n";
print "<input type=submit> * <input type=reset><hr>\n";
print "Return to the <a href=\"$guestbookurl\">Guestbook</a>.";
print "\n</body></html>\n";
# Log The Error
if ($uselog eq '1') {
&log('no_name');
}
exit;
}
# Log the Entry or Error
sub log {
$log_type = $_[0];
open (LOG, ">>$guestlog");
if ($log_type eq 'entry') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]<br>\n";
}
elsif ($log_type eq 'no_name') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No Name<br>\n";
}
elsif ($log_type eq 'no_comments') {
print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No ";
print LOG "Comments<br>\n";
}
}
# Redirection Option
sub no_redirection {
# Print Beginning of HTML
print "Content-Type: text/html\n\n";
print "<html><head><title>Thank You</title></head>\n";
print "<body><h1>Thank You For Signing The Guestbook</h1>\n";
# Print Response
print "Thank you for filling in the guestbook. Your entry has\n";
print "been added to the guestbook.<hr>\n";
print "Here is what you submitted:<p>\n";
print "<b>$FORM{'comments'}</b><br>\n";
if ($FORM{'url'}) {
print "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>";
}
else {
print "$FORM{'realname'}";
}
if ( $FORM{'username'} ){
if ($linkmail eq '1') {
print " <<a href=\"mailto:$FORM{'username'}\">";
print "$FORM{'username'}</a>>";
}
else {
print " <$FORM{'username'}>";
}
}
print "<br>\n";
if ( $FORM{'city'} ){
print "$FORM{'city'},";
}
if ( $FORM{'state'} ){
print " $FORM{'state'}";
}
if ( $FORM{'country'} ){
print " $FORM{'country'}";
}
print " - $date<p>\n";
# Print End of HTML
print "<hr>\n";
print "<a href=\"$guestbookurl\">Back to the Guestbook</a>\n"; print "- You may need to reload it when you get there to see your\n";
print "entry.\n";
print "</body></html>\n";
exit;
}
El_Nino
04-11-2002, 07:00 PM
Did you chmod the CGI script to 755 and the guestbook entry files to 666? If not, try doing that. If you did, try and add an entry and if you get an error message, look at the error log in your control panel and it should tell you what is wrong there
snapper
04-12-2002, 01:58 PM
Fixed already?
If no then:
$cgiurl = "http://www.summerrains.com/public_html/cgi-bin/guestbook.pl";
Probably should be:
$cgiurl = "http://www.summerrains.com/cgi-bin/guestbook.pl";
Hope it helps,
snapper
summerrains
04-13-2002, 01:30 AM
I changed the permissions and changed it to $cgiurl = "http://www.summerrains.com/cgi-bin/guestbook.pl"; but it still comes up with the following error message in the error log:
Sat Apr 13 00:26:56 2002] [error] [client 216.102.89.160] Premature end of script headers: /home/summerr/public_html/cgi-bin/guestbook.pl [Sat Apr 13 00:26:56 2002] [error] (2)No such file or directory: exec of /home/summerr/public_html/cgi-bin/guestbook.pl failed
Can anyone tell me what to do?
JustinSurfer
04-13-2002, 09:03 PM
Get a better guestbook, like the one from proxy2.de, example that can be found at http://www.itfconline.net/guestbook/
snapper
04-15-2002, 12:59 PM
Ok, lets look a little closer:
[error] (2)No such file or directory: exec of /home/summerr/public_html/cgi-bin/guestbook.pl failed
Means you still have path problems, use:
$date_command = "/bin/date";
rather than
$date_command = "/usr/bin/date";
Also check the paths you specify in the script are correct, ie. the HTML pages are in the root etc..
Just as a note be wary of setting the allow HTML flag, it's a common security issue in guestbooks - people can use java script in their posts and thus alter the behavior of your page.
Hope that nails it for ya,
snapper
summerrains
04-20-2002, 04:56 PM
I've changed the date command and made sure all files are there, but it still gives the error:
[Sat Apr 20 15:52:50 2002] [error] [client 216.102.89.160] Premature end of script headers: /home/summerr/public_html/cgi-bin/guestbook.pl [Sat Apr 20 15:52:50 2002] [error] (2)No such file or directory: exec of /home/summerr/public_html/cgi-bin/guestbook.pl failed
Any other suggestions on how to fix it?
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.