#! /usr/bin/perl # # WEB-IT Internet Services # Guestbook ver 1.1 #-------------------------------------------------------------------# # Installation Instructions: #----------------------------- # # 1: change the settings below to what your settings are!!! # 2: Copy this file guestbook.pl to your cgi-bin # 3: Copy the guestbook.html and add.html to a separate directory # eg /guestbook/ # 4: chmod guestbook.pl to 755 # 5: chmod guestbook.html and add.html to 777 # 6: chmod /guestbook/ to 777 # 7: change all of the settings below to your servers settings # 8: make sure to set add.html to call guestbook.pl #-------------------------------------------------------------------# # This program is Freeware and shall be distributed freely # Do not change the Header/Credits in any way. # # WEB-IT Internet Services # http://webit.ml.org/ # e-mail webit@iname.com # # WEB-IT CGI Scripts Archive: # http://webit.ml.org/scripts/ # e-mail webit@iname.com # #-------------------------Server Settings-----------------------------# # UNIX path of Guestbook.html $guestbook_file = "/usr/www/denis/guestbook/guestbook.html"; # URL to guestbook.html $guestbook_url = "http://www.ibl.ru/denis/guestbook/guestbook.html"; # TITLE of the website $site_name = "GALLERY OF TRAKTIR"; # Your E-mail address $your_email = "denis@ibl.ru"; #-----------------------------Settings---------------------------------# $top = 1; # 1 = add to top 0 = add to bottom $allow_html = 1; # 1 = allows html 2 = does not allow html 0 = dont $redirect = 1; # 1 = redirect to guestbook 0 = print return page # Run Program @day = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); # Get input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Parse data @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # do the unencoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if(! $allow_html) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; } &incomplete unless $FORM{'name'}; &incomplete unless $FORM{'city'}; &incomplete unless $FORM{'location'}; &incomplete unless $FORM{'comments'}; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); $mon += 1; #$month1 = $mon; if($mon = 1) { $month1 = "January"; } elsif($mon = 2) { $month1 = "February"; } elsif($mon = 3) { $month1 = "March"; } elsif($mon = 4) { $month1 = "April"; } elsif($mon = 5) { $month1 = "May"; } elsif($mon = 6) { $month1 = "June"; } elsif($mon = 7) { $month1 = "July"; } elsif($mon = 8) { $month1 = "August"; } elsif($mon = 9) { $month1 = "September"; } elsif($mon = 10) { $month1 = "October"; } elsif($mon = 11) { $month1 = "November"; } elsif($mon = 12) { $month1 = "December"; } else { $month1 = "Not Available"; } $date = "$day[$wday], the $mday. of $month1 19$year\n"; open(GUESTBOOK, "$guestbook_file") || die "Can't open GUESTBOOK: $guestbook_file\n"; @guestbook =; close(GUESTBOOK); open(GUESTBOOK, ">$guestbook_file") || die "Can't open GUESTBOOK: $guestbook_file\n"; foreach $line (@guestbook) { if($line =~ //i) { if($top) { print GUESTBOOK "\n"; } print GUESTBOOK "
\n"; if($FORM{'email'}) { print GUESTBOOK "
$FORM{'name'} - $FORM{'city'}, $FORM{'location'}\n"; } else { print GUESTBOOK "From: $FORM{'name'}
\n"; } if($FORM{'url'}) { print GUESTBOOK "
Homepage : $FORM{'htitle'}\n"; } print GUESTBOOK "

    \n"; print GUESTBOOK "$FORM{'comments'}\n"; print GUESTBOOK "

\n"; print GUESTBOOK "

\n"; print GUESTBOOK "signed on $date at $hour:$min:$sec\n"; print GUESTBOOK "\n"; print GUESTBOOK "

\n"; print GUESTBOOK "
\n"; if(! $top) { print GUESTBOOK "\n"; } } else { print GUESTBOOK "$line"; } } close(GUESTBOOK); if($redirect) { print "Location: $guestbook_url\n\n"; } else { print "Content-Type: text/html\n\n"; print qq!

Your GuestBook Entry has been Submited\!

Your guestbook entry has been successfully added to the guestbook. You may need to click reload to view your guestbook entry.

!; } sub incomplete { print "Content-Type: text/html\n\n"; print qq!

Incomplete Form\!

One of the Required Fields Was not filled in. Please press the back button on your browser and try again.

The following fields are required name,address,city,country,email,website

!; die; }