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.

Getting complete info for each account

Discussion in 'General Discussion' started by brack, Nov 13, 2005.

  1. brack

    brack Member

    Joined:
    Nov 12, 2005
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Why the script /scripts2/listaccts?nohtml=1&viewall=1 returns only reseller's name, domainname, and package name, while /scripts2/listaccts?&viewall=1 returns all information about each account? :confused:

    I'm looking for the simplest way of getting each account's registration date, to calculate expiration date.

    How to get all information about each account in form of arrays?
     
  2. brack

    brack Member

    Joined:
    Nov 12, 2005
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    is there any one to answer my question?
     
  3. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Instead of using supplied cPanel scripts, which may or may not provide you with the data you require, you can relatively easily build your own remote access features that you can then code to do what you want.

    I recently posted a tutorial on how to do this, using the example of reading the contents of /etc/localdomains as part of a process to determine whether or not a given domain name is already being used on a given server.

    The same technique could be used to iteratively read and parse the contents of the files in /var/cpanel/users/ and return an associative array representing the data in the files.

    The tutorial is at http://forums.cpanel.net/showthread.php?t=46362 and demonstrates the technique using PHP, although I'm sure idea can easily be modified to use another scripting language of your choice.

    Taking such a route may well involve a bit of effort to get the basics going, but once you've got that far it is really easy to add further remote access features.

    In the meantime, take a look at /var/cpanel/users/ and see what data it presents - you should be able to find all you need and the format of the files is quite self-explanatory. Bear in mind that the "IP" field in the files has been deprecated and cannot be relied upon to contain accurate data.
     
  4. brack

    brack Member

    Joined:
    Nov 12, 2005
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Thank you very much, here is the function that I've made for my purposes out of simular function in Accounting.php.inc and your tutorial.
    PHP:
    function whmListAccts($host,$user,$accesshash,$usessl) {
      
    // Get list of domains, both in db and in /etc/localdomains
      
    $result whmreq("/scripts/fetchcsv",$host,$user,$accesshash,$usessl);
      if (
    $cpanelaccterr != "") {
        return;
      }

      
    // Get domains into an array and trim
      
    $users split("\n"$result);
      foreach(
    $users as $u){
              list(,
    $u_domain,$u_ip,$u_name,,,,,,,,,$u_resel,$u_server,$u_cptheme,,$u_dn1,,,,$u_pack,,,,,,,$u_time,$u_dn2)=split(",",$u);
              if (
    $u_domain != "") {
                  
    $accts[$u_name]=array (
                                  
    "domain"=>$u_domain,
                                  
    "ip"=>$u_ip,
                                  
    "username"=>$u_name,
                                  
    "reseller"=>$u_resel,
                                  
    "server"=>$u_server,
                                  
    "cPanel"=>$u_cptheme,
                                  
    "package"=>$u_pack,
                                  
    "subscribed"=>$u_time,
                                  
    "timestamp"=>$u_dn2
                                  
    );
              }
      }
      return 
    $accts;
    }
     
    #4 brack, Nov 15, 2005
    Last edited: Nov 15, 2005
Loading...

Share This Page