Results 1 to 20 of 20

Thread: register_globals

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    register_globals

    How can I find out if it is on or off? I'm guessing there are at least two variables that tell you, like $_SERVER['REGISTER_GLOBALS'] and $register_globals, to account for the very nature of the question.

  2. #2

  3. #3

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    I just tried this as per http://www.php.net/manual/en/function.ini-get.php :
    PHP Code:
    register_globals is
      <?
        $val = ini_get('register_globals');
        var_dump($val);
        if ($val == "string(0) \"\"")
        {
            echo 'off';
        }
        elseif($val == "string(1) \"1\"")
        {
            echo 'on';
        }
        else
        {
            echo 'unknown';
        }
        ?>
    ...but it prints out string(0) "" unknown

  4. #4

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    This is for another project, genius

  5. #5

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Hmm, also didn't know we chucked one in there, too

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    ah well

    I just chucked it there

  7. #7

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    This didn't help either...grr
    PHP Code:
    register_globals is
      <?
        function svar_dump($data)
        {
            ob_start();
            var_dump($data);
            $ret_val = ob_get_contents();
            ob_end_clean();
            return $ret_val;
        }

      
        $val = ini_get('register_globals');
        svar_dump($val);
        if ($val == "string(0) \"\"")
        {
            echo 'off';
        }
        elseif($val == "string(1) \"1\"")
        {
            echo 'on';
        }
        else
        {
            echo 'unknown';
        }
        ?>
    It just prints out unknown.

  8. #8
    scoutt
    Guest
    $var = ini_get(register_globals);
    if ($var == 0){
    echo "register globals is Off";
    }else{
    echo "register globals is On";
    }

  9. #9

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Originally posted by scoutt
    $var = ini_get(register_globals);
    if ($var == 0){
    echo "register globals is Off";
    }else{
    echo "register globals is On";
    }
    Doesn't work...it prints out Off when they're really on.

    Also tried this:
    PHP Code:

        $all 
    ini_get_all();
        foreach(
    $all['register_globals'] as $s)
        {
            echo 
    "&gt;$s&lt;<br>";
        } 
    And it prints out:
    ><
    ><
    >7<


  10. #10
    scoutt
    Guest
    sorry that works. don't know what you are doing. there are 2 settings for register globals. the master and the local. you can't control the master. if it is off you can't turn it on. but you can control the local, that is what that code does is check the local value. so look again because it works on mine.

  11. #11

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Originally posted by scoutt
    sorry that works. don't know what you are doing. there are 2 settings for register globals. the master and the local. you can't control the master. if it is off you can't turn it on. but you can control the local, that is what that code does is check the local value. so look again because it works on mine.


    What I'm saying is that register_globals is set to on in php.ini, but this prints out off, which is not what I want. I tried it as 'register_globals' and register_globals and both did the same thing.

  12. #12
    scoutt
    Guest
    that is the master level you set to on. run phpinfo() and see what it is set at. if you want to really check it use this script. this will let you turn it on and off by changing the value in the ini_set()

    PHP Code:
    <?

    //echo get_cfg_var (register_globals);

    $var = ini_get(register_globals);
    if ($var == 0){
      echo "register globals is Off";
    }else{
      echo "register globals is On";
    }

    // Turns the register_globals on
    ini_set("register_globals", 0); // change to 1 for on
    $var2 = ini_get(register_globals);
    if ($var2 == 0){
      echo "register globals is Off";
    }else{
      echo "register globals is On";
    }

    phpinfo();
    ?>
    then look at the local value when it runs.

  13. #13

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Maybe I'm just not getting something...but I want to see what the value of register_globals in php.ini is set to. In phpinfo() it is shown to be off, as it is set in php.ini. I don't want to set the value to on or off, I just want to find out what it is.

    Are you saying that I can change the value of register_globals for the current script (which I don't want to do)?

  14. #14
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    yes. you can turn it off or on. The begining part of scoutts script reads what the value is of register_globals, the second part will either turn it on or off depending on your preference.

    -Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  15. #15
    scoutt
    Guest
    Arien, I know you don't want to turn it off or on, that was to jsut show you what happens when you turn it off and on and that it works. now you said a couple posts up that my script said ti was off when it was on in the ini file. then yoiu said phpinfo said it was off and it is off in the ini. So you are getting me confused here. my scripts works so what ever it says it what the variable is.

  16. #16
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    scoutt's snippet works fine for me as well.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  17. #17
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

  18. #18

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Originally posted by scoutt
    Arien, I know you don't want to turn it off or on, that was to jsut show you what happens when you turn it off and on and that it works. now you said a couple posts up that my script said ti was off when it was on in the ini file. then yoiu said phpinfo said it was off and it is off in the ini. So you are getting me confused here. my scripts works so what ever it says it what the variable is.
    Okay, simplified:

    Your script: on
    phpinfo: off
    php.ini: off

    So...eh...

  19. #19

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Okay, now your script is working must have been a typo or something

    Cheers

  20. #20
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    lol, filburt, even I figured this one out on my own the other day

Posting Permissions

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



Click Here to Expand Forum to Full Width