SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why isn't ini_set("allow_url_fopen", 1); working?

    I have the following code to make sure my RSS feeds work:

    ini_set("allow_url_fopen", 1);
    if (ini_get("allow_url_fopen") == 1) {
    echo "allow_url_fopen is ON";
    } else {
    echo "allow_url_fopen is OFF";
    }

    Then, as you can see, I check it. It ways displays:
    "echo "allow_url_fopen is OFF"

    Any ideas why?

  2. #2
    SitePoint Addict phpster's Avatar
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from the manual
    allow_url_fopen boolean

    This option enables the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers.

    Note: This setting can only be set in php.ini due to security reasons.
    So you can't change it in the code
    phpster

    I wish my computer would do what I want it to.
    Not what I tell it to do...

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like that was not tested because if it was the author would have known it didn't work.

    Just out of interest why do you do this:
    PHP Code:
    if (ini_get("allow_url_fopen") == 1) {
    echo 
    "allow_url_fopen is ON";
    } else {
    echo 
    "allow_url_fopen is OFF";

    when you could just as well do this?
    PHP Code:
    print ini_get("allow_url_fopen"); 

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ini_set("allow_url_fopen", 1);
    print ini_get("allow_url_fopen");

    Prints nothing.

  6. #6
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's because it is boolean(false) but print_r(ini_get("allow_url_fopen")); certainly would work.

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope, that prints nothing either. I checked and there is an entry for it in the ini file

    I;ve also tried:

    PHP Code:
             ini_set("allow_url_fopen"'On');
            
    print_r(ini_get("allow_url_fopen"));
             if (
    ini_get("allow_url_fopen") == 'On') {
                echo 
    "allow_url_fopen is ON";
            } else {
                echo 
    "allow_url_fopen is OFF";
            } 
    Same thing - Off

  8. #8
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As pointed out to you above it is not possible to alter this setting from a script.

  9. #9
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appreciate you pointing that out again. I have to wonder why Pear developers wrote in the documentation that the above method should be done to overcome this that setting being set to Off. Pear developers are pretty good at PHP.

    http://pear.php.net/manual/en/packag...quirements.php

  10. #10
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why isn't ini_set("allow_url_fopen", 1); working?

    I posted in the php forum but can not get a definitive answer (http://www.sitepoint.com/forums/showthread.php?t=295840)

    The crux of the matter is this, on Pear's XML_RSS documentation, it says that if your allow_url_fopen=Off, then ini_set it to 1:
    http://pear.php.net/manual/en/packag...quirements.php

    I figure these Pear guys know what their talking about so I have tried it every which way but loose.

    Some people in the forum say it can't be done from code.

    What do you advanced PHP users say? (I have spent most of the day on this because I am trying to avoid permenently setting it to On)

  11. #11
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My guess is that was written without testing. Maybe the person writing it thought it would work but the truth is it certainly does not.

  12. #12
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it certainly look sthat wya - thanks for your patience. I'm starting another thread to see if there are any security concerns with setting it to On.

    http://www.sitepoint.com/forums/show...73#post2138373

  13. #13
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know the definitive answer, and can see how I might want to be able to do this too. Having Safe Mode set "on" in your ini may override all of your attempts though.

  14. #14
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how does safe_mode interact with or change allow_url_fopen?

  15. #15
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I understand it, this is because Safe mode governs whether or not you can fopen anything except in directories you have stipulated in the ini.

    When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it.

  16. #16
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paulyG
    As I understand it, this is because Safe mode governs whether or not you can fopen anything except in directories you have stipulated in the ini.
    That only concerns the server directories; safe mode does not prevent you from accessing data from the outside. Edit: Then again, I could be rather wrong.

  17. #17
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    allow_url_fopen
    Note: This setting can only be set in php.ini due to security reasons.
    There’s more than one way to skin a cat.

  18. #18
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Threads merged. Please do not cross-post.

    Quote Originally Posted by WebDevGuy
    I posted in the php forum but can not get a definitive answer
    The manual says this cannot be set at script level (for obvious reasons) and your testing has proved this. Is this not a definitive answer?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  19. #19
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.bigbold.com/snippets/posts/show/530

    Is this workaround any help?


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
  •