Get email diskused (listpopwithdisk)
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);
[/PHP]
and the result:
[PHP]SimpleXMLElement Object ( [apiversion] => 2 [data] => Array ( [0] => SimpleXMLElement Object ( [_diskquota] => 41943040 [_diskused] => 0 [diskquota] => 40 [diskused] => 0 [diskusedpercent] => 0 [diskusedpercent20] => 0 [domain] => domain.com => test@domain.com [humandiskquota] => 40" MB [humandiskused] => None [login] => test@domain.com [mtime] => 1404380710 [txtdiskquota] => 40 [user] => test) [/PHP]
---------------------------------------
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);
}[/PHP]
Really need some help here guys, this is kinda important and time is running out!
-
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? 0
Please sign in to leave a comment.
Comments
1 comment