Very frustrating Sudden PHP Include Error

Discussion in 'Programming/Scripts' started by bpmee, Aug 7, 2007.

  1. bpmee

    bpmee Member

    Hi All,

    I'm having a very frustrating PHP include error that just started recently. :confused:

    Basically, I have .php pages in a directory with a PHP include call followed by some other html and code.

    Here is a sample of what I am talking about:

    PHP:
    <?php $clientip $_SERVER['REMOTE_ADDR']; ?><?php include('http://www.domain.com/subfolder/content/section1.php?keyword=Los-angeles-cosmetic-surgery&yourip='.$clientip); ?>
    The above is all on line 1 of my page. The page dynamically creates a page with an RSS feed I setup for the given keyword.

    I checked my RSS feed source and it works fine. I was able to query it with my browser and the feed shows up. Also, I used lynx on my command line and the feed comes to the server successfully.

    Now, however, I get the following error in my logs, and I am not sure why this is happening!

    Code:
    [Tue Aug 07 12:44:28 2007] [error] [client 64.151.124.29] PHP Warning:  include() [<a href='function.include'>function.include</a>]: Failed opening 'http://www.domain.com/subfolder/content/section1.php?keyword=Los-angeles-cosmetic-surgery&amp;yourip=64.151.124.29' for inclusion (include_path='.:/usr/share/pear') in /home/www/web758/web/subfolder/Los-angeles-cosmetic-surgery.php on line 1
    
    
    
    When I try to open the above page in my browser or lynx, I simply get a blank page with the other html I have on the page AFTER the include call.

    Note, the server is ASKING ITSELF for the include via http://www...etc. I am not including it using the local path (ie /web/subfolder/include.php). I have always used this method and never until a couple days ago did it cause any trouble.

    I am using ISPConfig (of course! :) ) on Fedora Core 5 linux.

    Note, I recently fixed some DNS issues with my server...The resolv.conf file was misconfigured and I had to change it to the proper values.

    Fopen is on in my PHP.ini file - so I don't know why this is happening?

    Any ideas? Thanks!:eek:
     
  2. bpmee

    bpmee Member

    Addendum

    It seems to be happening on another server that has a similar configuration: any calls to external PHP includes do not work!
     
  3. bpmee

    bpmee Member

    Also these notes...

    In anticipation of some sort of reply, I am supplying the following items which are currently configured on my server:

    1) fopen is on.

    2) openbasedir is commented out

    3) I have not upgraded Apache recently.

    4) I have not upgraded PHP recently.

    5) I have tried rebooting network, httpd, named, and ispconfig_server numerous times.

    I believe the issue might be DNS related, but I have no clue how to go about finding out how...

    Why would only PHP have issues with DNS and not the rest of the server?

    I am checking my resolv.conf files and configs at all my servers now, that are related to this problem...

    Any replies or solutions are greatly appreciated!
     
  4. bpmee

    bpmee Member

    Found Solution!

    Hi All,



    I am having nearly the exact same problem, and I have banged my head against the wall for the past 2 days trying to solve it.



    I have messed around with resolv.conf, rebooted all sorts of services, reconfigured etc...



    Turns out it is rather simple, (isn't it always?? ) and I'm not taking credit for solving it but rather for finding someone's own solution:

    http://www.mydigitallife.info/2006/...est-stream-with-fopen-or-fsockopen-functions/

    Follow the article, but for me, the part that matters was my user_agent setting in my PHP.ini.

    So, I did the following:

    Code:
    
    vi /etc/php.ini
    
    
    and scrolled down to my user_agent setting. It turns out that the server will not open an external URL or HTTP stream because the requesting user agent, as set by whatever version of PHP you are using is simply "PHP".

    So, the server balks at requests from this user agent and does not process them.

    so, I edited the user_agent setting and changed it from "PHP" to:

    Code:
    user_agent="Mozilla/4.0 (compatible; MSIE 6.0; BPMEESERVER NT 2.22)"
    
    This effectively tells the server that a browser is requesting the page, not a script.

    I named the OS "BPMEESERVER" so when I read my logs, I'll know that it is my box requesting various pages.

    Hope this helps
     
  5. blu3ness

    blu3ness New Member

    or just use curl
     

Share This Page