SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I set register_global= on in my script

    If my host install new version of PHP, and I can't set register_global = on. Can I set it in my script?
    I live in Thailand. My English grammar not well.

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try

    ini_set("register_globals",1);
    or
    ini_set("register_globals",0);

    Those should work. check out http://www.php.net/manual/en/function.ini-set.php for help.
    - the lid is off the maple syrup again!

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can emulate register_globals by using this at the top of your script,
    PHP Code:
    extract($_ENV);
    extract($_GET);
    extract($_POST);
    extract($_COOKIE);
    extract($_SERVER); 
    Although, I wouldn't recommend that, it could result in serious security problems for you.

    Paul

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    itsource, didn't you have a thread about this a few days ago?

    http://www.sitepointforums.com/showt...threadid=58017



    again i say, just use the proper arrays. register_globals will not be around forever, so why would you write code that relies on it?
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  5. #5
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the doc's right itsource

    we did reply to you in that post and this: "register_globals will not be around forever, so why would you write code that relies on it?" probably sums up what you should do...

    and nathan you can't set the register_globals flag using ini_set()... read the reference link you gave...

  6. #6
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes you can.

    register_globals "0" PHP_INI_ALL
    PHP_INI_ALL 7 Entry can be set anywhere

    Right off the page.
    Last edited by notepad_coder; May 1, 2002 at 23:30.
    - the lid is off the maple syrup again!

  7. #7
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    woah apologies there on my part notepad_coder

    i was refering to my downloaded copy of the PHP manual... prolly version 4.1.0... and it says there PHP_INI_PERDIR|PHP_INI_SYSTEM instead of ALL... they must have changed it in view of scripts needing register_globals=on... prolly pressure from users for an easy way to set register_globals=on now that most new php installations (4.2.0) would have it off by default

  8. #8
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He he, a lot of people I asked about it didn't think you could do it and one person said it might not work because a lot of servers are in seafe mode.
    - the lid is off the maple syrup again!

  9. #9
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as DR_LaRRY_PEpPeR says, Sorry that I post this topic 2 times, I forgot that I post it before.

    I think if I use script that rely on register_global = on before, So when it off, I don't need to change my code.

    In php script, if I check all input before process anything.
    I think not need to use register_global = off. Is I think correct?
    Last edited by itsource; May 2, 2002 at 04:35.
    I live in Thailand. My English grammar not well.

  10. #10
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by notepad_coder
    Yes you can.

    register_globals "0" PHP_INI_ALL
    PHP_INI_ALL 7 Entry can be set anywhere

    Right off the page.
    have you done it? i'd be very interested if you have.

    it can't be done. the manual page for ini_set() has a lot of errors on it for what can be set where.

    i said it in itsource's other thread, register_globals has done its thing before your script even starts running; your script can't change it. redemption's copy of the manual that said `PHP_INI_PERDIR|PHP_INI_SYSTEM' is correct.

    believe me, if you could turn register_globals off in a script, i'd have it in every one of mine in an instant.

    another example; the page says magic_quotes_gpc is `PHP_INI_ALL'... WRONG! just like register_globals, magic_quotes_gpc has already been done before the script even starts. nothing your script can do about it.


Bookmarks

Posting Permissions

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