Integrate PHPBB3 with PHPMaker site

Tips submitted by PHPMaker users

Integrate PHPBB3 with PHPMaker site

Postby mdfaisalpapa » Tue Jun 10, 2014 9:28 pm

If you are using dynamic uselevel then create a additional field in the phpbb_users table for storing userlevel, say uLevelID(int)

if you use a common database for phpbb3 and your site database then select the phpbb_users as the user table and select username as username in the security settings

if you have a diffrent database for phpbb3 and your site then create a view based on phpbb_users which contains the username,password,uLevelID (password is immaterial as we are going to use the phpbb3 login always but since it has to be selected in the security settings the same is selected here)
remember to disallow change password in phpmaker project.

i have the forum under the folder phpbb3 in the root of the website. U need to add code at the three places in phpmaker project and one place in the ucp.php file in phpbb3

1.User Custom Validate event 2.User Logging Out event 3. startup script of login page

// User Custom Validate event
function User_CustomValidate(&$usr, &$pwd) {
// Enter your custom code to validate user, return TRUE if valid.
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if ($user->data['user_id'] != ANONYMOUS)
{
$usr=$user->data['username_clean'];
return TRUE;
}
$result = $auth->login($usr, $pwd);
if ($result['status'] == LOGIN_SUCCESS)
{
// Logged in
return TRUE;
}
return FALSE;
}

// User Logging Out event
function User_LoggingOut($usr) {
// Enter your code here
// To cancel, set return value to FALSE;
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_kill();
return TRUE;
}


// Write your startup script here
// document.write("page loaded");
//php is usedin the stratup script so as to submit the form only if phpbb3 user is already logged in
<?php
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if ($user->data['user_id'] != ANONYMOUS)
{
echo "document.getElementById('username').value='".$user->data['username']."';";
echo "document.getElementById('flogin').submit();";
}

?>

//modifiations in ucp.php
find
$user->session_kill();
and add
header("Location: ../logout.php");
above that line.
mdfaisalpapa
 
Posts: 56
Joined: Wed Jan 30, 2013 4:07 pm

Re: Integrate PHPBB3 with PHPMaker site

Postby mdfaisalpapa » Sun Jan 18, 2015 11:30 am

clean code for the above:
//Global ->All Pages ->Global Code

define('IN_PHPBB', true);
global $phpbb_root_path, $phpEx, $user, $auth,$db, $config, $cache, $template;
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './phpBB3/';// change this to the root path of your phpBB3 installation
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
function phpbb_IsLoggedIn()
{
// Start session management
global $user,$auth;
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if ($user->data['user_id'] != ANONYMOUS)
{
return TRUE;
}
return FALSE;
}
function phpbb_Login($usr,$pwd)
{
global $auth;
$result = $auth->login($usr, $pwd);
if ($result['status'] == LOGIN_SUCCESS)
{
// Logged in
return TRUE;
}
return FALSE;
}
function phpbb_Logout()
{
global $user;
if(phpbb_IsLoggedIn())$user->session_kill();
}


// Global ->All Pages ->User_CustomValidate event
function User_CustomValidate(&$usr, &$pwd) {
// Enter your custom code to validate user, return TRUE if valid.
if(phpbb_IsLoggedIn()) return TRUE;
return phpbb_Login($usr,$pwd);
}

//Other->Default Page -> Page_Load event to check whether the phpBB user is already loggedin
// Page Load event
function Page_Load() {
//echo "Page Load";
if(!$GLOBALS['Security']->IsLoggedIn() && phpbb_IsLoggedIn())
{
ob_end_clean();
header("Location: login.php");
exit();
}

}

// Other->User_ LoggingOut event
function User_LoggingOut($usr) {
// Enter your code here
// To cancel, set return value to FALSE;
phpbb_Logout();
return TRUE;
}

//Other->Login Page->Startup script I am using php code to generate javascript code

// Write your startup script here
// document.write("page loaded");
<?php
if(phpbb_IsLoggedIn())
{
echo "document.getElementById('username').value='".$user->data['username']."';";
echo "document.getElementById('flogin').submit();";
echo "$('.ewContentColumn').html('Logging in....Please Wait....');";

}

?>
mdfaisalpapa
 
Posts: 56
Joined: Wed Jan 30, 2013 4:07 pm

Re: Integrate PHPBB3 with PHPMaker site

Postby Skybound » Wed May 25, 2016 9:10 pm

Is this code for 3.0 or 3.1 of phpBB3?
Skybound
 
Posts: 19
Joined: Thu Dec 13, 2012 5:29 pm


Return to User Submitted Tips (PHPMaker)