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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Nov 09, 2004 8:47 am
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:
Post
by TwiSteD » Sun Dec 19, 2004 3:42 am
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);
}
?>
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Dec 20, 2004 6:28 am
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 » Mon Dec 20, 2004 7:26 am
hmmm..odd then, because I had to add the if statement for mine to work