Skip to content

Added getmaindomain method, add and remove addon domains #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions xmlapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,12 @@ 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');
}

// This API function displays a list of all selected stats for a specific user.
public function stat($username, $args = null)
{
Expand All @@ -2467,4 +2473,50 @@ 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) {
$alldomains = $this->listalldomains($username);
$maindomain = $alldomains['main_domain'];
}

// follow the pattern for subdomain: subdomain_maindomain.com
$args = array(
'newdomain' => $newdomain,
'subdomain' => $subdomain . '_' . $maindomain
);

return $this->api2_query($username, "AddonDomain", "deladdondomain", $args);
}

}