+ Reply to Thread
Results 1 to 9 of 9

Thread: HowTo: Easily emulate register_globals = on

  1. #1
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75

    HowTo: Easily emulate register_globals = on

    Hi,

    If you are having problems with register_global = off there is an easy way to emulate the "on" setting:

    PHP Code:
    extract($_COOKIE); extract($_POST); extract($_GET); 
    Note that the order is important! (GPC -> CPG).

    Nevertheless I recommend you to convert your scripts to work with rg = off for enhanced security.
    ------------------------------------
    [URL=http://www.dedicatedzone.com]Managed Dedicated Servers[\URL]

  2. #2
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    ... and do not forget about $_SERVER, $_ENV, $_FILES, $_REQUEST and other superglobals.
    ------------------------------------
    [URL=http://www.dedicatedzone.com]Managed Dedicated Servers[\URL]

  3. #3
    Full Member Allin1Joe is on a distinguished road
    Join Date
    Jan 2004
    Posts
    10
    Here is what I put at the top of all my PhP programs...

    Code:
    if (!empty($_GET)) 
    { 
      extract($_GET); 
    }  
    else if (!empty($HTTP_GET_VARS)) 
    { 
      extract($HTTP_GET_VARS); 
    } 
    
    if (!empty($_POST)) 
    {
      extract($_POST);
    }  
    else if (!empty($HTTP_POST_VARS)) 
    {
      extract($HTTP_POST_VARS);
    }

  4. #4
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    In my opinion, something like

    PHP Code:
    if (!get_cfg_var("register_globals")) {
    ...

    is more handy and appropriate then !empty($_GET) stuff

    HTH,
    Z.
    ------------------------------------
    [URL=http://www.dedicatedzone.com]Managed Dedicated Servers[\URL]

  5. #5
    Full Member Allin1Joe is on a distinguished road
    Join Date
    Jan 2004
    Posts
    10
    Maybe, but this way I don't bother exploding if the array is empty.

    However, at this point, I think we are debating the difference between a nickel and 5 pennies

  6. #6
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    Originally posted by Allin1Joe
    However, at this point, I think we are debating the difference between a nickel and 5 pennies
    Heh, yep, you are right
    ------------------------------------
    [URL=http://www.dedicatedzone.com]Managed Dedicated Servers[\URL]

  7. #7
    Full Member RedefinedMedia is on a distinguished road
    Join Date
    Jan 2004
    Location
    Kansas City
    Posts
    10
    ive always used this 1 command to update old scripts

    PHP Code:
    import_request_variables("GPC"""); 
    http://us4.php.net/import_request_variables

    it basically is the same as running the export on all three just a little cleaner and smaller
    Ben Summers
    Head Programmer
    RedefinedMedia.com

  8. #8
    Full Member Allin1Joe is on a distinguished road
    Join Date
    Jan 2004
    Posts
    10
    Originally posted by RedefinedMedia
    ive always used this 1 command to update old scripts

    PHP Code:
    import_request_variables("GPC"""); 
    http://us4.php.net/import_request_variables

    it basically is the same as running the export on all three just a little cleaner and smaller
    Great info, thanks!

  9. #9
    Full Member dzone is on a distinguished road
    Join Date
    Dec 2003
    Posts
    75
    Originally posted by RedefinedMedia
    ive always used this 1 command to update old scripts
    Heh, cool! I didn't know about that. But you will always have to add extract($_SERVER); because most of those old scripts use $PHP_SELF as well.
    ------------------------------------
    [URL=http://www.dedicatedzone.com]Managed Dedicated Servers[\URL]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts