/** * MEthods retrieves information from server, assignes new values to * cloned Server_Account object and returns it. * @param Server_Account $a * @return Server_Account */ public function synchronizeAccount(Server_Account $a) { $this->getLog()->info('Synchronizing account with server ' . $a->getUsername()); $new = clone $a; //@example - retrieve username from server and set it to cloned object //$new->setUsername('newusername'); return $new; }
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 getUserInfo(Server_Account $a) { $fields = array(); $fields['user'] = $a->getUsername(); $result = $this->_request('CMD_API_SHOW_USER_CONFIG', $fields); return; }
public function changeAccountPassword(Server_Account $a, $new) { $params = array('class' => 'client', 'name' => $a->getUsername(), 'action' => 'update', 'subaction' => 'change_password', 'v-password' => $new); $result = $this->_makeRequest($params); if (isset($result['return']) && $result['return'] == 'error') { throw new Server_Exception('Kloxo error: ' . $result['message']); } return true; }
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; }
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 _modifyClient(Server_Account $a) { if ($a->getReseller()) { $type = 'reseller'; $genInfo = 'gen-info'; } else { $type = 'customer'; $genInfo = 'gen_info'; } $client = $a->getClient(); $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' => $client->getEmail(), 'address' => $client->getAddress1(), 'city' => $client->getCity(), 'state' => $client->getState(), '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; }
/** * Change account password on server * @param Server_Account $a * @param type $new - new password */ public function changeAccountPassword(Server_Account $a, $new) { // Server credentials $vst_username = $this->_config['username']; $vst_password = $this->_config['password']; $vst_command = 'v-change-user-password'; $vst_returncode = 'yes'; // Prepare POST query $postvars = array('returncode' => $vst_returncode, 'cmd' => $vst_command, 'arg1' => $a->getUsername(), 'arg2' => $new); // Make request and change password $result = $this->_makeRequest($postvars); if ($result != '0') { throw new Server_Exception('Server Manager Vesta CP Error: Change Password Account Error ' . $result); } return true; }
private function getClient(Server_Account $a) { $params['username'] = $a->getUsername(); $result = $this->_request('client_get_by_username', $params); return $result; }