#!/usr/bin/perl #variables that will be used later. $guestbookreal = "/real/path/to/guestbook.html"; $return = "http://your.server.com/path/to/guestbook.html"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair(@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<\!\-\-.*\-\->//g; # get rid of SSI $in{$name} = $value; } open (FILE,"$guestbookreal"); @LINES=; chop (@LINES); close(FILE); $SIZE=@LINES; open (GUEST,">$guestbookreal"); for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; print GUEST "$_\n"; if (//) { if ($in{'email'} ne '') { print GUEST ""; print GUEST "$in{'name'}:
\n"; } else { print GUEST "$in{'name'}:
\n"; } if ($in{'www'} ne '') { print GUEST ""; print GUEST "$in{'www'}
\n"; } print GUEST "$in{'body'}

\n"; } } close (GUEST); print "Location: $return\n\n";