private function _modifyClient(Server_Account $a) { if ($a->getReseller()) { $type = 'reseller'; $genInfo = 'gen-info'; } else { $type = 'client'; $genInfo = 'gen_info'; } $client = $a->getClient(); $p = $a->getPackage(); $params = array($type => array('set' => array('filter' => array('login' => $a->getUsername()), 'values' => array($genInfo => array('cname' => $client->getCompany(), 'pname' => $client->getFullname(), 'login' => $a->getUsername(), 'passwd' => $a->getPassword(), 'status' => 0, 'phone' => $client->getTelephone(), 'fax' => $client->getFax(), 'email' => $a->getEmail(), 'address' => $client->getAddress1(), 'city' => $client->getCity(), 'state' => $client->getState(), 'pcode' => $client->getZip(), 'country' => $client->getCountry()))))); $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->{$type}->set->result->status) && $response->{$type}->set->result->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->{$type}->set->result->errcode . ' - ' . $response->{$type}->set->result->errtext); } if (isset($response->{$type}->set->result->status) && $response->{$type}->set->result->status == 'ok') { return $response->{$type}->set->result->id; } return 0; }
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; }
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; }
public function createAccount(Server_Account $a) { $this->getLog()->info('Creating account ' . $a->getUsername()); $client = $a->getClient(); $package = $a->getPackage(); $this->_checkPackageExists($package, true); $action = 'createacct'; $var_hash = array('username' => $a->getUsername(), 'domain' => $a->getDomain(), 'password' => $a->getPassword(), 'contactemail' => $client->getEmail(), 'plan' => $this->_getPackageName($package), 'useregns' => 0); if ($a->getReseller()) { $var_hash['reseller'] = 1; } $json = $this->_request($action, $var_hash); $result = $json->result[0]->status == 1; // if this account is reseller account set ACL list if ($result && $a->getReseller()) { $params = array('user' => $a->getUsername(), 'makeowner' => 0); $this->_request('setupreseller', $params); $params = array('reseller' => $a->getUsername(), 'acllist' => $package->getAcllist()); $this->_request('setacls', $params); } return $result; }
private function _modifyReseller(Server_Account $a) { if (!$this->_checkCommand('modify-reseller')) { throw new Server_Exception('Modify reseller command is only available in Virtualmin PRO version'); } $p = $a->getPackage(); $client = $a->getClient(); $params = array('name' => $a->getUsername(), 'pass' => $a->getPassword(), 'email' => $client->getEmail(), 'max-doms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-aliasdoms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-realdoms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-quota' => $p->getQuota() == 'unlimited' ? 'UNLIMITED' : (int) $p->getQuota() * 1024, 'max-mailboxes' => (int) $p->getMaxPop(), 'max-aliases' => (int) $p->getMaxDomains() ? $p->getMaxDomains() : 1, 'max-dbs' => $p->getMaxSql() == 'unlimited' ? 'UNLIMITED' : (int) $p->getMaxSql(), 'max-bw' => $p->getBandwidth() == 'unlimited' ? 'UNLIMITED' : (int) $p->getBandwidth() * 1024 * 1024, 'allow1' => 'dns', 'allow2' => 'web', 'allow3' => 'webmin', 'allow4' => 'dir', 'allow5' => 'virt', 'nameserver1' => $a->getNs1(), 'nameserver2' => $a->getNs2(), 'nameserver3' => $a->getNs3(), 'nameserver4' => $a->getNs4()); if ($p->getMaxPop()) { $params['allow6'] = 'mail'; } if ($p->getHasSsl()) { $params['allow7'] = 'ssl'; } if ($p->getMaxFtp() > 0) { $params['allow8'] = 'ftp'; } if ($p->getHasSpamFilter()) { $params['allow9'] = 'spam'; } if ($p->getMaxSql() > 0) { $params['allow10'] = 'mysql'; } $response = $this->_makeRequest('modify-reseller', $params); if (isset($response['status']) && $response['status'] == 'success') { return true; } else { throw new Server_Exception('Failed to create reseller\'s account'); } return false; }
private function _changeIpType(Server_Account $a) { $client = $a->getClient(); $params = array('reseller' => array('ippool-set-ip' => array('reseller-id' => $client->getId(), 'filter' => array('ip-address' => $a->getIp()), 'values' => array('ip-type' => 'shared')))); $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->reseller->{'ippool-set-ip'}->result->status) && $response->reseller->{'ippool-set-ip'}->result->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->reseller->{'ippool-set-ip'}->result->errcode . ' - ' . $response->reseller->{'ippool-set-ip'}->result->errtext); } if (isset($response->reseller->{'ippool-set-ip'}->result->status) && $response->reseller->{'ippool-set-ip'}->result->status == 'ok') { return true; } else { return false; } }
/** * 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; }
/** * @param integer $type */ private function createClient(Server_Account &$a, $type) { $client = $a->getClient(); $p = $a->getPackage(); $params = array('server_id' => $this->getServerId(), 'company_name' => $client->getCompany(), 'contact_name' => $client->getFullName(), 'username' => $a->getUsername(), 'password' => $a->getPassword(), 'language' => $p->getCustomValue('languge'), 'usertheme' => $p->getCustomValue('theme'), 'street' => $client->getStreet(), 'zip' => $client->getZip(), 'city' => $client->getCity(), 'state' => $client->getState(), 'country' => $client->getCountry(), 'telephone' => $client->getTelephone(), 'mobile' => $client->getTelephone(), 'fax' => $client->getTelephone(), 'email' => $client->getEmail(), 'internet' => $client->getWww(), 'icq' => '', 'notes' => $a->getNote(), 'template_master' => '0', 'template_additional' => '', 'default_mailserver' => '1', 'limit_maildomain' => '1', 'limit_mailbox' => '-1', 'limit_mailalias' => '-1', 'limit_mailforward' => '-1', 'limit_mailcatchall' => '-1', 'limit_mailrouting' => '-1', 'limit_mailfilter' => '-1', 'limit_fetchmail' => '-1', 'limit_mailquota' => '-1', 'limit_spamfilter_wblist' => '-1', 'limit_spamfilter_user' => '-1', 'limit_spamfilter_policy' => '-1', 'default_webserver' => '1', 'limit_web_domain' => '-1', 'web_php_options' => "SuPHP", 'limit_web_aliasdomain' => '-1', 'limit_web_subdomain' => '-1', 'limit_ftp_user' => '-1', 'limit_shell_user' => '-1', 'ssh_chroot' => 'None', 'default_dnsserver' => '1', 'limit_dns_zone' => '-1', 'limit_dns_record' => '-1', 'limit_client' => $type, 'default_dbserver' => '1', 'limit_database' => '-1', 'limit_cron' => '0', 'limit_cron_type' => '', 'limit_cron_frequency' => '-1'); $action = 'client_add'; $result = $this->_request($action, $params); return $result; }