## CGI BlackBoard in TCL V1.1
## by Pierre-Mikael Legris (Feb 27 1999 )
## Modification 17 May 2000
## perki@perki.org
##
## This sofware is free as long as it's
## not used for commercial matters
##
## For other applications feel free to use and/or modify this code
## As long as you leave credits to his author


*HomePage: http://www.perki.org/Tcl

*This BlackBoard is designed for the PostgreSQL database, 
*but it should be possible to port it easily for another DB. 
*(http://www.postgresql.org/)

*This has been tested with the apache web server

###### UNPACKAGING ########
#copy the BlackBoard dir in a place where you can access it 
#from your webserver. for example /home/httpd/htdocs/Tcl/BlackBoard

###### SETING UP APACHE ####### 
#locate the file httpd.conf  and add the folowing lines to enable 
#cgi execution on the BlackBoard dir.
<Directory "/home/httpd/htdocs/Tcl/BlackBoard">
 Options ExecCGI
</Directory>
# restart your webserver

# try to access the file "getinfos.cgi" from the web
# it should output numerous informations
# find the value of "USER" "LOGNAME" or "USERNAME" it is the name of the
# user who run the webserver. please note it.

###### SETING UP THE DATABASE

#for the folowing steps we assume that the user is named nobody

# first of all install postgresql and run postgres
# If you have to compile it be sure to compile 
# it with TCL SUPPORT
# once you're done verify you have libpgtcl.so installed
# normaly in /lib/libpgtcl.so

# BECOME ROOT
anyone bash$ su root
Password:
#BECOME POSTGRES
root bash$ su postgres
#NOW WE CREATE A DB AND A USER FOR IT
# change "nobody" to the name of the user which runs the httpd service
postgres bash$ createuser nobody
Enter user's postgres ID or RETURN to use unix user ID: 99 ->
Is user "nobody" allowed to create databases (y/n) n
Is user "nobody" a superuser? (y/n) n
createuser: nobody was successfully added
Shall I create a database for "nobody" (y/n) y

# GO BACK to ROOT
postgres bash$ exit

#BECOME NOBODY
root bash$ su nobody

#* CONNECT TO your DB postgres
bash$ psql
Welcome to the POSTGRESQL interactive sql monitor:
  Please read the file COPYRIGHT for copyright terms of POSTGRESQL
[PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66]
 
   type \? for help on slash commands
   type \q to quit
   type \g or terminate with semicolon to execute query
 You are currently connected to the database: nobody

#* CREATE THE black_b TABLE                                               

nobody=>create table black_b (id int4, date abstime, reply int4, author text, message text, subject text);
CREATE
#* ADD THE NULL ENTRY (THIS IS VERY IMPORTANT)
nobody=>insert into black_b (id,reply) values (0,0);
INSERT 18574 1
#* VERIFY EVRYTHINGS OK
nobody=> select * from black_b;
id|date|reply|author|message|subject
--+----+-----+------+-------+-------
 0|    |    0|      |       |
(1 row)    
#* OK DONE FOR THE DATABASE

########### EDIT board.lib in the BlackBoard directory

#Grant access to log.txt in this file all the messages are logged
#but the webserver must be able to write into it.
#2 solution you give log.txt to the user nobody
(As root) chown nobody log.txt
#Or you give write access to anyone (not a good solution)
chmod a+rw log.txt


########## Protecting the "DELETE" feature

# By default the login is "bb_admin" and the password "bb_passwd"

#I use the password system of apache look at the documentation
#about htaccess and how to set up users 

# Here is what to do to add a user to .htpasswd
> Go in the BlackBoard directory
bash$ htpasswd -c .htpasswd bb_admin
New password:
Re-type new password:
Adding password for user bb_admin
# now you have created the user bb_admin

> Edit protected/.htaccess to fit your needs

########## Seting up timed
# This part is needed if you decided to remve autotically threads older
# that a certain age. Or if you decided to mail a specific e-amil adress
# each day for incoming messages.

> Edit protected/cron.sh

> Edit mycron
# By default it is set as:
# 55 23 * * *  /home/httpd/htdocs/Tcl/BlackBoard/protected/cron.sh
# which means that each day at 23:55 the script cron.sh will be run.

> load your configuration in the crontab 
# this must be done by the httpd user (nobody)
# so become root and execute the folowing command:
root bash$ crontab -u nobody mycron
# try the folowing command to be sure it's done
root bash$ crontab -u nobody -l


## Well I wish evrythings OK ;)



