Jump to content

$GLOBALS not working properly


Guest joanging

Recommended Posts

Guest joanging

I just installed 3.0.9 on two different Unix environments (though at this point I do not know what is different). One worked perfectly using the automated setup. The other, however, is not working properly.

I've discovered the problem. When I try to go to the admin section, the forward to the login page is not working properly. Upon further testing, I've discoverd that though I have all the values set properly in globals.inc.php, the $GLOBALS['rootRel'] variable in the auth.inc.php file has no value (and thus is not forwarding to the proper directory). Does anyone know why this might work on one system and not another, or why this variable is producing no value?

Help is appreciated.

Joan

Additional Info: I did just discover that one server is on php4 and the other is php5. Does $GLOBALS work differently between PHP versions, and if so, is there an easy/fast workaround?

Link to comment
Share on other sites

Guest joanging

Does no one have an answer to this or is there something I need to clarify in the situation? This is preventing me from being able to use the software at the moment, so ANY ideas or suggestions would help me a great deal.

Thanks,

Joan

Link to comment
Share on other sites

Guest joanging

Well, I finally solved the problem in a horrible workaround. In many files (admin/includes/auth.inc.php as an example), I've had to manually set the $GLOBALS value at the top of the file like so:

$GLOBALS['rootDir'] = '/path/to/store/;

$GLOBALS['rootRel'] = '/store/';

$GLOBALS['storeURL'] = 'http://www.mysite.com/store/';

It was the only way I could get those variables to work properly throughout the rest of the script.

Link to comment
Share on other sites

Well, I finally solved the problem in a horrible workaround. In many files (admin/includes/auth.inc.php as an example), I've had to manually set the $GLOBALS value at the top of the file like so:

$GLOBALS['rootDir'] = '/path/to/store/;

$GLOBALS['rootRel'] = '/store/';

$GLOBALS['storeURL'] = 'http://www.mysite.com/store/';

It was the only way I could get those variables to work properly throughout the rest of the script.

Well I'm not running 3.09 or PHP 5, but in my installation, $GLOBALS['rootDir'], $GLOBALS['storeURL'] , and $GLOBALS['rootRel'] are all set in includes/sslSwitch.inc.php (depending upon whether you're using SSL or not). The script checks that $_SERVER["HTTPS"] is set and equals "on" before deciding what to make those three variables. So it should use the SSL config values if you access the page via https and the regular ones if not.

One thing that looks odd to me is that it checks whether $_SERVER["HTTPS"] == "on". I thought it this was just set to a positive value when you use https, not specifically to "on". Maybe this is different in PHP 5?

PHP 5 also has register_globals OFF by default. This is a huge improvement in security, but it can cause some headaches. This also may have something to do with what happened to you.

I would play with the code in includes/sslSwitch.inc.php a bit and see what you can figure out. You could output the values at that point and see where the script is failing. Once it sets those values correctly there it should work throughout.

Please post anything that you learn so that the next person doesn't have to go through what you are.

Link to comment
Share on other sites

Hmm...

Another possible source of this problem is in includes/functions.inc.php. There it sets $storeURL and $storeURL_SSL, but as far as I can tell it doesn't make them global in scope and it's doing this inside a function. So that looks odd to me and I could see how it might not work with register_globals off.

Anyone more familiar than I am with this script want to confirm/deny my suspicions?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...