SitePoint Sponsor

User Tag List

Results 1 to 25 of 28

Hybrid View

  1. #1
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Turning register_globals on for a particular folder

    Hi,

    In my application, i need register_globals to be turned on for a particluar folder, i tried to achieve this by putting a file named as .htaccess inside that folder having following code:

    php_value register_globals on

    I also tried placing php.ini file here, but didn't work as well.

    Is there a way to achieve this?
    Plz suggest!

    Thanks,
    kul.

  2. #2
    ¨.¨ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Why do you need register_globals for this one folder?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, i need global session varaibles so, i need that setting to be turned on!

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kuldeepkaundal View Post
    well, i need global session varaibles so, i need that setting to be turned on!
    $_SESSION array is always available for you so why you need register globals turned ON for this?
    page 1
    PHP Code:
    session_start();
    $_SESSION['mysessvar'] = 'somevalue'
    page 2
    PHP Code:
    session_start();
    echo 
    $_SESSION['mysessvar']; 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, i know, but, its an old fashioned script, that i need to integrate, and it is using "session_register", and its the requirement of that script to turn on register_globals, if i change the settings in php.ini it works fine, so, thats why i need register_globals to be turned on!

  6. #6
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In fact, i am not able to change any of the php.ini settings for that particular folder or application, suppose i need to change some setting for a particluar application, then, is there a way to do this?

    currently, i've tried to put in a file "php.ini" with my settings, but, if i am checking those settings by creating a file phpinfo.php and executing that file, i still see default php.ini settings.

    plz suggest a solution,
    Thanks,
    kul.

  7. #7
    ¨.¨ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    $_SESSION is not global enough? Register_globals is not the solution you seek.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Just remember that PHP6 doesn't even have the ability to turn register_globals on since it was deprecated in PHP 4.2 and made completely obsolete in PHP 5. You only need to add about three lines of code to the top of a script to copy all the $_REQUEST values to their equivalent variable names so as to give the equivalent of turning on register_globals anyway without actually doing so.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  9. #9
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Decowski:

    Or if you really need register_globals on for a directory then use .htaccess:

    Code:

    php_flag register_globals on

    yep, i tried this earlier, but, it didn't work!

    And Felgall, you are right, i agree, but, the issue for me is that, i'll have to do that change in lots of pages then!

  10. #10
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kuldeepkaundal View Post
    Code:
    php_flag register_globals on
    yep, i tried this earlier, but, it didn't work!
    No, you tried php_value. For boolean (on/off) settings you need to use php_flag.

  11. #11
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya, i had replaced php_value with php_flag, but, somehow its not working

  12. #12
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried:

    PHP Code:
    echo ini_get('register_globals'); 
    It has to work with php_flag. Does it give you any errors?

  13. #13
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fiddle with a few other settings in .htaccess . If the changes still fail to show up within PHP, it's likely that .htaccess is disabled. In order to enable .htaccess, you must set AllowOverride directive inside httpd.conf to all.

  14. #14
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    It is possible that your hosting provider doesn't allow you to turn it on - it does lower the security of their server if you do so.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  15. #15
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't it be...

    PHP Code:
    php_admin_flag register_globals on
    php_admin_flag register_long_arrays on 

  16. #16
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by printf View Post
    Shouldn't it be...

    PHP Code:
    php_admin_flag register_globals on
    php_admin_flag register_long_arrays on 
    No. php_admin_flag cannot go in .htaccess, only httpd.conf (or any Apache configuration file to be specific). It’s used specifically so that a setting cannot be modified from .htaccess. But you gave me a great hint! If in httpd.conf register_globals is set with:

    Code:
    php_admin_flag register_globals off
    rather than:


    Code:
    php_flag register_globals off
    Then you can’t change it from .htaccess. This may be the reason why it’s not working. Do you have access to Apache configuration?

  17. #17
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to test it at my local machine now,rather than at server and for this i've set register_globals off in php.ini file here.

    Just incase i want to check it at my local machine, can i do it by checking apache->httpd.conf file at my machine?

  18. #18
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Why not just fix the script so that it doesn't require register globals in order to run. After all that option was turned off by default and deprecated in PHP 4.2 and declared completely obsolete in PHP 5 and has already been completely removed from PHP 6. So for any scripts written after about 2005 that setting should be assumed to be no longer available and the coding should be done properly.

    See http://www.felgall.com/htmlt59.htm for a short piece of code that can be added to a web page that has the same effect gor GET and POST variables as turning on register globals would have. The other global arrays can be dealt with similarly if you need to.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  19. #19
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    See http://www.felgall.com/htmlt59.htm for a short piece of code
    Iíve already suggested using extract(), which does exactly what your code does, but was ignored so I assumed it wasnít a viable solution (for what reason I donít know).

  20. #20
    SitePoint Addict kuldeepkaundal's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    K, Thanks for the replies, i'll try to put in one of the methods suggested, though, i'll still be interested in making register_globals "on/off" from my script, b'coz some scripts like oscommerce and oscmax also require register_globals on!

  21. #21
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,825
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by kuldeepkaundal View Post
    K, Thanks for the replies, i'll try to put in one of the methods suggested, though, i'll still be interested in making register_globals "on/off" from my script, b'coz some scripts like oscommerce and oscmax also require register_globals on!
    Only the old version of oscommerse required register globals on. If you are using the latest version with the correct security plugins then you must have it off.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •