#!/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) $template = "template.tmp"; # template file $data_file = "datastore.dat"; # Where to read the options that aren't hardcoded $pws = "password.psw"; # Location of the password file. $password = "password.psw"; # Location of the password file. 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); # 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; open (PASSWRD, "$password") || die("Error opening the password file.\n"); $passstore=; close(PASSWRD); if ((length($FORM{password}) < 1) || $passstore ne $FORM{password}){ print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "$title\n"; print "\n"; print "
Make your own free website on Tripod.com
\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; print "
"; print "Password:
\n"; print "\n"; print "
\n"; print "\n"; exit; } if ($FORM{data} eq 'write'){ if (length($FORM{temp}) < 1){ 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 "Error. You must specify a template.\n"; print "\n"; print "\n"; exit; } open(PASSFILE, "$pws") || die("Error reading password file.\n"); $pass_store=; close(PASSFILE); if ($FORM{password} ne $pass_store){ 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 "Error. Incorrect password entered.\n"; print "\n"; print "\n"; exit; } open(TEMPLATEFILE, ">$template") || die("Error opening template file for output.\n"); print TEMPLATEFILE $FORM{temp}; 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 "Template Succesfully written to.\n"; print "\n"; print "\n"; exit; close(TEMPLATEFILE); } else { open(TEMPLATEFILE, "$template") || die("Error reading template file.\n"); @DATA=; $SIZE=@DATA; for($i=0;$i<=$SIZE;$i++){ $newdata="$newdata$DATA[$i]"; } close(TEMPLATEFILE); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "$title\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "$banneralt
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "Use this form to modify the template.
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "Password:
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; exit; }