[ Main page | Products | Tech Tips | Computer books | Opinions | ... ]
The simple board
Here are the sources of my message board. For an example in action see My message board.
The message board is written in PERL as a CGI script. Is is supposed to work on LINUX with Apache server and NT with IIS server, everything
else has not been tested.
It has the following features:
Ok. The board is given for free, and you are allowed to use it at your own risk.
Here you can dowload the script as a zip archive.
if you have problems with the zip file format, you can also download all files as is:
- you can add smileys to your Messages (very important !)
- The data is stored in files on the disk (no database, no mysql).
- Files are locked/has file locking.
- It should be easy to setup the board (there were some tradeoffs between speed and
ease-of-setup in favor of the later).
- Should be scalable.
The file listing:
ok, now you want to use this stuff. First of all congratulations, best wishes and all such stuff.
Now we are almost there. Now you should be able to run the administration script.
- in board.pl and admin.pl edit the following lines.
(These parameters have to be changed for your place).
There are also some optional parameters you can change:
### URL path where this script resides (+gifies for smilies).
### (can also be a relative url)
### Where are the datafiles stored in ?
### URL path where gif's are stored.
### background color of table headers
### 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'";
### How many subjects are listed in one page
- The first line in board.pl and admin.pl is as follows:
#!/usr/bin/perl - check that this is the place where the PERL runtime can be found on the server.
- If you are editing the files on a windows machine: Check if your editor did not
turn control-linefeed characters into the perl files.
download this a small command line program that strips control characters from the file.
- Upload the files via FTP onto a directory on your WEB server
- Set the execute permission for both board.pl and admin.pl files.
This can be done from your FTP client.
- Check that the data directory has write permission. (See parameter $DATADIR in the script)
- In your WEB browser: write the following URL.
- If everything goes well (as it should have):
First thing you do is to change the administrators password to something personal.
- Next thing is to add some message board.
- Now you can access you board as the url:
... keeps tracks of changes.
- 3/11/01 - Fixed bugs: Allow HTML in message body (still remove table tags - they can upset the layout);
Strip whitespaces from message body - no trailing empty lines;
When you reply to a message, the subject field is initialised with Re: text-of-message-to-reply-to (this is for new messages,the title is part of a url);
remove the magic string from the page title;
Add message - remove global variables from code (now code can be
reused with the community page project)
Administration: change how interface looks; when a thread or board
is deleted, the data files are deleted too;
now when a message is deleted, the counter of messages is updated;
do you trust a project with a large number of changes/fixes -
probably you think 'what a joker - he can't even make a message board right :-)
... but, if i can maintain my own PERL code, then i am worth something :-)
well, the truth is that this was just a very lonely weekend, and this script is a handy tinker toy :-(
- 30/09/01 - Fixed bug: add a subject with empty header caused problems.
added the script parameter $GIFDIR - directory for GIF files;
added the script parameter $ENCODING - character set used.
- 01/02/01 - Don't include title of board in URL.
Change of format: board_<nnn>.data - the first line is not the title of the board.
Display date of last message in main page. (allboards.data contains dat of last message.)
- 18/01/00 - The main page now counts the number of messages in each board.
- 29/12/00 - Bug: new message without subject caused damage.
Scrolling of subjects (new script parameter $SUBJECTSPAGESIZE)
File locking with flock improved.
- 27/12/00 - first revision (my first non trivial PERL CGI script ;-)
What i have learned
never wrote CGI stuff in PERL before (well nothing as large as this)
- i don't like the perl syntax for passing parameters to functions
$_,$_,$_ is a bad bad thing. (i would have liked names)
now go figure what you did last month...
- as a result people start to use global variables for passing parameters.
now go figure what you did last month...
- the nice thing about PERL are the regular expressions, but here i say nothing new.
and the way that variables are quoted in text blocks - for easy report/html generation.
- it helps enormously to have well formated HTML code - (like indented table tags).
much more readable and changeable (here you don't have the luxury of an HTML editor).
- The bigest pain: when you duplicate information in files/(tables). With SQL you
have a common syntax for operations; when you do files, you have to reuse the functions that modify the files.
Now comes PERL's disadvantage with function calls, and the very strange way
they do modules (all because of those stupid scoping rules)....