Lightweight forum PunBB
Introduction
This is a quick guide on setting up and customizing the light-weight, open-source
PunBB (1.3.4) forum application. This guide
will also show how to rely on PunBB to provide single-sign-on (SSO) so you can
combine PunBB with eg. a blog with a single authentication procedure.
Note that as of July 2010, the SQLite that PunBB supports is only V2 (Guess
it's the one that is compiled into the PHP binary.)
Setup
- Set up an SMTP mail server
- If you choose to save data in MySQL, first, set up and configure MySQL.
Create a database that will be used for PunBB:
- mysql> CREATE DATABASE punbb;
- mysql> CREATE USER 'punbbadmin'@'localhost' IDENTIFIED BY 'test';
- mysql> GRANT ALL PRIVILEGES ON punbb.* TO 'punbbadmin'@'localhost'
WITH GRANT OPTION;
- mysql> SHOW GRANTS FOR 'punbbadmin'@'localhost';
- mysql> EXIT
- # mysql -u punbbadmin -p
- mysql> EXIT
- From the PunBB site, download and untar the latest tarball onto the
server into its www directory:
- cd /var/www/
- wget -c http://punbb.informer.com/download/punbb-1.3.4.tar.gz
- tar xzvf punbb-1.3.4.tar.gz
- rm punbb-1.3.4.tar.gz
- mv punbb-1.3.4
punbb
- chown -R www-data.www-data ./punbb/
- Aim your browser at http://srv/forum/index.php,
and follow the instructions. You might need to chmod 777 ./cache
Note on database configuration when installing PunBB on a shared host at
French ISP www.free.fr:
- database location = sql.free.fr
- database username = same as account name
- database password = password you chose when creating account
- database name = same as account name (if your ISP only grants you a
single database for your account, you might want to add a table prefix eg.
punbb_)
- To manage database: log on,
and hit http://sql.free.fr/phpMyAdmin/
- SMTP server address: smtp.free.fr. Login/password not required
Administration
Log on to PunBB using the admin account that you created during setup.
Start
categories
forums
Settings
Users
Management
Maintenance mode
Extensions
http://punbb.informer.com/wiki/punbb13/extensions
Adding Daris Portal
- cd /var/ww/punbb/extensions/
- wget http://punbb.wiiem.pl/download_extensions/?f=portal_by_daris_2.4.3.zip
- unzip portal_by_daris_2.4.3.zip
- rm portal_by_daris_2.4.3.zip
- In PunBB, log on as Admin
- Administration > Extensions > Portal by Daris > Install extension
- Administration > Settings > Portal: Choose from which section
of the forum news articles will be fetched and displayed in the homepage,
and whether the panels will be displayed just in the homepage or on all
pages of the forum
- Administration > Start > Panels: Choose which panels are displayed
where
Data backup and restore
Customizing and development
Here's what you can do to customize PunBB once it's up and running:
- Add Davis Portal, and simplify homepage
- Main menu: remove User list, Example page (Administratin > Start
> Panels > Edit)
- Links: Add/remove links
- Homepage: (header.php) Remove Index/Forum/etc navigation bar + (footer.php)
simplify link to PunBB
- If one of the forums is meant to organize events, modify viewtopic.php
to include a button to (un)subscribe, and modify login.php
- Make some forums read-only (Administration > Start > Forum)
- Disable avatars
- Customize include/template/main.tpl
- Add SMTP server address: Administration > E-mail
- Rewrite "Welcome message"
- Manage e-mail activation when creating user account (Administration
> Settings > Registration)
- Change look 'n feel: http://punbb.informer.com/wiki/punbb13/styles
, Integrate
FluxBB 1.4 with a WordPress site
- Add support for other languages
- Add extensions to limit trolling and SPAM
Pages
Administration > Start > Pages
Panel File
Allow free-text description in users' profiles
Use Signature
Adding support for other languages
For French:
- cd ./lang
- wget -c http://punbb.informer.com/wiki/_media/punbb13/lang/punbb-1.3.4-francais.zip
- unzip punbb-1.3.4-francais.zip
- rm punbb-1.3.4-francais.zip
- Administration > Settings > Default language
Development
Hooks:
It appears like they go by pair, and anything between the two lines is included/excluded
depending on the result of the ternary operator. "hooks" : ./extensions/*/manifest.xml
Global
variables (common.php: $forum_page[], $forum_user[]
cache/cache_config.php: $forum_config[]
PunBB to provide single sign-on (SSO)
Here's a script to check if the user logged on, and if not, display a form
that will call PunBB's login.php, authenticate the user against the PunBB database,
and redirect the user to the root of the site:
- <html>
-
- <head>
- <link
type="text/css" rel="stylesheet" media="all"
href="/default.css" />
- </head>
-
- <body>
- <?php
- define('FORUM_ROOT', './forum/');
- require FORUM_ROOT.'include/common.php';
-
- // Where will we go after login?
- $forum_page['redirect_url'] = '/';
- $forum_page['form_action'] = forum_link($forum_url['login']);
- $forum_page['hidden_fields'] = array(
- 'form_sent'
=> '<input type="hidden" name="form_sent"
value="1" />',
- 'redirect_url'
=> '<input type="hidden" name="redirect_url"
value="'.forum_htmlencode($forum_page['redirect_url']).'" />',
- 'csrf_token'
=> '<input type="hidden" name="csrf_token"
value="'.generate_form_token($forum_page['form_action']).'" />'
- );
-
- //Already logged on
- if(!$forum_user['is_guest']) {
- $user
= htmlspecialchars($forum_user['username']);
- print
"Hi $user!";
- print
'<a href="'.forum_link($forum_url['logout'], array($forum_user['id'],
generate_form_token('logout'.$forum_user['id']))).'&redirect=1">'.$lang_common['Logout'].'</a>';
-
- //Not logged on
- } else {
- ?>
- <form
method="post" action="<?php echo $forum_page['form_action']
?>">
- <?php
echo implode("\n\t\t", $forum_page['hidden_fields'])."\n"
?>
-
- Username:
- <input
type="text" id="fld1" name="req_username"
value="" />
- <br
/>
-
- Password:
- <input
type="password" id="fld2" name="req_password"
value="" />
- <br
/>
-
- <input
type="checkbox" id="fld3" name="save_pass"
value="1" />
- <label
for="fld3">Log me in automatically each time I visit.</label>
- <br
/>
-
- <input
type="submit" name="login" value="Login" />
- </form>
- <?php
- }
- ?>
-
- </body>
- </html>
Reading user information
In case you're using PunBB to authenticate users, here's how to read user-related
infos as provided by PunBB through a session ID:
- <?php
-
- define('FORUM_ROOT', '/var/www/punbb/');
- require FORUM_ROOT.'include/common.php';
-
- echo("<pre>");
- print_r($forum_user);
- echo("</pre>");
-
- ?>
Q&A
How to stop spamming and trolling?
anti-troll (Antispam
System 1.3.4), anti-spam (Stop spam from bots 0.2) + secure site
Does PunBB support private messaging?
Resources