So here is the working code
<?php
/* Example 1: Logging in place in your pages
*/
require_once( '/home/public_html/forum-board/PHPBB_login.php');
//include( "./login.php");
session_start();
/* First, login the user using your own login system, for example; */
$user = new User();
// Then login the user to the forum
$phpBB = new PHPBB_Login();
$user->login( $username, $password );
$phpBB->login( $user->id );
header("Location: ". "index.php");
/* Example 2: Logging out
I do not use a logout so this code is untested and I'm not sure if it works or not
you may play with it to get it to work?
*/
require_once( '/home/public_html/forum-board/PHPBB_login.php');
session_id();
$user = new User();
/* First, logout the user from the forum */
$phpBB = new PHPBB_Login();
$phpBB->logout( session_id(), $user->id) ;
/* Then logout the user from your own login system */
$user->logout( $user->id );
?>
Here are the classes to be called
<?php
// Define Your User class
// User has a method called login
class User {
function login($username,$password) {
/*
Process $username, $password and ID here
Note that phpbb is currently using md5 encryption for passwords
If your members area is not encrypted then you can do a straight replacement
of "password" with your value or var.
Otherwise you will need to decrypt your password and convert it to md5 hash.
other encryption types are sha1, mhash and md5
*/
$password = md5( "password" );
$username = "cFemailforfun";
$user_id = 19;
$this->id = $user_id;
}
}
class PHPBB_Login {
function PHPBB_Login() {
}
function login( $phpbb_user_id ) {
define('IN_PHPBB',true);
// You may need to change the following line to reflect
// your phpBB installation.
$phpbb_root_path = "./";
global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
// Setup the phpbb environment and then
// run through the phpbb login process
require_once( $phpbb_root_path . "config.php" );
require_once( $phpbb_root_path . "extension.inc" );
require_once( $phpbb_root_path . "common.php" );
return session_begin( $phpbb_user_id, $user_ip, PAGE_INDEX, FALSE, TRUE );
}
function logout( $session_id, $phpbb_user_id ) {
define('IN_PHPBB',true);
// You may need to change the following line to reflect
// your phpBB installation.
$phpbb_root_path = "./";
global $db, $lang, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
// Setup the phpbb environment and then
// run through the phpbb login process
// You may need to change the following line to reflect
// your phpBB installation.
require_once( $phpbb_root_path . "config.php" );
require_once( $phpbb_root_path . "extension.inc" );
require_once( $phpbb_root_path . "common.php" );
session_end( $session_id, $phpbb_user_id );
// session_end doesn't seem to get rid of these cookies,
// so we'll do it here just in to make certain.
setcookie( $board_config[ "cookie_name" ] . "_sid", "", time() - 3600, " " );
setcookie( $board_config[ "cookie_name" ] . "_mysql", "", time() - 3600, " " );
}
}//-- END of All Classed needed to loging / logout a user
/*
// The following is for reference only to move a user to setup
//a basic user so he or she can be automatically logged in with the classes
//above the phpbb_users table will need to be stuffed with some basic
//information.
$phpbb_Password = md5( $arr_iamembers['Password'] );
$phpbb_user_timezone = "-8.00" ;
$phpbb_user_lang = "english";
$phpbb_user_dateformat = "D M d, Y g:i a";
$Zero = "0";
$One = "1";
//-- Note: this is my dbres function to insert a new user in to phpbb_user table with
//some basic default values, you may have to do a std mysql query.
$res = db_res( "INSERT INTO zphpbb_users (
user_id,
user_active,
username,
user_password,
user_regdate,
user_level,
user_posts,
user_timezone,
user_style,
user_lang,
user_dateformat,
user_new_privmsg,
user_unread_privmsg,
user_last_privmsg,
user_viewemail,
user_attachsig,
user_allowhtml,
user_allowbbcode,
user_allowsmile,
user_allowavatar,
user_allow_pm,
user_allow_viewonline,
user_notify,
user_notify_pm,
user_popup_pm,
user_rank,
user_avatar,
user_avatar_type,
user_email,
user_sig
)
VALUES
(
'$arr_iamembers[ID]',
'$One',
'$arr_iamembers[NickName]',
'$phpbb_Password',
NOW(),
'$Zero',
'$Zero',
'$phpbb_user_timezone',
'$One',
'$phpbb_user_lang',
'$phpbb_user_dateformat',
'$Zero',
'$Zero',
'$Zero',
'$Zero',
'$Zero',
'$One',
'$One',
'$One',
'$One',
'$One',
'$One',
'$One',
'$One',
'$One',
'$Zero',
'$phpbb_user_avatar',
'$phpbb_user_avatar_type',
'$arr_iamembers[Email]',
'$arr_iamembers[Headline]'
)"
);
*/
?>