in reply to simple message board gone very wrong?
I'd like to add flock to that, but I haven't quite gotten it working for some reason... Any suggestions welcome.#!/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/</</g; $NM::message =~ s/>/>/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 " \<<a href = 'mailto:$NM::email'>$NM::name</a>\>"; } else { print FH " \<$NM::name\>"; } 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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: simple message board gone very wrong?
by AgentM (Curate) on Dec 12, 2000 at 03:35 UTC | |
|
Re: Re: simple message board gone very wrong?
by turnstep (Parson) on Dec 12, 2000 at 07:49 UTC |