#!/usr/bin/perl ################################################################################################# #COBRA version 1.0, copyright 2000 by Michael K. Goode. #based on the guestbook script by bernard sowa : www.zonecoaster.com # #Copyright 2000 by Michael K. Goode# #Version Finish Date: 10 October 2000 #This script is free for use, distribution, and modification# #The only right I reserve is this header must remain intact, as long as the program# #is used for its original purpose (appending comments to a webpage).# #This header may be removed, if, and only if, a portion of the code is used in a program that does not# #fulfill the functions of this program# #The home of this script: http://www.mikegoode.com/web/scripts/# #please check there for any updates or upgrades or bug fixes and for help files# #my email address: mike@mikegoode.com# #if you have any good changes or additions, please email them to me,# #and I will add them to this program or add new versions of the program# #to my website and credit you.# ## #I am not responsible for any damage resulting from the use of this program# #and I make no guarentees about its performance, specific or implied# #I am also not able to help anyone with support, other than # #by providing some basic help info on my website.# ############################################################# # YOU CAN CHANGE ANYTHING BELOW THIS POINT TO YOUR HEART'S CONTENT# ############################################################# ###################################################################### ########################### # You must insert this line of html in your page right before you want the comments to appear: # #It is, however, included in the html form template, before the actual form ################################################################################################# #Configuration Section # #$basedir #The base directory onto which all user directories are appended. #Example: #Two typical users, jdoe and eodj have the following home directories(respectively) #/root/users/jdoe #/root/users/eodj #$basedir would be: $basedir='/root/users'; # #If you're setting it up for your own personal use, set this to your home directory. If you #have a public_html directory, include public_html in $basedir # #No trailing slash! # #$baseurl #The URL for the $basedir. No trailing slash! # # # #@required #Array containing a list of all of the fields that must be present in a form and which #must be filled in by a person signing the guestbook in order for the entry to be #added to the guestbook(required inputs from your form...) ################################################################################################# #the page that the comments will be added to is sent to the program in the form as a hidden input #see the html form template -- that hidden input must be changed to the relative position of the #page being appended each time the form is appended to a page. # #Also, before this program will work, it is necessary to chmod the program to world executable, #and to chmod the page that will have comments added to world writeable. # #In the form is another hidden input called 'bulleturl'; this is the location of the bullet .gif file #on your server. The bullet is printed at the left of the first line of each comment. #If you wish, you may set 'bulleturl' to '', and the program will not print anything # $basedir='/data/domains/mikegoode.com/public_html'; $baseurl='http://www.mikegoode.com'; @required=('realname','email'); #You do not need to change anything below this point. ################################################################################################# #Get Form Data ################################################################################################# &get_form_data; foreach $rfield (@required) #Check if required fields are filled out. If not, quit. { if($formdata{$rfield} eq "") { ++$bad; } } if($bad != "0") #if one or more of the required fields isn't filled in { print "Content-type: text/html\n\n"; print "\nError\n"; print "\n\n"; print "

At least one of the required fields was left blank or your email address was not accepted.\n"; print "

The required inputs are:\n

\n"; print "

\n

\n"; exit 0; } ################################################################################################# #Do stuff with it...ie. open the user's guestbook file and add the new entry to the top ################################################################################################# $page=$formdata{'page'}; #find out name of user's guestbook $pagename="$page"; $page="$basedir/$page"; open(PAGE, "$page") || print "Content-type: text/html\n\n Could not open $page"; @contents=;#get contents of Guestbook so you can add this entry to it. close(PAGE); open(PAGE2, ">$page"); foreach $line (@contents) { if($line =~ //)#print new entry after this line { print PAGE2 "$line\n\n"; print PAGE2 "<\!\-\-Begin Entry\-\->\n"; print PAGE2 "

\n
\n"; print PAGE2 "$formdata{'message'}\-\-\- From $formdata{'realname'}\n
\n"; print PAGE2 "[Mail Me"; &get_date; $nicedate="$nicedate"; if ($formdata{'homepage'} ne "") { print PAGE2 " \| Visit My Homepage][$nicedate]\n
\n"; } else { print PAGE2 "][$nicedate]\n
\n\n"; } #now print each of the input names and the user's input if it isn't empty #then print the comments last. print PAGE2 "
\n

\n"; print PAGE2 "\n

\n


\n


\n\n"; print PAGE2 "<\!\-\-End Entry\-\->\n"; } else { print PAGE2 $line; } } close(PAGE2); print "Content-type: text/html\n\n"; print "\nThank you\n"; print "\n\n"; print "Thank you for adding your comment. You can click "; print "here to see it."; print "
You may need to reload it to get an updated version which includes your entry."; print ""; exit; ################################################################################################# #Subroutines ################################################################################################# sub get_form_data { $buffer = ""; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$buffer); foreach $pair (@pairs) { @a = split(/=/,$pair); $name=$a[0]; $value=$a[1]; $name =~ s/\+/ /g; $deniedfile='/usr/local/www/bernard/denied.txt'; if($value=~/