peterjmag Posted March 24, 2008 Share Posted March 24, 2008 Hello all, I'm a bit of a PHP newbie, so forgive me if this is a simple question. I am in the process of consolidating three different web servers into one, and one of the sites I'm migrating is written for and run on PHP 4.3.4 with the register_globals parameter in php.ini set to on. On PHP 5.2.3 on the new server, I've turned off register_globals (since I have two Joomla sites running on the same instance), so the older PHP app only works when I add the following line to its virtual host's .htaccess file: php_flag register_globals on The original author (who no longer works here) used variables like $DOCUMENT_ROOT and $PHP_AUTH_USER (which I'm assuming are global variables), instead of what seems to be the proper way: $_SERVER['DOCUMENT_ROOT'] and $_SERVER['PHP_AUTH_USER']. Out of curiosity, what would I have to do to get this older code to work with register_globals turned off? Do all the variables need to be changed? Is it even worth going through all that PHP (and there's quite a bit of it)? Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/97701-rewriting-a-php-app-for-register_globals-off/ Share on other sites More sharing options...
cooldude832 Posted March 24, 2008 Share Posted March 24, 2008 well its good you are trying to rewrite it with out registered_globals the answer to your question is there is no "simple" way you need to look through each line and replace every variable deceleration with its proper $_SERVER, $_GET, $_POST, $_SESSION version. There is no function non_registered_globals_to_registered_globals() because there is no way to tell which global array that given variable belongs to. Link to comment https://forums.phpfreaks.com/topic/97701-rewriting-a-php-app-for-register_globals-off/#findComment-499938 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2008 Share Posted March 25, 2008 If you turn on full php error reporting, most of the variables that are dependent on register globals will be exposed because they will be undefined when they are referenced in the code. The ones that have an assignment statement before they are referenced won't show up this way and would need to be found by examining the code. Link to comment https://forums.phpfreaks.com/topic/97701-rewriting-a-php-app-for-register_globals-off/#findComment-500054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.