Hi all,

For those faced with the task of updating 100's or 1000's of pages that
assumed register_globals on, I've found a couple of solutions which can work
as a temporary solution whilst you re-engineer your pages (as I plan to do).

1. simple: ask your ISP to change php.ini :)

2. use a .htaccess file to change register_globals for your domain / dir, as
long as your Apache config file allows it.

3. (untested) use ini_set() to turn them back on at a per-script or
per-config file level.

4. add this code to the top of your pages, or in a common library of code /
config file:

foreach($GLOBALS as $key => $value)
    { $$key=$value; }

If you have this url: page.php?foo=bah, with register_globals off, $foo will
not be available in your script automatically, as it was in older PHP

Using the above code, we scroll through the $GLOBALS array, and for each key
(eg foo) we assign a var of the same name (eg $foo) and assign it the
matching value (eg $foo = "bah").

The ultimate (secure) solution would be to get your code up to scratch with
the new set-up (and I plan to do this, ASAP), but I myself do not have time
for this, given that I have to update MANY sites within a short time frame,
and my ISP is planning a merge to the new version very soon.

I think foreach() was only available in newer versions of PHP though sorry.

Hope this helps.

Justin French
Creative Director

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to