Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 5
0
 public function changeAccountPassword(Server_Account $a, $new)
 {
     if ($a->getReseller()) {
         if (!$this->_changeResellerPassword($a)) {
             return false;
         }
     } else {
         if (!$this->_changeUserPassword($a)) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Change account IP on server
  * @param Server_Account $a
  * @param type $new - account IP
  */
 public function changeAccountIp(Server_Account $a, $new)
 {
     if ($a->getReseller()) {
         $this->getLog()->info('Changing reseller hosting account ip');
     } else {
         $this->getLog()->info('Changing shared hosting account ip');
     }
 }