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.

Get email diskused (listpopwithdisk)

Discussion in 'cPanel Developers' started by k0zh4x, Jul 3, 2014.

  1. k0zh4x

    k0zh4x Registered

    Joined:
    Jul 3, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello!

    I'm trying to create a script to list and manage the email accounts. At the moment i can do the list and add/remove/change password/change quota for each email.

    The only problem i am having is that i dont get the correct usedquota! Already sent emails with some files for testing, and the quota usage is right on Cpanel->Mail accounts.

    Part of my script:
    PHP:
    class cpanelapi
        
    {
            private 
    $domain;
            private 
    $port;
            private 
    $account;
            private 
    $account_password;

            private 
    $xmlapi;

            function 
    __construct($domain$port$account$account_password){
                
    $this->domain $domain;
                
    $this->port $port;
                
    $this->account $account;
                
    $this->account_password $account_password;
            }

            function 
    connect(){
                
    $this->xmlapi = new xmlapi($this->domain);
                
    $this->xmlapi->set_port($this->port);
                
    $this->xmlapi->password_auth($this->account$this->account_password);
                
    $this->emailsList();    
            }

            function 
    emailsList(){
                
    // get list of accounts
                
    $result $this->xmlapi->api2_query($this->account"Email""listpopswithdisk");
                
    //print_r($result);
    and the result:

    PHP:
    SimpleXMLElement Object ( [apiversion] => [data] => Array ( [0] => SimpleXMLElement Object ( [_diskquota] => 41943040 [_diskused] => [diskquota] => 40 [diskused] => [diskusedpercent] => [diskusedpercent20] => [domain] => domain.com [email] => test@domain.com [humandiskquota] => 40 MB [humandiskused] => None [login] => test@domain.com [mtime] => 1404380710 [txtdiskquota] => 40 [user] => test
    ---------------------------------------
    Another problem i am facing is that i'm creating an array to store the values returned by the querry. Every time i do this request (Refresh page for example), the values are "shuffled" and i cant figure out how to sort this values in the array.

    This is how i store the values:

    PHP:
    $result $this->xmlapi->api2_query($this->account"Email""listpopswithdisk");
                
    $resultSize sizeof($result) - 4;
                
    //print_r($result);

                
    $emailList = array();

                for (
    $i=0$i $resultSize$i++) {

                    
    $email $result->data[$i]->email;
                    
    $diskused $result->data[$i]->diskused;
                    
    $diskquota $result->data[$i]->diskquota;
                    
    $diskusedpercent $result->data[$i]->diskusedpercent;
                       
                       
    $emailList[$i] = array($email,
                                              
    $diskused,
                                              
    $diskquota,
                                              
    $diskusedpercent);
                }
    Really need some help here guys, this is kinda important and time is running out!
     
  2. k0zh4x

    k0zh4x Registered

    Joined:
    Jul 3, 2014
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Ok so...i solved the problem with diskused. I needed to wait 4 hours for the refresh, sorry for noobish from my part :p.
    The problem with the array sorting still persists. Any advice on that matter?
     
Loading...

Share This Page