Integrating a site with phpBB

Small, short code snippets that other people may find useful. Do you have a good regex that you would like to share? Share it! Even better, the code can be commented on, and improved.

Moderator: General Moderators

Post Reply
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Integrating a site with phpBB

Post by JayBird »

Put this at the top of any page that you want to access logged in user information...

Code: Select all

 
<?php
 
define('IN_PHPBB', true);
 
$site_root_path = 'path/to/root'; //<-- Modify
$phpbb_root_path2 = '/forum/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.php'); 
include($phpbb_root_path . 'config.php'); 
 
$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 
 
?>
 
then, to see what variable are accessible...use

Code: Select all

 
echo "<pre>";
print_r($userdata);
echo "</pre>";
Mark
TwiSteD
Forum Newbie
Posts: 4
Joined: Wed Dec 01, 2004 5:19 pm
Contact:

Re: Integrating a site with phpBB

Post by TwiSteD »

Bech100 wrote:

Code: Select all

<?php

define('IN_PHPBB', true);

$site_root_path = 'path/to/root'; //<-- Modify
$phpbb_root_path2 = '/forum/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.php'); 
include($phpbb_root_path . 'config.php'); 

$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 

?>
^^ will cause "Hacking Attempt" to appear.

Use this part for the first code instead.

Code: Select all

<?php

define('IN_PHPBB', true);

$site_root_path = 'path/to/root'; //<-- Modify
$phpbb_root_path2 = '/forum/'; //<-- Modify
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
if ( defined('IN_PHPBB') )
{
	include($phpbb_root_path . 'extension.inc'); 
	include($phpbb_root_path . 'common.php'); 
	include($phpbb_root_path . 'config.php'); 

	$userdata = session_pagestart($user_ip, PAGE_INDEX); 
	init_userprefs($userdata);
} 

?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

not on phpBB 2.0.11 it doesn't, works fine for me.

Why use the if statement?
TwiSteD
Forum Newbie
Posts: 4
Joined: Wed Dec 01, 2004 5:19 pm
Contact:

Post by TwiSteD »

hmmm..odd then, because I had to add the if statement for mine to work :?
Post Reply