예제 #1
0
 private function _addNs(Server_Account $a, $domainId)
 {
     $params = array('dns' => array());
     if ($a->getNs1()) {
         $params['dns']['add_rec1'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs1());
     }
     if ($a->getNs2()) {
         $params['dns']['add_rec2'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs2());
     }
     if ($a->getNs3()) {
         $params['dns']['add_rec3'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs3());
     }
     if ($a->getNs4()) {
         $params['dns']['add_rec4'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs4());
     }
     if (empty($params['dns'])) {
         return true;
     }
     $oldNs = $this->_getNs($a, $domainId);
     $this->_removeDns($oldNs);
     $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);
     }
     foreach ($response->dns->add_rec as $ns) {
         if (isset($ns->result->status) && $ns->result->status == 'error') {
             throw new Server_Exception('Plesk error: ' . $ns->result->errcode . ' - ' . $ns->result->errtext);
         }
     }
     return true;
 }
예제 #2
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;
 }
예제 #3
0
 public function modifyAccount(Server_Account $a)
 {
     $package = $a->getPackage();
     $fields = array();
     $fields['action'] = 'customize';
     $fields['user'] = $a->getUsername();
     $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['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['nemailf'] = $package->getMaxEmailForwarders();
     //Number of forwarders the User will be allowed to create
     if ($package->getMaxEmailForwarders() == 'unlimited') {
         $fields['unemailf'] = 'ON';
         //ON or OFF Unlimited option for nemailf
     }
     $fields['nemailml'] = $package->getMaxEmailLists();
     //Number of mailing lists the User will be allowed to create
     if ($package->getMaxEmailLists() == 'unlimited') {
         $fields['unemailml'] = 'ON';
         //ON or OFF Unlimited option for nemailml
     }
     $fields['nemailr'] = $package->getMaxEmailAutoresponders();
     //Number of autoresponders the User will be allowed to create
     if ($package->getMaxEmailAutoresponders() == 'unlimited') {
         $fields['unemailr'] = 'ON';
         //ON or OFF Unlimited option for nemailr
     }
     $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['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['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['aftp'] = $package->getHasAnonymousFtp() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will be able to have anonymous ftp accounts.
     $fields['cgi'] = $package->getHasCgi() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have the ability to run cgi scripts in their cgi-bin.
     $fields['php'] = $package->getHasPhp() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have the ability to run php scripts.
     $fields['spam'] = $package->getHasSpamFilter() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have the ability to run scan email with SpamAssassin.
     $fields['cron'] = $package->getHasCron() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have the ability to creat cronjobs.
     $fields['catchall'] = $package->getHasCatchAll() ? '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->getHasSll() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have the ability to access their websites through secure https://.
     $fields['ssh'] = $package->getHasShell() ? 'ON' : 'OFF';
     //ON or OFF If ON, the User will have an ssh account.
     $fields['sysinfo'] = 'ON';
     //ON or OFF If ON, the User will have access to a page that shows the system information.
     $fields['dnscontrol'] = 'ON';
     //ON or OFF If ON, the User will be able to modify his/her dns records.
     $fields['ns1'] = $a->getNs1();
     $fields['ns2'] = $a->getNs2();
     $this->_request('CMD_API_MODIFY_USER', $fields);
     return true;
 }
예제 #4
0
 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;
 }