PDA

View Full Version : Accesing the bbuserinfo array from a PHP page


cybrcyfr
08-07-2002, 09:30 PM
First off, I asked this question on vbulletin.com, and Jakeman suggested I ask here. Thanks in advance!

We have just purchased vB for the new version of Klient.com.

We decided to use vB's intrinsic user registrration and suthorization system instead of writing our own. Our main problem is we can not access the bbuserinfo[] array from parent pages.

Our site design is obviously "http://localhost/forums/" (this is on our development server...). We want to be able to access the array from our standard_header.php that is located in the root of the web. This file builds our headers and navigation structure.

We have tried all that we can think of, we set the cookie path to "/", even tried directly including the "forums/admin/sessions.php" (and a few others...) still to no avail.

As soon as I require "./forums/global.php" the page display halts.

It will display up until the point where it is looking for the required file. I would assume it is due to the dependancies in the global.php file...

We can not even preform a simple echo afer logging in:

<?php echo $bbuserinfo[username];?>

Can you please offer some assistance?



-Tyler Lynch
Klient.com Staff

------------------

Got it working thanks to eiSecure on vB.com!


chdir("forums");
include("./global.php");
chdir("..");

cybrcyfr
08-08-2002, 04:15 PM
Here is a post in the vB.com forums to fix the include problems if you have subdirectories...


http://www.vbulletin.com/forum/showthread.php?s=&postid=332142#post332142

cybrcyfr
09-06-2002, 10:14 AM
How it is blowing up on our FreeBSD production server.

Unix doesn't like the:

include("./global.php");

So change that to:

include("global.php");

Here is the complete script, works in Win32 an Unix.



// **** This little bit is because we have a directory structure, and need to include things... ****
$intDirPos = strpos($SCRIPT_NAME,"/",1);
$strDirectoryCurrent = substr($SCRIPT_NAME, 1, strpos($SCRIPT_NAME,"/",1)-1);

if($intDirPos!==false)
{ // we are calling from a sub directory
chdir("../forums");
include("global.php");
chdir("../".$strDirectoryCurrent);
}else{ // we are calling from the web root directory
chdir("./forums");
include("global.php");
chdir("..");
}