We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16901
    • 35 Posts
    Howdy!

    I was wondering if anyone might be able to help me understand this warning that showed up on one of the websites I maintain...

    It showed up one day out of the blue. No one had touched the site in months. However, the hosting company recently migrated the site to a newer server, and I’m wondering if that’s part of the problem here. (They, of course, say that this error has nothing to do with them.)

    Here’s the error:

    Services for this domain have been discontinued
    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug

    Error: file_get_contents(http://usr-52.starnet.md/in.php?ip=96.54.238.51&host=protectionislandbeachhouse.com) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

    Error type/ Nr.: Warning - 2

    File: /var/www/vhosts/protectionislandbeachhouse.com/httpdocs/index.php(136) : eval()’d code

    Line: 1

    Parser timing
    MySQL: 7.0412 s (47 Requests)
    PHP: 6.9221 s

    Total: 13.9633 s


    I’m at a loss here - can anyone guide me towards a possible solution?

    Cheers!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The new server has allow_url_fopen turned off. When it’s off, you can’t open URLs as if they were files.

      http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
      http://www.php.net/manual/en/function.file-get-contents.php
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 16901
        • 35 Posts
        Thank you! That totally helped me get to a solution... which was:

        - adding a php.ini file to the root level of the server with this in it:

        allow_url_fopen = 1;


        Problem solved.

        Cheers!
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Keep in mind that the directory-level php.ini files are not inherited; every directory that has a .php file that gets executed needs one. In the case of MODx, that means the root directory and the manager directory, since everything else is included into their index.php files.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 16901
            • 35 Posts
            Thanks for your help here. However, it looks like I spoke too soon.

            The solution appeared to work but only for a bit. Now it’s back to throwing the error.

            I checked with the hosting company - the server does have allow_url_fopen turned on.

            I also tried adding a copy of that php.ini file to the /manager directory.

            No luck.

            So... any other ideas about what could be causing the error?

            Cheers.
              • 3749
              • 24,544 Posts
              Have you checked PhpInfo() to confirm that allow_url_fopen is really off?

              Is the file on your own server or somewhere else?
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 16901
                • 35 Posts
                Yes - I just checked using PhpInfo() and allow_url_fopen is really ON.

                The file is on our server.
                  • 3749
                  • 24,544 Posts
                  Can you just give the path to the file rather than using a URL in the file_get_contents() call?

                  Also, check the permissions and ownership of the file.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 16901
                    • 35 Posts
                    Quote from: BobRay at Feb 16, 2011, 04:06 PM

                    Can you just give the path to the file rather than using a URL in the file_get_contents() call?

                    I don’t have any idea where the file_get_contents() call is coming from. How can I tell?

                    Quote from: BobRay at Feb 16, 2011, 04:06 PM

                    Also, check the permissions and ownership of the file.

                    I’ve checked the permissions and ownership of /index.php and everything appears to be in order there.
                      • 3749
                      • 24,544 Posts
                      This is the file it’s trying to open:

                      http://usr-52.starnet.md/in.php


                      You could search your snippet code for that to see where the call is being made.

                      Also, take a look at line 136 of that index.php file. It’s possible that your site has been hacked.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting