Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    7

    Default Using list account function to get IP address in php

    Dear friends,

    I want to get the IP address of the accounts I am hosting when I call the list account function.Please can anyone help.

    Fransisco

    cPanel.net Support Ticket Number:
    Fransisco D Anoncia
    www.fountaintechies.com
    www.amolchawathe.com

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Default

    Quote Originally Posted by fransisco
    Dear friends,

    I want to get the IP address of the accounts I am hosting when I call the list account function.Please can anyone help.

    Fransisco

    cPanel.net Support Ticket Number:
    Hi everyone, I also would like to know how I can get the ip address of an account (domain) through PHP. Thanks.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    1

    Default Ping is the only way

    Since the IP address is not given by that function you must do the following:

    <?php

    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host = "localhost";
    $user = "root";
    $accesshash = 'YOUR ACCESS HASH HERE';

    $accts = listaccts($host,$user,$accesshash,0);

    foreach($accts as $acct) {
    echo $acct[0] . " = " . gethostbyname($acct[0]) . "<br />";
    }

    ?>

    This does a lookup on the main domain for every account. If it returns the domain name back that means that the domain name could not be resolved.

    Keep inmind that depending on how many accounts you have it might take a while to load becasue it has to do a lookup on each account.

    If You want to get the IP of one specific domain you would do this:

    <?php

    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host = "localhost";
    $user = "root";
    $accesshash = 'YOUR ACCESS HASH HERE';

    $accts = listaccts($host,$user,$accesshash,0);

    //If you have the user name do this
    echo gethostbyname($accts[$theUserName][0]);

    //If you have the domain name do this
    echo gethostbyname($theDomainName);

    ?>
    --------------------------------------------------
    TheRoamingLlama

    A Romaing Llama never looses it's way.
    http://www.multitaskgraphics.com
    Last edited by roamingllama; 10-23-2005 at 09:47 AM.

Similar Threads & Tags
Similar threads

  1. Replies: 1
    Last Post: 05-03-2011, 12:19 AM
  2. php function mail () not working within my account
    By chike in forum New User Questions
    Replies: 7
    Last Post: 06-07-2010, 02:03 PM
  3. Enable php function for single account
    By webstyler in forum cPanel and WHM Discussions
    Replies: 10
    Last Post: 10-05-2009, 02:14 AM
  4. Replies: 0
    Last Post: 05-29-2006, 11:57 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube