#!/usr/bin/perl require "cgi-lib.pl"; &ReadParse; $bc = "/usr/bin/bc"; if ($ENV{'REQUEST_METHOD'} eq "POST") { $runmode = 1; #0 = display, #1 is action } else { $runmode = 0; #0 = display, #1 is action } if (($in{"url"} ne "") && (!($in{"url"} =~ m/^[a-zA-Z][a-zA-Z]*:/))) { $in{"url"} = "http://$in{'url'}"; } $currentnum = 0; $currentnum = &getNextNum; if ($runmode eq 1) { if ($in{"stage"} eq "preview") { &outputPageStart("Guest Book Preview"); print "
\n"; print "
***YOU'RE NOT DONE YET!!!***

\n"; print "
If you don't click \"Ok, ok, it's fine now. Enter it!\" below, your entry won't go into the guestbook!
\n"; print "
\n"; print "

Here's what your entry will look like if you enter it:

"; print &generateEntryHTML(%in); print "

If you want to touch it up, make changes then click Preview, otherwise click Enter It to save it

"; &outputForm("save",%in); &outputPageEnd; return; } open (GUESTBOOKRAW,">>guestbookraw.html"); print GUESTBOOKRAW &generateEntryHTML(%in); close(GUESTBOOKRAW); &outputPageStart("Guest Book"); print < Thank you for adding to our Guest Book! We appreciate it.

..Jeff & Laurie

Go back to the Guest Book to see your change!

EOT &outputPageEnd; open(GBNOTIFY, "| Mail -s \"Guest Book signed!\" jkeegan\@keegan.org,laurie\@keegan.org > /dev/null"); select(GBNOTIFY); # Next two lines took out on 9/11/2001 --JLK #print "From: ", $in{"email"}, " (", $in{"name"}, ")\n"; #print "Subject: Guest Book signed!\n\n"; print "Your Guest Book on keegan.org was signed!\n\n"; print " http://www.keegan.org/jeff/gb.cgi?#$currentnum\n\n"; print "NAME: ", $in{"name"}, "\n"; print "EMAIL: ", $in{"email"}, "\n"; print "URL: ", $in{"url"}, "\n"; print "COMMENTS: \n\n", $in{"comment"}, "\n"; print "\n\n"; #select(STDOUT); close(GBNOTIFY); # Added these next two lines on 6/12/2001 because I was getting: # # Warning: Option: AuthMechanisms requires SASL support (-DSASL) # Warning: Option: AuthMechanisms requires SASL support (-DSASL) # Warning: Option: AuthMechanisms requires SASL support (-DSASL) # # in the output.. --JLK, 6/12/2001 # close(STDOUT); close(STDERR); } else { &outputPageStart("Guest Book"); print < Welcome to Jeff & Laurie Keegan's Guest Book!

Here is our guest book. Please be sure to sign it!
(Jeff's old one was here)


EOT print < Please Sign In! EOT &outputForm("preview",%in); print < EOT open (GUESTBOOKRAW,"guestbookraw.html"); while ($nextline = ) { print $nextline; } close(GUESTBOOKRAW); print "


"; &outputPageEnd; } ############################################################# sub outputPageStart { local ($title) = @_; print < Jeff & Laurie's Page - $title
Our $title
EOT } sub outputPageEnd { print <
Jeff & Laurie's Page EOT } sub outputForm { local ($stage, %in) = @_; local ($submitText); if ($stage eq "preview") { $submitText = "Preview this / Sign Guestbook"; } else { $submitText = "Ok, ok, it's fine now. Enter it!"; } print <
Your Name:
Your Email Address:
(leave blank if you have none)
Your Web Page:
(leave blank if you have none)
Comment:

You can use
<I>...</I> for italics
and
<B>...</B> for bold.

EOT if ($stage eq "save") { print < EOT } print <
EOT } sub getNextNum { local ($retVal); $retVal = `grep '.*/\\1/g' | sort -n | tail -1`; if ($retVal eq "") { $retVal = "0"; } $retVal = `echo "1 + $retVal" | $bc`; chop($retVal); return $retVal; } sub generateEntryHTML { local (%in) = @_; local ($retVal); local ($dateStr); open (DATEPROC,"date|"); $dateStr = ; chop($dateStr); close(DATEPROC); $retVal .= "
\n"; $retVal .= "" . $dateStr . "
\n"; $retVal .= ""; if ($in{"url"}) { $retVal .= ""; } $retVal .= $in{"name"}; if ($in{"url"}) { $retVal .= ""; } $retVal .= "\n"; if ($in{"email"}) { $retVal .= "("; } $retVal .= $in{"email"}; if ($in{"email"}) { $retVal .= ")"; } $retVal .= "

\n"; $in{"comment"} =~ s!<[bB]>(.*?)!==JKB==\1==/JKB==!g; $in{"comment"} =~ s!<[iI]>(.*?)!==JKI==\1==/JKI==!g; $in{"comment"} =~ s/&/&/g; $in{"comment"} =~ s!!>!g; $in{"comment"} =~ s/:-?\)/:)/g; #$in{"comment"} =~ s/:-?\(/:(/g; #$in{"comment"} =~ s/:-?D/:D/g; $in{"comment"} =~ s/(\r\n|\n\r)(\r\n|\n\r)/

/g; $in{"comment"} =~ s/(\r\n|\n\r)/
/g; $in{"comment"} =~ s!==JKB==!!g; $in{"comment"} =~ s!==/JKB==!!g; $in{"comment"} =~ s!==JKI==!!g; $in{"comment"} =~ s!==/JKI==!!g; $retVal .= $in{"comment"}; $retVal .= "


\n"; $retVal .= "\n"; return $retVal; }