public function createAccount(Server_Account $a) { $ips = $this->getIps(); if (empty($ips)) { throw new Server_Exception(sprintf('Server Manager DirectAdmin Error: "%s" ', 'There are no IPs on DirectAdmin server')); } $ip = $ips[array_rand($ips)]; $package = $a->getPackage(); $client = $a->getClient(); $fields = array(); $fields['action'] = 'create'; $fields['add'] = 'Submit'; $fields['username'] = $a->getUsername(); $fields['email'] = $client->getEmail(); $fields['passwd'] = $a->getPassword(); $fields['passwd2'] = $a->getPassword(); $fields['domain'] = $a->getDomain(); // do not create new package // $packages = $this->getPackages(); // $fields['package'] = $package->getName(); $fields['ip'] = $ip; $fields['notify'] = 'no'; $fields['bandwidth'] = $package->getBandwidth(); //Amount of bandwidth User will be allowed to use. Number, in Megabytes if ($package->getBandwidth() == 'unlimited') { $fields['ubandwidth'] = 'ON'; //ON or OFF. If ON, bandwidth is ignored and no limit is set } $fields['quota'] = $package->getQuota(); //Amount of disk space User will be allowed to use. Number, in Megabytes if ($package->getQuota() == 'unlimited') { $fields['uquota'] = 'ON'; //ON or OFF. If ON, quota is ignored and no limit is set } $fields['vdomains'] = $package->getMaxDomains(); //Number of domains the User will be allowed to create if ($package->getMaxDomains() == 'unlimited') { $fields['uvdomains'] = 'ON'; //ON or OFF. If ON, vdomains is ignored and no limit is set } $fields['nsubdomains'] = $package->getMaxSubdomains(); //Number of subdomains the User will be allowed to create if ($package->getMaxSubdomains() == 'unlimited') { $fields['unsubdomains'] = 'ON'; //ON or OFF. If ON, nsubdomains is ignored and no limit is set } $fields['domainptr'] = $package->getMaxParkedDomains(); //Number of domain pointers the User will be allowed to create if ($package->getMaxParkedDomains() == 'unlimited') { $fields['udomainptr'] = 'ON'; //ON or OFF Unlimited option for domainptr } $fields['nemails'] = $package->getMaxPop(); //Number of pop accounts the User will be allowed to create if ($package->getMaxPop() == 'unlimited') { $fields['unemails'] = 'ON'; //ON or OFF Unlimited option for nemails } $fields['mysql'] = $package->getMaxSql(); //Number of MySQL databases the User will be allowed to create if ($package->getMaxSql() == 'unlimited') { $fields['umysql'] = 'ON'; //ON or OFF Unlimited option for mysql } $fields['ftp'] = $package->getMaxFtp(); //Number of ftp accounts the User will be allowed to create if ($package->getMaxFtp() == 'unlimited') { $fields['uftp'] = 'ON'; //ON or OFF Unlimited option for ftp } $fields['nemailf'] = $package->getCustomValue('nemailf'); //Number of forwarders the User will be allowed to create if ($fields['nemailf'] == 'unlimited') { $fields['unemailf'] = 'ON'; //ON or OFF Unlimited option for nemailf } $fields['nemailml'] = $package->getCustomValue('nemailml'); //Number of mailing lists the User will be allowed to create if ($fields['nemailml'] == 'unlimited') { $fields['unemailml'] = 'ON'; //ON or OFF Unlimited option for nemailml } $fields['nemailr'] = $package->getCustomValue('nemailr'); //Number of autoresponders the User will be allowed to create if ($fields['nemailr'] == 'unlimited') { $fields['unemailr'] = 'ON'; //ON or OFF Unlimited option for nemailr } $fields['aftp'] = $package->getCustomValue('aftp') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will be able to have anonymous ftp accounts. $fields['cgi'] = $package->getCustomValue('cgi') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to run cgi scripts in their cgi-bin. $fields['php'] = $package->getCustomValue('php') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to run php scripts. $fields['spam'] = $package->getCustomValue('spam') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to run scan email with SpamAssassin. $fields['cron'] = $package->getCustomValue('cron') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to creat cronjobs. $fields['catchall'] = $package->getCustomValue('catchall') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to enable and customize a catch-all email (*@domain.com). $fields['ssl'] = $package->getCustomValue('ssl') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have the ability to access their websites through secure https://. $fields['ssh'] = $package->getCustomValue('ssh') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have an ssh account. $fields['sysinfo'] = $package->getCustomValue('sysinfo') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will have access to a page that shows the system information. $fields['dnscontrol'] = $package->getCustomValue('dnscontrol') ? 'ON' : 'OFF'; //ON or OFF If ON, the User will be able to modify his/her dns records. $command = 'CMD_API_ACCOUNT_USER'; if ($a->getReseller()) { $command = 'CMD_ACCOUNT_RESELLER'; $fields['ips'] = 1; //Number of ips that will be allocated to the Reseller upon account during account $fields['ip'] = 'assign'; } try { $results = $this->_request($command, $fields); } catch (Exception $e) { if (strtolower($e->getMessage()) == strtolower(sprintf('Server Manager DirectAdmin Error: "%s" ', 'That domain already exists'))) { return true; } else { throw new Server_Exception($e->getMessage()); } } if (strpos(implode('', $results), 'Unable to assign the Reseller ANY ips') !== false) { throw new Server_Exception('Unable to assign the Reseller ANY ips. Make sure to have free, un-assigned ips.'); } if (strpos(implode('', $results), 'Error Creating User') !== false) { throw new Server_Exception('Error Creating User'); } return true; }
private function _modifyDomain(Server_Account $a) { $p = $a->getPackage(); $params = array('domain' => array('set' => array('filter' => array('domain-name' => $a->getDomain()), 'values' => array('gen_setup' => array('name' => $a->getDomain(), 'status' => 0, 'owner-id' => $a->getId(), 'ip_address' => $a->getIp()), 'hosting' => array('vrt_hst' => array('property1' => array('name' => 'ftp_login', 'value' => $a->getUsername()), 'property2' => array('name' => 'ftp_password', 'value' => $a->getPassword()), 'property3' => array('name' => 'php', 'value' => $p->getHasPhp()), 'property4' => array('name' => 'ssl', 'value' => $p->getHasSsl()), 'property5' => array('name' => 'cgi', 'value' => $p->getHasCgi()), 'ip_address' => $a->getIp())))))); $response = $this->_makeRequest($params); if (isset($response->system->status) && $response->system->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->system->errcode . ' - ' . $response->system->errtext); } if (isset($response->domain->set->result->status) && $response->domain->set->result->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->domain->set->result->errcode . ' - ' . $response->domain->set->result->errtext); } if (isset($response->domain->set->result->status) && $response->domain->set->result->status == 'ok') { return (string) $response->domain->set->result->id; } else { return 0; } }
private function modifyAccountPackage(Server_Account $a, Server_Package $p) { $this->getLog()->info('Midifying account ' . $a->getUsername()); $package = $p; $action = 'modifyacct'; $var_hash = array('user' => $a->getUsername(), 'domain' => $a->getDomain(), 'HASCGI' => $package->getHasCgi(), 'CPTHEME' => $package->getTheme(), 'LANG' => $package->getLanguage(), 'MAXPOP' => $package->getMaxPop(), 'MAXFTP' => $package->getMaxFtp(), 'MAXLST' => $package->getMaxEmailLists(), 'MAXSUB' => $package->getMaxSubdomains(), 'MAXPARK' => $package->getMaxParkedDomains(), 'MAXADDON' => $package->getMaxAddons(), 'MAXSQL' => $package->getMaxSql(), 'shell' => $package->getHasShell()); $this->_request($action, $var_hash); return true; }
public function createAccount(Server_Account $a) { $p = $a->getPackage(); $resourcePlan = $this->_getResourcePlan($p); $dnsTemplate = $this->_getDnsTemplate($p); $client = $a->getClient(); $params = array('action' => 'add', 'class' => 'client', 'name' => $a->getUsername(), 'v-plan_name' => $resourcePlan, 'v-type' => $a->getReseller() ? 'reseller' : 'customer', 'v-contactemail' => $client->getEmail(), 'v-send_welcome_f' => 'off', 'v-domain_name' => $a->getDomain(), 'v-dnstemplate_name' => $dnsTemplate, 'v-password' => $a->getPassword()); $result = $this->_makeRequest($params); if (isset($result['return']) && $result['return'] == 'error') { throw new Server_Exception('Kloxo error: ' . $result['message']); } return true; }
/** * * Disable not needed features for user * @param Server_Account $a * @throws Server_Exception * @return boolean */ private function _disableFeatures(Server_Account $a) { $p = $a->getPackage(); $params = array('domain' => $a->getDomain()); if (!$p->getMaxPop() == 0) { $params['mail'] = ''; } if (!$p->getHasSsl()) { $params['ssl'] = ''; } if ($p->getMaxSql() == 0) { $params['mysql'] = ''; } if ($p->getMaxFtp() == 0) { $params['ftp'] = ''; } if (!$p->getHasSpamFilter()) { $params['spam'] = ''; } $response = $this->_makeRequest('disable-feature', $params); if (isset($response['status']) && $response['status'] == 'success') { return true; } else { throw new Server_Exception('Failed to disable features'); } return false; }
public function deleteSubscription(Server_Account $a) { $params = array('webspace' => array('del' => array('filter' => array('name' => $a->getDomain())))); $response = $this->_makeRequest($params); if (isset($response->system->status) && $response->system->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->system->errcode . ' - ' . $response->system->errtext); } }
/** * Create new account on server * * @param Server_Account $a */ public function createAccount(Server_Account $a) { $p = $a->getPackage(); $packname = $this->_getPackageName($p); $client = $a->getClient(); // Server credentials $vst_command = 'v-add-user'; $vst_returncode = 'yes'; $parts = explode(" ", $client->getFullName()); $lastname = array_pop($parts); $firstname = implode(" ", $parts); // Prepare POST query $postvars = array('returncode' => $vst_returncode, 'cmd' => $vst_command, 'arg1' => $a->getUsername(), 'arg2' => $a->getPassword(), 'arg3' => $client->getEmail(), 'arg4' => $packname, 'arg5' => $firstname, 'arg6' => $lastname); // Make request and create user $result = $this->_makeRequest($postvars); if ($result == 0) { // Create Domain Prepare POST query $postvars2 = array('returncode' => 'yes', 'cmd' => 'v-add-domain', 'arg1' => $a->getUsername(), 'arg2' => $a->getDomain()); $result2 = $this->_makeRequest($postvars2); } else { throw new Server_Exception('Server Manager Vesta CP Error: User name exists on server, please choose another one ' . $result); } if ($result2 != '0') { throw new Server_Exception('Server Manager Vesta CP Error: Create Domain failure ' . $result2); } return true; }
private function dnsCreateZone(Server_Account &$a) { $client = $a->getClient(); // ---- Setting up the DNS ZONE $dns_domain_params['server_id'] = $this->getServerId(); $dns_domain_params['client_id'] = $client->getid(); $dns_domain_params['origin'] = $a->getDomain() . '.'; $dns_domain_params['ns'] = $a->getNs1(); $dns_domain_params['zone'] = $client->getid(); $dns_domain_params['name'] = $a->getDomain() . '.'; //adding a final dot $dns_domain_params['type'] = 'A'; $dns_domain_params['data'] = $a->getIp(); $dns_domain_params['mbox'] = 'mail.' . $a->getDomain() . '.'; //@todo $dns_domain_params['refresh'] = '7200'; $dns_domain_params['retry'] = '540'; $dns_domain_params['expire'] = '604800'; $dns_domain_params['minimum'] = '86400'; $dns_domain_params['ttl'] = '3600'; $dns_domain_params['active'] = 'Y'; $this->_request('dns_zone_add', $dns_domain_params); $pa['origin'] = $a->getDomain(); $info = $this->_request('test', $pa); //Adding the DNS record A $dns_a_params['server_id'] = $this->getServerId(); $dns_a_params['client_id'] = $client->getid(); $dns_a_params['zone'] = $info; $dns_a_params['name'] = $a->getDomain() . '.'; //adding a final dot $dns_a_params['type'] = 'A'; $dns_a_params['data'] = $a->getIp(); $dns_a_params['ttl'] = '3600'; $dns_a_params['active'] = 'Y'; $this->_request('dns_a_add', $dns_a_params); //Adding the DNS record A $dns_a_params['server_id'] = $this->getServerId(); $dns_a_params['client_id'] = $client->getid(); $dns_a_params['zone'] = $info; $dns_a_params['name'] = 'www'; //adding a final dot $dns_a_params['type'] = 'A'; $dns_a_params['data'] = $a->getIp(); $dns_a_params['ttl'] = '3600'; $dns_a_params['active'] = 'Y'; $this->_request('dns_a_add', $dns_a_params); //Adding the DNS record A $dns_a_params['server_id'] = $this->getServerId(); $dns_a_params['client_id'] = $client->getid(); $dns_a_params['zone'] = $info; $dns_a_params['name'] = 'mail'; //adding a final dot $dns_a_params['type'] = 'A'; $dns_a_params['data'] = $a->getIp(); $dns_a_params['ttl'] = '3600'; $dns_a_params['active'] = 'Y'; $this->_request('dns_a_add', $dns_a_params); //Adding the DNS record NS1 $dns_ns_add = array('server_id' => $this->getServerId(), 'zone' => $info, 'name' => $a->getDomain() . '.', 'type' => 'ns', 'data' => $a->getNs1() . '.', 'aux' => '0', 'ttl' => '86400', 'active' => 'Y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', 'client_id' => $client->getId()); $this->_request('dns_ns_add', $dns_ns_add); //Adding the DNS record NS2 $dns_ns_add = array('server_id' => $this->getServerId(), 'zone' => $info, 'name' => $a->getDomain() . '.', 'type' => 'ns', 'data' => $a->getNs2() . '.', 'aux' => '0', 'ttl' => '3600', 'active' => 'Y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', 'client_id' => $client->getId()); $this->_request('dns_ns_add', $dns_ns_add); /* $dns_a_params['server_id'] = $this->getServerId(); $dns_a_params['client_id'] = $client->getid(); $dns_a_params['origin'] = $a->getDomain(); $dns_a_params['ns'] = $a->getNs1(); $dns_a_params['zone'] = '90'; $dns_a_params['name'] = $a->getDomain().'.'; //adding a final dot $dns_a_params['type'] = 'A'; $dns_a_params['data'] = $a->getIp(); $dns_a_params['mbox'] = 'mail.'.$a->getDomain().'.';//@todo $dns_a_params['refresh'] = '28800'; $dns_a_params['retry'] = '7200'; $dns_a_params['expire'] = '86400'; $dns_a_params['minimum'] = '86400'; $dns_a_params['ttl'] = '86400'; $dns_a_params['active'] = 'Y'; $this->_request('dns_zone_add', $dns_a_params); */ // ---- Setting up the mail domain $mail_domain_params['client_id'] = $client->getId(); $mail_domain_params['server_id'] = $this->getServerId(); $mail_domain_params['domain'] = $a->getDomain(); $mail_domain_params['active'] = 'y'; $this->_request('mail_domain_add', $mail_domain_params); return true; }
private function dnsCreateZone(Server_Account &$a) { $client = $a->getClient(); //Adding the DNS record A $dns_a_params['server_id'] = $this->getServerId(); $dns_a_params['client_id'] = $client->getAid(); $dns_a_params['zone'] = '90'; $dns_a_params['name'] = $a->getDomain() . '.'; //adding a final dot $dns_a_params['type'] = 'A'; $dns_a_params['data'] = $a->getIp(); $dns_a_params['ttl'] = '86400'; $dns_a_params['active'] = 'Y'; $this->_request('dns_a_add', $dns_a_params); /* // ---- Setting up the mail domain $mail_domain_params['client_id'] = $client->getAId(); $mail_domain_params['server_id'] = $this->getServerId(); $mail_domain_params['domain'] = $a->getDomain(); $mail_domain_params['active'] = 'y'; $domain_id = $this->_request('mail_domain_add', $mail_domain_params); // ---- Setting up the DNS ZONE $dns_domain_params['client_id'] = $client->getAId(); $dns_domain_params['server_id'] = $this->getServerId(); $dns_domain_params['origin'] = $a->getDomain(); $dns_domain_params['ns'] = '8.8.8.8'; $dns_domain_params['mbox'] = 'mbox.beeznest.com.';//@todo $dns_domain_params['refresh'] = 28800; $dns_domain_params['retry'] = 7200; $dns_domain_params['expire'] = 604800; $dns_domain_params['minimum'] = 604800; $dns_domain_params['ttl'] = 604800; $dns_domain_params['active'] = 'y'; $result = $this->remote('dns_zone_add', $dns_domain_params); */ return true; }