Example #1
0
 private function getUserInfo(Server_Account $a)
 {
     $fields = array();
     $fields['user'] = $a->getUsername();
     $result = $this->_request('CMD_API_SHOW_USER_CONFIG', $fields);
     return;
 }
Example #2
0
 private function _changeIpType(Server_Account $a)
 {
     $params = array('reseller' => array('ippool-set-ip' => array('reseller-id' => $a->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;
     }
 }
Example #3
0
 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;
 }
Example #4
0
 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;
 }
Example #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;
 }
Example #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');
     }
 }
 /**
  * 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;
 }
Example #8
0
 public function testsync()
 {
     $data = array('password' => 'topsecret', 'password_confirm' => 'topsecret');
     $orderModel = new \Model_ClientOrder();
     $orderModel->loadBean(new \RedBeanPHP\OODBBean());
     $model = new \Model_ServiceHosting();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Servicehosting\\Service')->setMethods(array('_getAM'))->getMock();
     $accountObj = new \Server_Account();
     $accountObj->setUsername('testUser1');
     $accountObj->setIp('1.1.1.1');
     $accountObj2 = new \Server_Account();
     $accountObj2->setUsername('testUser2');
     $accountObj2->setIp('2.2.2.2');
     $serverManagerMock = $this->getMockBuilder('\\Server_Manager_Custom')->disableOriginalConstructor()->getMock();
     $serverManagerMock->expects($this->atLeastOnce())->method('synchronizeAccount')->will($this->returnValue($accountObj2));
     $AMresultArray = array($serverManagerMock, $accountObj);
     $serviceMock->expects($this->atLeastOnce())->method('_getAM')->will($this->returnValue($AMresultArray));
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('store');
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['logger'] = new \Box_Log();
     $serviceMock->setDi($di);
     $result = $serviceMock->sync($orderModel, $model, $data);
     $this->assertTrue($result);
 }
Example #9
0
 private function getClient(Server_Account $a)
 {
     $params['username'] = $a->getUsername();
     $result = $this->_request('client_get_by_username', $params);
     return $result;
 }