Integrating PHPBB 3

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
We can use the login/session manager in phpbb 3 as our main sitewide login system. This way, we only have to include the php to link our files with the phpbb session manager, and not write it ourself (hours of debuging spared... trust me!)

Here is the code that should be in the file config.php, placed in your root website directory (accessible on the web)
Place the following code in it and modify it so that it is configured for your installation.
PHP:
<?php
// config.php
define('IN_PHPBB', true);
$phpbb_root_path = 'phpBB3/'; //modify this to point to the root path of your phpbb 3 installation.
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management

$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>
Now this is the code of a page that displays some information to logged in users.
PHP:
<?php
//check_user.php
require_once 'config.php';
?>
<html>
<head>
</head>
<body>
Some content
<?php
if($user->data['is_registered'])
{
     //user is logged in
     echo 'Welcome back, ' . $user->data['username'];
} else
{
     //user is not logged in
?>
Please log in:<br />
<form method="POST" action="./<?php echo $phpbb_root_path ?>ucp.php?mode=login">
<p>Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
Remember Me?: <input type="checkbox" name="autologin"><br />
<input type="submit" value="Submit" name="login"></p>
<input type="hidden" name="redirect" value="index.php">
<!-- The value off the redirect hidden input may be modified, 
but you need to keep in mind that the wording directory will 
be not the directory of the script, but of the forum. -->
</form>
<?php
}  
?>
More content
</body>
</html>

You find my post helpful, donate or add me rep.
 
Last edited:

cowctcat

New Member
Messages
401
Reaction score
0
Points
0
I moved it to Tutorials. Please post a new thread in Programming Help if you still need Programming Help. :D
 

JuniorD

New Member
Messages
564
Reaction score
0
Points
0
not bad. now if you make one of these tuts for smf I may be interested. :D

Nice tut. Im pretty bad at php myself but I give it a 8.5/10 (I personally hate tuts that give you all the coding you need.)
 

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
Nice tutorial.

It took me 3 months to work that out, and then someone makes a tutorial on it :(
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Nice tutorial.

It took me 3 months to work that out, and then someone makes a tutorial on it :(

The trick with this sort of stuff is to ask someone or do a long search for it, because most of the time somebody else has done it. If you are really lucky they have made an awesome tutorial or mod to show you how to do it easily. ;)
 
Top