one phpBB2 for multiple boards

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

one phpBB2 for multiple boards

Post by ^rooker »

[PROBLEM]
For some unknown reason it seems impossible to run multiple forums with ONE installation of phpBB2 (the one we're using here).
One would have to install a copy of phpBB2 for EACH forum he's about to host on the same server which I personally consider a pain in the ass.

[SOLUTION]
take the "config.php" file in the root directory of the phpBB2 installation and modify it a little bit:

----------------------------------------------
<?php
$referer = $_SERVER["PHP_SELF"];
$slashcount = 2;
$slashpos = 0;

$dummy = $referer;

for($i=0; $i<=($slashcount); $i++) {
$n = strpos($dummy, "/");
$slashpos += $n;
// echo("(".$i."/".$n."/".$slashpos.") ".$dummy."<br>");
$dummy = substr($dummy, $n+1);
}
$slashpos += $i;
$choice = strtoupper(substr($referer, 1, ($slashpos-1)));

$destiny = "---";

$forum_prefix = "FORUM/";
$forum_name1 = "MYFORUM/";
$forum_name2 = "MYOTHERFORUM/";

$dbname="";
$dbuser="";
$dbpasswd="";

switch($choice) {
case $forum_prefix.$forum_name1:
$dbname = 'db_myforum';
$dbuser = 'myuser1';
$dbpasswd = '*****';
break;

case $forum_prefix.$forum_name1:
$dbname = 'db_myotherforum';
$dbuser = 'myuser1';
$dbpasswd = '*****';
break;

... // add several other boards here

default:
$dbname = 'wrong';
$dbuser = 'credentials';
$dbpasswd = 'chosen';
break;
}
-----------------------------------

Replace the beginning of the original config.php with the above code and you're it.
Post Reply