Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Accessing WHM via PHP - php_network_getaddresses: getaddrinfo failed

Discussion in 'General Discussion' started by azoundria, Apr 28, 2007.

  1. azoundria

    azoundria Member

    Joined:
    Apr 28, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    151
    This error has been bugging me for just short of a month! Originally I discovered it in a script for a free hosting manager (I am trying to build a free host). I isolated the exact code that is attempting to access the WHM below:

    Code:
    <?php
    $file = file("http://user:pass@@ismywebsite.com:2086");
    print_r($file);
    ?>
    It doesn't work. Yet when I go to http://user:pass@ismywebsite.com:2086 myself I can access it fine. To fully test that file() is working on the server -with URLs - I created:

    Code:
    <?php
    $file = file("http://www.ismywebsite.com/");
    print_r($file);
    $file = file("http://user:pass@ismywebsite.com:2086");
    print_r($file);
    ?>
    Try it at http://www.ismywebsite.com/access.php

    The contents of my site display perfectly but the WHM is still inaccessible.

    Please help me. This is the biggest roadblock I have ever faced in the development of my free host dream and please don't let it fail. Thanks a lot for your time and help.
     
  2. djbob2

    djbob2 Well-Known Member

    Joined:
    May 14, 2005
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    166
    Why not use cURL instead of file? If you don't have that library, just use the fsock library. The file functions don't work so well for http-type things, and might break from weird characters of authentication methods.
     
  3. azoundria

    azoundria Member

    Joined:
    Apr 28, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    151
    This line was originally in a script for the Free Host Manager from http://www.fhm-script.com/ using file_get_contents() instead - which returns the same error.

    It appears no others have these errors. And I do not know how to create CPanel accounts on my own - so I would need to use a ready-made script for that.

    But maybe I can update the entire code to use fsock instead of file() if it works. What code would I use to do what I am trying to do above?

    Code:
    $fp = fsockopen("user:pass@ismywebsite.com", 2086, $errno, $errstr);
    Like that? Then what?
     
  4. bpat1434

    bpat1434 Well-Known Member

    Joined:
    Oct 2, 2004
    Messages:
    71
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Columbia, MD
    To read information you'd use something like

    Code:
    $fp = fsockopen('www.imywebsite.com', 2086, $errno, $errstr, 30);
    $html = '';
    
    while(!feof($fp))
      $html .= fread($fp, 1024);
    At that point, everything that WHM would output is put into the $html variable. In order to send headers and stuff, you'd have to use the fputs() function to send information to the server.
     
  5. azoundria

    azoundria Member

    Joined:
    Apr 28, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    151
    Still not working...
     
  6. azoundria

    azoundria Member

    Joined:
    Apr 28, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    151
    Please help me...
     
  7. jvanv8

    jvanv8 Member

    Joined:
    Nov 10, 2006
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    151
    I have a similar / same problem. You can repeat this by using SOAP cURL, file_get_contents, etc. Some servers are ok for me (yahoo.com is ok, but google.com does not load - I get a Hostway underconstruction page)

    Any fixes. Is this a DNS resolution problem?
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice