vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Including global.php clears all my variables (https://vborg.vbsupport.ru/showthread.php?t=205603)

myHybridcar.com 02-16-2009 08:37 PM

Including global.php clears all my variables
 
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 dating to 2004 in which a vB staff member said
Quote:

Originally Posted by Andreas
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…
PHP Code:

$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

Quote:

Originally Posted by Lynne (Post 1746891)
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.


All times are GMT. The time now is 03:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00968 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete