raviminds Posted July 1, 2006 Share Posted July 1, 2006 I am trying to create subdomain remotelyI 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] Quote Link to comment https://forums.phpfreaks.com/topic/13375-how-to-create-subdomain-in-cpanel-remotely/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.