PDA

View Full Version : Integration of Vbulletin in website causing errors


Fulla
06-15-2008, 10:48 AM
Integrating Vbulletin functions into my website is causing me problems.

If I include the following in my script:
<?php
//Begin Define $rootdir
$times=substr_count($_SERVER['PHP_SELF'],'/');
$rootdir='';
$x=1;
while ($x < $times) {$rootdir .= "../";$x++;}
$GLOBALS['rootdir']=$rootdir;
//End Define $rootdir

define('DIR',$rootdir.'board/');
define('CWD',$rootdir.'board/');
require_once(DIR.'global.php'); //these 4 files all (also separate) cause this problem
require_once(DIR.'includes/functions_bigthree.php'); //these 4 files all (also separate) cause this problem
require_once(DIR.'includes/class_postbit.php'); //these 4 files all (also separate) cause this problem
require_once(DIR.'includes/class_bbcode.php'); //these 4 files all (also separate) cause this problem
?>

Once I require a file from Vbulletin, all my vars are wiped.
If I open the page as followed: myfile.php?page=test
Then the following scripts give the following response

<?php
$pagina=$_GET['page']

echo $pagina; //test

//vbinclude

echo $pagina; //empty
?>

<?php
$pagina='about';
$pagina=$_GET['page'};

echo $pagina; //test

//vbinclude

echo $pagina; // empty
?>

<?php
$pagina='about';

echo $pagina; //about

//vbinclude

echo $pagina; //about
?>

So it doesn’t really wipe out the $vars, altho vars filled with $_GET’s are wiped.

What is causing this, and how can I solve this?

I put this in my php.ini: register_globals = off

thx for any help

Opserty
06-15-2008, 02:34 PM
Include global.php at the begging of your script. and use chdir().

Like this:


<?php
$cwd = getcwd(); // Save our current directory to switch to after
chdir('path/to/forum');
require_once('global.php')
// more require_once()
chdir($cwd) // Switch back to original directory

// Continue script...

MoT3rror
06-15-2008, 05:38 PM
vBulletin destroys most variables when it is included. If you define the variables as a constant, vbulletin will keep this value.

I suggest if you are going to use superglobals such as $_GET, $_POST, $_REQUEST, etc. to use the vBulletin Input Cleaner (https://vborg.vbsupport.ru/showthread.php?t=119372&highlight=input+cleaner).