Exemple #1
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;
 }
 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;
     }
 }
 public function changeAccountPackage(Server_Account $a, Server_Package $p)
 {
     $fields = array();
     $fields['action'] = 'package';
     $fields['user'] = $a->getUsername();
     $fields['package'] = $a->getPackage()->getName();
     $this->_request('CMD_API_MODIFY_USER', $fields);
     return true;
 }
Exemple #4
0
 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;
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 /**
  *
  * Creates new client account
  * @param Server_Account $a
  * @throws Server_Exception
  * @return integer client's plesk id
  */
 private function _creatClient(Server_Account $a)
 {
     if ($a->getReseller()) {
         $type = 'reseller';
         $genInfo = 'gen-info';
     } else {
         $type = 'customer';
         $genInfo = 'gen_info';
     }
     $client = $a->getClient();
     $p = $a->getPackage();
     $params = array($type => array('add' => 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}->add->result->status) && $response->{$type}->add->result->status == 'error') {
         throw new Server_Exception('Plesk error: ' . $response->{$type}->add->result->errcode . ' - ' . $response->{$type}->add->result->errtext);
     }
     if (isset($response->{$type}->add->result->status) && $response->{$type}->add->result->status == 'ok') {
         return $response->{$type}->add->result->id;
     }
     return 0;
 }
 /**
  * Change account package on server
  * @param Server_Account $a
  * @param Server_Package $p 
  */
 public function changeAccountPackage(Server_Account $a, Server_Package $p)
 {
     $package = $a->getPackage()->getName();
     // Server credentials
     $vst_username = $this->_config['username'];
     $vst_password = $this->_config['password'];
     $vst_command = 'v-change-user-package';
     $vst_returncode = 'yes';
     // Prepare POST query
     $postvars = array('returncode' => $vst_returncode, 'cmd' => $vst_command, 'arg1' => $a->getUsername(), 'arg2' => $this->_getPackageName($p), 'arg3' => 'no');
     // Make request and change package
     $result = $this->_makeRequest($postvars);
     if ($result != '0') {
         throw new Server_Exception('Server Manager Vesta CP Error: Change User package Account Error ' . $result);
     }
     return true;
 }
Exemple #8
0
 /**
  * @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;
 }