The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP whm script for getting the ip of an account

Discussion in 'General Discussion' started by r3lic, May 1, 2003.

  1. r3lic

    r3lic Registered

    Joined:
    Apr 5, 2003
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Does anyone have a PHP script that gets the the ip from whm of an account given the domain name?

    I tried making one but the return I got from whm was too big to store in a variable for string manipulation:

    function getip ($domain) {
        $host2 = "localhost";
    &nbsp;&nbsp;&nbsp;&nbsp;$user2 = "<USER NAME>";
    &nbsp;&nbsp;&nbsp;&nbsp;$accesshash = '<ACCESS HASH>';
    &nbsp;&nbsp;&nbsp;&nbsp;$result = whmreq("/scripts2/listaccts?nohtml=0&viewall=1",$host2,$user2,$accesshash,0);
    &nbsp;&nbsp;&nbsp;&nbsp;if ($cpanelaccterr != "") { return; }

    &nbsp;&nbsp;&nbsp;&nbsp;$start = strpos($result,"$domain</a></td><td>")+strlen("$domain</a></td><td>");
    &nbsp;&nbsp;&nbsp;&nbsp;$result = substr($result,$start);
    &nbsp;&nbsp;&nbsp;&nbsp;$result = substr($result,0,strpos($result,"</td><td>"));

    &nbsp;&nbsp;&nbsp;&nbsp;return $result;
    }
     
  2. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    I need to get Cpanel to display the IP of the server.
    Do you know how to do it?
     
  3. r3lic

    r3lic Registered

    Joined:
    Apr 5, 2003
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Depends on what skin you have. If you know the server name, just go to your command prompt/shell and type 'ping' followed by the server name and it should give you the ip. My post is in reguards to "web host manager"
     
  4. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    /var/cpanel/root.accts


    disadvantage is some times you have to log into the WHM and go to list accounts and click fetch cvs to rebuild this file...

    other wise you can write a script that runs thru the /etc/userdomains finds the doman, then grabs the username, then opens /var/cpanel/user/username and use regex to strip the IP= line out.... then split it and walaaaa

    haha
     
  5. Roy@ENHOST

    Roy@ENHOST Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    495
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Los Angeles California
    It's OK guys I found the right method justto do that.
    Thanks anyway!!!
     
Loading...

Share This Page