I looked at MSA's board and there were a handful of things I didn't like about it. I'm no perl saint, but here's what I came up with as a quick & dirty:
#!/usr/bin/perl -w use CGI; use strict; my ($CGID, $i, $date); my $P = CGI::new(); $P->import_names('NM'); if ($0=~m#^(.*)\\#){ $CGID = "$1"; } elsif ($0=~m#^(.*)/# ){ $CGID = "$1"; } else {`pwd` =~ /(.*)/; $CGID = "$1"; } my $gb = "$CGID/../www/html/fan/fan_main.html"; open (FH, "$gb") || die "Can't Open $gb: $!\n"; my @LINES=<FH>; close(FH); my $SIZE=@LINES; my $minutes = (localtime)[1]; ($minutes = "0".$minutes) if ($minutes < 10); $date = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')[(localtime)[6]] . ', ' . ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')[(localtime)[4]] . " " . (localtime)[3] . ", " . ((localtime)[5] + 1900) . " at " . (localtime)[2] . ":" . (localtime)[1]; open (FH,">$gb") || die "Can't Open $gb: $!\n"; for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; if (/<!--begin-->/) { print FH "<!--begin-->\n"; $NM::message =~ s/(\S{20})/$1 /g; $NM::message =~ s/</&lt;/g; $NM::message =~ s/>/&gt;/g; $NM::message =~ s/\cM\n/<br>\n/g; print FH "<b>$NM::message</b><!-- $ENV{'REMOTE_HOST'} --><br>\n"; if ( $NM::email ){ print FH " \&lt;<a href = 'mailto:$NM::email'>$NM::name</a>\&gt;"; } else { print FH " \&lt;$NM::name\&gt;"; } print FH "<br>\n - $date<p><hr>\n\n"; } else { print FH $_; }} close (FH); open(FH, $gb) or die "Can't open $gb: $!"; local($/) = undef; my $template = <FH>; close(FH); print "Content-type: text/html\n\n$template"; exit (0);
I'd like to add flock to that, but I haven't quite gotten it working for some reason... Any suggestions welcome.

In reply to Re: simple message board gone very wrong? by cei
in thread simple message board gone very wrong? by jptxs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.