From 52fa21cb20c181805c89182279ee97466edf507a Mon Sep 17 00:00:00 2001 From: dmanchev Date: Tue, 3 Feb 2015 12:08:33 +0200 Subject: [PATCH 1/3] Added methods in xmlapi: getmaindomain - get the main domain from user. Added methods in xmlapi2: addaddondomain - add an addon domain to the user's account deladdondomain - remove addon domain from the user's account --- xmlapi.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/xmlapi.php b/xmlapi.php index 51b65dc..62c8753 100644 --- a/xmlapi.php +++ b/xmlapi.php @@ -1278,6 +1278,15 @@ public function setsiteip ( $ip, $user = null, $domain = null ) } } + /** + * @param $username + * @return mixed + */ + public function getmaindomain($username) + { + return $this->api1_query($username, 'print','', array('$CPDATA{\'DOMAIN\'}')); + } + #### # DNS Functions #### @@ -2467,4 +2476,49 @@ public function stat($username, $args = null) return $this->api2_query($username, 'StatsBar', 'stat', $values); } + // This API function add as addon a domain onto this user's account + public function addaddon($username, $newdomain, $subdomain, $ftpPass, $dir = null) + { + if ( (!isset($username)) && (!isset($newdomain)) ) { + error_log("addaddon requires that a username, new domain, subdomain and ftp password are passed to it"); + + return false; + } + + if(empty($dir)) { + $dir = "public_html/" . $newdomain; + } + + $args = array( + 'newdomain' => $newdomain, + 'dir' => $dir, + 'subdomain' => $subdomain, + 'pass' => $ftpPass + ); + + return $this->api2_query($username, "AddonDomain", "addaddondomain", $args); + } + + // This API function remove an addon domain from this user's account + public function deladdon($username, $newdomain, $subdomain, $maindomain = null) + { + if ( (!isset($username)) && (!isset($newdomain)) ) { + error_log("deladdon requires that a username, new domain and subdomain are passed to it"); + + return false; + } + + if(!$maindomain) { + $maindomain = $this->getmaindomain($username); + } + + // follow the pattern for subdomain: subdomain_maindomain.com + $args = array( + 'newdomain' => $newdomain, + 'subdomain' => $subdomain . '_' . $maindomain + ); + + return $this->api2_query($username, "AddonDomain", "deladdondomain", $args); + } + } From 5528e281659f5452213c15727aafa664887ecba5 Mon Sep 17 00:00:00 2001 From: dmanchev Date: Wed, 4 Feb 2015 10:49:13 +0200 Subject: [PATCH 2/3] removed deprecated method added listalldomains method --- xmlapi.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/xmlapi.php b/xmlapi.php index 62c8753..4e9abd1 100644 --- a/xmlapi.php +++ b/xmlapi.php @@ -1278,15 +1278,6 @@ public function setsiteip ( $ip, $user = null, $domain = null ) } } - /** - * @param $username - * @return mixed - */ - public function getmaindomain($username) - { - return $this->api1_query($username, 'print','', array('$CPDATA{\'DOMAIN\'}')); - } - #### # DNS Functions #### @@ -2455,6 +2446,11 @@ public function listaddondomains($username, $domain = null) return $this->api2_query($username, 'Park', 'listaddondomains'); } + public function listalldomains($username) + { + return $this->api2_query($username, 'DomainInfo', 'list_domains'); + } + // This API function displays a list of all selected stats for a specific user. public function stat($username, $args = null) { @@ -2509,7 +2505,8 @@ public function deladdon($username, $newdomain, $subdomain, $maindomain = null) } if(!$maindomain) { - $maindomain = $this->getmaindomain($username); + $alldomains = $this->listalldomains($username); + $maindomain = $alldomains['main_domain']; } // follow the pattern for subdomain: subdomain_maindomain.com From 82f59a302f08f70e7d284af52199d23db7da0e47 Mon Sep 17 00:00:00 2001 From: dmanchev Date: Wed, 4 Feb 2015 10:52:30 +0200 Subject: [PATCH 3/3] comment --- xmlapi.php | 1 + 1 file changed, 1 insertion(+) diff --git a/xmlapi.php b/xmlapi.php index 4e9abd1..db3afd9 100644 --- a/xmlapi.php +++ b/xmlapi.php @@ -2446,6 +2446,7 @@ public function listaddondomains($username, $domain = null) return $this->api2_query($username, 'Park', 'listaddondomains'); } + // This API function displays a list of all domains related to this account. public function listalldomains($username) { return $this->api2_query($username, 'DomainInfo', 'list_domains');