PDA

View Full Version : Including global.php clears all my variables


myHybridcar.com
02-16-2009, 08:37 PM
I've been including global.php from a script in another directory in order to access $vbulletin login information. However, I've realized global.php keeps clearing any variables I set and the only way to keep them around is to store them in a session. Why is it doing this, and is there a way I can make it stop? Thanks.

Dismounted
02-17-2009, 04:44 AM
What variables? Superglobals?

myHybridcar.com
02-17-2009, 05:03 AM
I'm not particularly advanced in PHP. All I know is that anything I set before requiring globals.php gets unset after the include.

I found a thread (https://vborg.vbsupport.ru/showthread.php?p=530177) dating to 2004 in which a vB staff member said For security reasons, vBulletin global.php unsets all global variables except a few specified in array $_allowedvars.I believe this is what I mean.

If I were to do the following…$var='value';
require('/home/dir/www/forums/globals.php');
echo $var;…$var would return empty.

Lynne
02-17-2009, 02:01 PM
Then.... include global.php at the beginning of your page before you set the variables?

myHybridcar.com
02-17-2009, 02:16 PM
Then.... include global.php at the beginning of your page before you set the variables?Yes, this is the solution I ended up using, though it's a bit of a pain because previously it was in my header include; now it has to be inserted at the top of every page by itself.

Thanks.