#!/usr/bin/perl ################################################################### # SCRIPT PARAMETERS (CHANGE HERE). ################################################################### ### URL path where this script resides (+gifies for smilies). ### (can also be a relative url) $SCRIPTDIR="/board"; ### Where are the datafiles stored in ? $DATADIR="./data"; ### background color of table headers $BGCOLORTBLHEAD="33CCFF"; ### title of all boards page $ALLBOARDS="Michael's Message Board"; ### style of fonts (is put into body tag of all generated files. $FONTSTYLE = "style='font-family:verdana,helvetica,ariel;font-size:11pt'"; ################################################################### ### HTTP Header string for HTML result $HTTPHEADER = "Content-type: text/html\n\n"; ### read POST parameters into global $CgiParam{$name} &parse_form; $DO = $CgiParam{"do"}; $BOARDID = $CgiParam{"id"}; ### change password if ($DO eq "pword"){ &CheckSecurity; &ChangePword; } ### no parameters - show listof message boards. elsif ($DO eq "newb"){ &CheckSecurity; &NewBoard; } ### delete a message board elsif ($DO eq "delb"){ &CheckSecurity; &DeleteBoard; } ### delete a whole thread elsif ($DO eq "delt"){ &CheckSecurity; &DeleteThread; } ### delete a message elsif ($DO eq "delm") { &CheckSecurity; &DeleteMessage; } else { &AdminBoard; } ## stupid security sub ChangePword { if (open(PASW,">$DATADIR/passw")) { $salt = crypt($CgiParam{'npassw'},"KuKuKuKu"); print PASW "$salt"; close(PASW); print "$HTTPHEADER
/g;
$msg =~ s/\n/
/g;
$msg =~ s/##//g;
$boardid = get_number("allboards.num");
### copy board list and put the new board first.
CreateIfNotThere("$DATADIR/allboards.data");
open(BOARD,"+<$DATADIR/allboards.data") || die "$HTTPHEADER Can't open allobards.data";
flock(BOARD,2); ## exclusive write lock
@lines=The message board has been added
";
}
### deletes a message board
sub DeleteBoard
{
### delete the entry from the list of all message boards.
open(BOARD,"+<$DATADIR/allboards.data") || die "$HTTPHEADER can't open allboards.data";
flock(BOARD,2); ## exclusive write lock
@lines=The message board has been deleted
";
}
### delete thread
sub DeleteThread
{
$THREADID = $CgiParam{"tid"};
$filename="$DATADIR/board_$BOARDID.data";
CreateIfNotThere($filename);
open(BOARD,"+<$filename") || die "$HTTPHEADER can't open $filename";
flock(BOARD,2); ## exclusive write lock
$BOARDTITLE=The thread has been deleted
";
}
### delete a message from a thread.
sub DeleteMessage
{
$THREADID = $CgiParam{"tid"};
$MSGID = $CgiParam{"mid"};
$DELALL = $CgiParam{"delall"} eq "on";
$threadfile = "$DATADIR/thread_$CgiParam{'id'}_$THREADID";
CreateIfNotThere("$threadfile.htm");
open(THREAD,"+<$threadfile.htm") || die "$HTTPHEADER Can't open file $threadfile";
flock(THREAD,2); ## exclusive write lock
@threadlines = The message has been deleted
";
}
### Update count of messages and date of last message
#
# $_[0] - data directory
# $_[1] - board id
#
# $_[2] - date string
#
# $_[3] - increment.
#
###
sub AddToBoardList
{
local(@boardlines,$filename,$line,$tid, $subject, $comment, $nummsg ,$date_time);
$filename="$_[0]/allboards.data";
CreateIfNotThere("$filename");
open(BOARD,"+<$filename") || die "$HTTPHEADER Can't open file $filename";
flock(BOARD,2); ## exclusive write lock
@boardlines=