Location: PHPKode > scripts > cPanel X > cpanel-x/cpanel.php
<?
class CPanel{
	var $host = "";
	var $path = "";
	var $port = 2082;
	var $cpaneluser = "";
  	var $cpanelpass = "";
  	var $authstr = "";
	var $pass = "";
	var $output = false;
	
	function login($user,$password,$host)
	{
		$this->host = $host;
		$this->cpaneluser = $user;
		$this->cpanelpass = $password;
		$this->authstr = "$this->cpaneluser:$this->cpanelpass";
		$this->pass = base64_encode($this->authstr);
	}

	function api_output()	
	{
	$this->output = true;
	}
		
	function open_sock($method,$formdata)
	{
		foreach($formdata AS $key => $val){
     			$string .= urlencode($key) . "=" . urlencode($val) . "&";
    			}
		
		$string = substr($string, 0, -1);
	    $fp = fsockopen($this->host, $this->port, $errno, $errstr, $timeout = 30);
  
 		if(!$fp){ echo "$errstr ($errno)\n"; }
		else{			
				fputs($fp, "$methos $this->path HTTP/1.1\r\n");
    			fputs($fp, "Host: $this->host\r\n");
    			fputs($fp, "Authorization: Basic $this->pass \r\n");
    			fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
    			fputs($fp, "Content-length: ".strlen($string)."\r\n");
    			fputs($fp, "Connection: close\r\n\r\n");
    			fputs($fp, $string . "\r\n\r\n");	
			if($this->output)
				{
				while(!feof($fp)) {
     				echo fgets($fp, 4096);
    					}    
			    fclose($fp);
				}
			}  	

	}


	function create_email_account($email,$password,$quota)
	{
		$this->path = "/frontend/x2/mail/doaddpop.html";
		$formdata = array ( "email" => $email, "domain" => $this->host, "password" => $password, "quota" => $quota);
		$this->open_sock('POST',$formdata);
    }

				
	 function delete_email_account($email)
		{
		 $this->path = "/frontend/x2/mail/realdelpop.html";
		 $formdata = array ( "email" => $email, "domain" => $this->host);
		 $this->open_sock('GET',$formdata);
		}  	

	 function add_subdomain($subdomain,$domain='')
	 {
	   $this->path = "/frontend/x/subdomain/doadddomain.html";
	   $formdata = array ( "domain" => $subdomain , "rootdomain" => $domain.$this->host);
	   $this->open_sock('POST',$formdata);
	}
	
	function delete_subdomain($subdomain)
	{
	 $this->path = "/frontend/x/subdomain/dodeldomain.html";
	 $formdata = array ( "domain" => $subdomain);
	 $this->open_sock('POST',$formdata);
	}

}
?>
Return current item: cPanel X