Jump to content

Archived

This topic is now archived and is closed to further replies.

raviminds

How to create subdomain in cpanel remotely

Recommended Posts

I am trying to create subdomain remotely

I have tried from WHM but i do not want to create account or domain from WHM using hash key. 

i am using following code but it does not work

<?

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) . "&"; 
echo "<br>string 1:"$string;
}       

$string = substr($string, 0, -1);     
echo "<br>string 1:"$string;

$fp = fsockopen($this->host, $this->port, $errno, $errstr, $timeout = 30);       

if(!$fp)
{
echo "$errstr ($errno)n";
}   

else

echo "<br>path 1:".$path;
fputs($fp, "$method $this->path HTTP/1.1");       
fputs($fp, "Host: $this->host");       
fputs($fp, "Authorization: Basic $this->pass");       
fputs($fp, "Content-type: application/monsoon-www-form-urlencoded");       
fputs($fp, "Content-length: ".strlen($string)."");       
fputs($fp, "Connection: closernrn"); 
fputs($fp, $string . "rnrn");     

if($this->output)     
{     
while(!feof($fp))
{         
echo fgets($fp, 4096);         
}           

fclose($fp);     

}   
}       
}     

function create_email_account($email,$password,$quota) 
{   
$this->path = "/frontend/monsoon/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/monsoon/mail/realdelpop.html";   
$formdata = array ( "email" => $email, "domain" => $this->host);    $this->open_sock('GET',$formdata);   

}       

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

}     

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

?>



[color=red][b]Is have any solution[/b][/color]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.