#!/bin/perl # noticeboard.cgi # Copyright Julian Baker 1999 $poetryFile="noticeboard.txt"; @days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); @months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%0D%0A/
/g; ### $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; $FORM{$name} = $value; } $dateCmd = '/bin/date'; chop ($jDate = `$dateCmd +"%j"`); chop ($mdyStamp = `$dateCmd +"%d/%m/%y"`); chop ($timeStamp = `$dateCmd +"%A %d %h %Y %H:%M %Z"`); chop ($dateStamp = `$dateCmd +"%y%m%d"`); if ($dateStamp <10000) { $dateStamp += 1000000; } # write to file if ($FORM{'comments'} ne "") { open(POETRYFILE, ">>$poetryFile") || die ("Can't open output file"); flock(POETRYFILE,2); print POETRYFILE "

\n"; if ($FORM{'realname'} eq ""){ print POETRYFILE "anon, $FORM{'username'}"; }else{ print POETRYFILE "$FORM{'realname'}, $FORM{'username'}"; } $ampm = ($hour >= 12) ? "pm" : "am"; $hour -= 12 if ($hour > 12); print POETRYFILE " $timeStamp\n\n"; print POETRYFILE "

$FORM{'comments'}

\n"; flock(POETRYFILE,8); close POETRYFILE; } #### display contents of file print "Content-type: text/html\n\n"; print<<_end_of_text_; mushimushi :: noticeboard
YOUR NAME: *

EMAIL ADDRESS:
mushimushi banter. . .
_end_of_text_ $total = -1; @lines = (); open(POETRYFILE, "$poetryFile") || die "Can't can't open $poetryFile$!"; flock(POETRYFILE,2); while () { push @lines, ($_); $total++ } flock(POETRYFILE,8); close POETRYFILE; @lines = reverse @lines; for($i=0; $i<=$total; $i++){ print "$lines[$i]"; } print<<_end_of_text_;
_end_of_text_ exit (0);