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

  1. Set up an SMTP mail server
  2. If you choose to save data in MySQL, first, set up and configure MySQL. Create a database that will be used for PunBB:
    1. mysql> CREATE DATABASE punbb;
    2. mysql> CREATE USER 'punbbadmin'@'localhost' IDENTIFIED BY 'test';
    3. mysql> GRANT ALL PRIVILEGES ON punbb.* TO 'punbbadmin'@'localhost' WITH GRANT OPTION;
    4. mysql> SHOW GRANTS FOR 'punbbadmin'@'localhost';
    5. mysql> EXIT
    6. # mysql -u punbbadmin -p
    7. mysql> EXIT
  3. From the PunBB site, download and untar the latest tarball onto the server into its www directory:
    1. cd /var/www/
    2. wget -c http://punbb.informer.com/download/punbb-1.3.4.tar.gz
    3. tar xzvf punbb-1.3.4.tar.gz
    4. rm punbb-1.3.4.tar.gz
    5. mv punbb-1.3.4 punbb
    6. chown -R www-data.www-data ./punbb/
  4. 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:

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

  1. cd /var/ww/punbb/extensions/
  2. wget http://punbb.wiiem.pl/download_extensions/?f=portal_by_daris_2.4.3.zip
  3. unzip portal_by_daris_2.4.3.zip
  4. rm portal_by_daris_2.4.3.zip
  5. In PunBB, log on as Admin
  6. Administration > Extensions > Portal by Daris > Install extension
  7. 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
  8. 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:

  1. Add Davis Portal, and simplify homepage
  2. Main menu: remove User list, Example page (Administratin > Start > Panels > Edit)
  3. Links: Add/remove links
  4. Homepage: (header.php) Remove Index/Forum/etc navigation bar + (footer.php) simplify link to PunBB
  5. If one of the forums is meant to organize events, modify viewtopic.php to include a button to (un)subscribe, and modify login.php
  6. Make some forums read-only (Administration > Start > Forum)
  7. Disable avatars
  8. Customize include/template/main.tpl
  9. Add SMTP server address: Administration > E-mail
  10. Rewrite "Welcome message"
  11. Manage e-mail activation when creating user account (Administration > Settings > Registration)
  12. Change look 'n feel: http://punbb.informer.com/wiki/punbb13/styles , Integrate FluxBB 1.4 with a WordPress site
  13. Add support for other languages
  14. 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:

  1. cd ./lang
  2. wget -c http://punbb.informer.com/wiki/_media/punbb13/lang/punbb-1.3.4-francais.zip
  3. unzip punbb-1.3.4-francais.zip
  4. rm punbb-1.3.4-francais.zip
  5. 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']))).'&amp;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