- Code: Select all
'index.php' or 'things.php'
and not like this,
- Code: Select all
'default.asp' or index.html'
The first thing on our phpBB integrated page is the session data. This code looks something like this:
- Code: Select all
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Set page ID for session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);
//
// End session management
//
Let me explain all this, first of all. Let's look at this line of code.
- Code: Select all
define('IN_PHPBB', true);
This simply means that we are in the phpBB software, it means that you are allowed to view this page.
- Code: Select all
$phpbb_root_path = './';
The code here is relatively simple, it lets us know where to find the phpBB root folder. If the directory list is like this:
- Code: Select all
index.php
downloads.php
customise.php
support.php
dev.php
phpBB2/index.php
phpBB2/common.php
Then the string for that would be './phpBB2/'. Like this:
- Code: Select all
$phpbb_root_path = './phpBB2/';
Carrying on, the following code simply includes the config.php file and the common.php file for various things.
- Code: Select all
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
This code:
- Code: Select all
//
// Set page ID for session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);
//
// End session management
//
Is just the Management of the Session, this is required.
These following PHP commands allow dynamics's for the user.
- Code: Select all
$userdata['username'];
This lets the user get the users username.
- Code: Select all
$userdata['user_id'];
The ID of the user.
- Code: Select all
$userdata['user_rank'];
The rank of the user. User/Admin.
These can be used in If/Else statements, for instance:
- Code: Select all
if ($userdata['user_id'] = $_GET['id']) {
echo "Hello. You are " . $userdata['username'] . ".";
}
Thanks for reading. I hope you have learned something from this article.
Update: Sept 8, 2007 by battye, changed $userdata['userid'] to the correct $userdata['user_id'] variable.