Jump to content

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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.