<?php
	/*
	Hezecom Email Solution
	Author: Hezecom Technologies (http://hezecom.com) info@hezecom.net
	COPYRIGHT 2014 ALL RIGHTS RESERVED
	
	You must have purchased a valid license from CodeCanyon.com in order to have 
	access this file.

	You may only use this file according to the respective licensing terms 
	you agreed to when purchasing this item.
	*/

	class MyCpanel
	{
	public $ip;
	public $account; 
	public $password; 
	public $port; 
	public $domail; 
	public $user_email;
	public $new_user_email; 
	public $new_user_pwd; 
	public $new_user_pwd2;
	public $old_user_pwd;  
	
	public function __construct()
	{
	$this->ip = C_IP;
	$this->account = C_USERNAME;
	$this->password = C_PASSWORD;
	$this->port = C_PORT;
	$this->domain = C_URL;
	$this->userid = isset($user_email);
	$this->new_user_email = isset($new_user_email);
	$this->new_user_pwd = isset($new_user_pwd);
	$this->new_user_pwd2 = isset($new_user_pwd2);
	$this->old_user_pwd = isset($old_user_pwd);
	$this->email_forwarder = isset($email_forwarder);
	}
	//create
	public function AddEmail($email_user,$email_pass,$email_quota){
	$xmlapi = new xmlapi($this->ip);
	$xmlapi->set_port($this->port);
	$xmlapi->password_auth($this->account, $this->password);
	$call = array('domain'=>$this->domain, 'email'=>$email_user, 'password'=>$email_pass, 'quota'=>$email_quota);
	$xmlapi->set_debug(0);
	$result = $xmlapi->api2_query($this->domain, "Email", "addpop", $call ); 
	}
	//List email
	public function ListEmail(){
	$xmlapi = new xmlapi($this->ip);
	$xmlapi->set_port($this->port);
	$xmlapi->password_auth($this->account, $this->password);
	$xmlapi->set_debug(0);
	$result = $xmlapi->api2_query($this->account, "Email", "listpopswithdisk");
	return $result; 
	}
	//List One email
	public function ListEmailOne($user_email){
	$xmlapi = new xmlapi($this->ip);
	$xmlapi->set_port($this->port);
	$xmlapi->password_auth($this->account, $this->password);
	$call = array('domain='>$this->domain, 'email'=>$user_email);
	$xmlapi->set_debug(0);
	$result = $xmlapi->api2_query($this->account, "Email", "listpopswithdisk",$call);
	return $result; 
	}
	//update 
	public function UpdateEmail($user_email,$newpass){
	$msg = '';
	if (!empty($user_email))
	while(true) {
	$xmlapi = new xmlapi($this->ip);
	$xmlapi->set_port($this->port);
	$xmlapi->password_auth($this->account, $this->password);
	$call = array('domain'=>$this->domain, 'email'=>$user_email, 'password'=>$newpass);
	$xmlapi->set_debug(0);
	$result = $xmlapi->api2_query($this->account, "Email", "passwdpop", $call ); 
	if ($result->data->result == 1){
	$msg = $email_user.'@'.$this->domain.' account password changed';
	} else {
	$msg = $result->data->reason;
	  break;
	}
	break;
	}}
	
	//delete email
	public function DeleteEmail($user_email){
	if (!empty($user_email)){
	$xmlapi = new xmlapi($this->ip);
	$xmlapi->set_port($this->port);
	$xmlapi->password_auth($this->account, $this->password);
	$call = array('domain='>$this->domain, 'email'=>$user_email);
	$xmlapi->set_debug(0);
	$result = $xmlapi->api2_query($this->account, "Email", "delpop", $call ); 
	}
}
	
	

	}//end class
?>