User:Rjhodson/phpBB Installation

From WolfTech
< User:Rjhodson
Revision as of 14:02, 12 October 2007 by Rjhodson (talk | contribs)
Jump to navigation Jump to search

PhpBB onto Engineering Servers

To add forum functionality to your site, you may wish to use pre-existing forum software. One such example is phpBB. PhpBB is a free, open-source, php-based internet forum software suite. Using phpBB on an Engineering server, however, requires a custom installation process.

Downloading phpBB

The first step to intalling phpBB on an engineering server is to download the most current stable release of phpBB2. Unzip this file to where you wish host the forum.

Compensating for basedir Restrictions

To compensate for basedir restrictions, you will have to copy the necessary included files to the subdirectories within the phpBB directory that calls them.

Both the install and admin directories need copies of the following:

  • the db directory
  • the includes directory
  • the language directory
  • the templates directory
  • the contrib directory (for the install directory only)
  • the common.php file
  • the extension.inc file
  • the config.php file

All instances of the PHP variable phpbb_root_path should be set to a blank state.

$phpbb_root_path = '';

Additionally, in the /install/install.php file, FTP should be disabled.

// Begin main prog
define('IN_PHPBB', true);
// Uncomment the following line to completely disable the ftp option...
// define('NO_FTP', true);
$phpbb_root_path = './../';
include($phpbb_root_path.'extension.inc');

should be changed to

// Begin main prog
define('IN_PHPBB', true);
// Uncomment the following line to completely disable the ftp option...
define('NO_FTP', true);
$phpbb_root_path = '';
include($phpbb_root_path.'extension.inc');

Setting up a database for phpBB

PhpBB requires a MySQL database to store much of it's information. Once a database has been created, the forum will need a username and password set up for it. Give the following permissions to this user:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE (NOTE: this permission will be removed after installation)

Running the phpBB Installation script

Once all the above modifications have been made, it is time to install phpBB. To begin the installation process, visit the forum's web address. This will auto-direct you to the installation wizard. Once everything has been submitted to the wizard, you will be taken to a page that will prompt you to download a config.php file. Save this file to your forum directory, then put a copy of this file in your admin directory. This file should overwrite the existing config.php file.

Once that is done, visit the web address of the forum once again. The page will prompt you to delete the install directory and the contrib directory - do so. At this point, you will want to go back and remove the CREATE permission from the forum's MySQL privileges.

Congratulations, phpBB has successfully been installed!

WRAP Authentication and User Generation with phpBB

If your phpBB forum is WRAP protected, some slight code modifications can be made to automatically create and log-in users based on their WRAP ids. An easy WRAP management system that the WolfTech Team provides is Guarddog.

Create a custom include file

To make it easier to install, you'll want to make a custom include file to contain your code modifications. We'll call it WRAPcheck.php.

Within Wrapcheck, put the following code:

<?PHP
$wolftech_unity_id = NULL;
$wolftech_group = 1;

if(!empty($_SERVER["WRAP_USERID"])) {
	$checkWRAP = mysql_query("SELECT user_id FROM forum_users WHERE username='{$_SERVER['WRAP_USERID']}'");
	if(mysql_num_rows($checkWRAP)==0) { //check to see if this user already has an account; if not, create one
		$newID = mysql_fetch_object(mysql_query("SELECT user_id FROM forum_users ORDER BY user_id DESC LIMIT 1"))->user_id;
		mysql_query("INSERT INTO forum_users (user_id, username, user_password) VALUES ('".($newID+1)."', '{$_SERVER['WRAP_USERID']}', '".md5($_SERVER['WRAP_USERID'].microtime())."')") or die(mysql_error());
		mysql_query("INSERT INTO forum_user_group (group_id, user_id, user_pending) VALUES ('{$wolftech_group}', '".($newID+1)."', '0')") or die(mysql_error());
		$wolftech_unity_id = ($newID+1);		
	} else {
		//$userdata = session_begin(mysql_fetch_object($checkWRAP)->user_id, $user_ip, PAGE_INDEX, FALSE, TRUE);
		$wolftech_unity_id = mysql_fetch_object($checkWRAP)->user_id;
	}
}

function wolftech_session_pagestart($unity_ip, $page_index) {
	global $wolftech_unity_id;
	if($wolftech_unity_id) return session_begin($wolftech_unity_id, $unity_ip, $page_index, FALSE, TRUE);
	else return NULL;
}
?>

You can change the variable names wolftech_unity_id and wolftech_group if you desire.

  • wolftech_unity_id is the id number of the user associated with the WRAP id.
  • wolftech_group is the group number you wish to put the user in. A list of groups and their ids can be found in the phpbb_groups table in the phpBB MySQL database.