From 1cca181f5cdce7f01b359b2ae8a1a3b225519265 Mon Sep 17 00:00:00 2001 From: "Mr. Timothy Glenn Webb Sr" Date: Tue, 13 Oct 2020 01:22:18 +0000 Subject: [PATCH] Plesk Revision5 --- src/bb-library/Server/Manager/Plesk.php | 64 +++++++++++------------ src/bb-modules/Servicehosting/Service.php | 32 ++++++------ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/bb-library/Server/Manager/Plesk.php b/src/bb-library/Server/Manager/Plesk.php index fb7f8cb32..2627cbe44 100644 --- a/src/bb-library/Server/Manager/Plesk.php +++ b/src/bb-library/Server/Manager/Plesk.php @@ -575,35 +575,35 @@ class Server_Manager_Plesk extends Server_Manager throw new Server_Exception('Server manager does not support ip changes'); } - private function _makeRequest($params) { - $headers = array( - 'HTTP_AUTH_LOGIN: ' . $this->_config['username'], - 'HTTP_AUTH_PASSWD: ' . $this->_config['password'], - 'HTTP_PRETTY_PRINT: TRUE', - 'Content-Type: text/xml' - ); - - $xml = $this->_arrayToXml($params, new SimpleXMLElement('')) - ->asXML(); - error_log($xml); - $ch = curl_init (); - curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt ($ch, CURLOPT_URL, $this->getLoginUrl()); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt ($ch, CURLOPT_TIMEOUT, 60); - curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml); - curl_setopt ($ch, CURLOPT_POST, $xml); - - $result = curl_exec($ch); - - if (curl_errno ($ch)) { - throw new Server_Exception('cURL error: ' . curl_errno ($ch) . ' - ' . curl_error ($ch)); - } - - return $this->_parseResponse($result); - } +// private function _makeRequest($params) { +// $headers = array( +// 'HTTP_AUTH_LOGIN: ' . $this->_config['username'], +// 'HTTP_AUTH_PASSWD: ' . $this->_config['password'], +// 'HTTP_PRETTY_PRINT: TRUE', +// 'Content-Type: text/xml' +// ); +// +// $xml = $this->_arrayToXml($params, new SimpleXMLElement('')) +// ->asXML(); +// error_log($xml); +// $ch = curl_init (); +// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); +// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); +// curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); +// curl_setopt ($ch, CURLOPT_URL, $this->getLoginUrl()); +// curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); +// curl_setopt ($ch, CURLOPT_TIMEOUT, 60); +// curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml); +// curl_setopt ($ch, CURLOPT_POST, $xml); +// +// $result = curl_exec($ch); +// +// if (curl_errno ($ch)) { +// throw new Server_Exception('cURL error: ' . curl_errno ($ch) . ' - ' . curl_error ($ch)); +// } +// +// return $this->_parseResponse($result); +// } private function _arrayToXml(array $arr, SimpleXMLElement $xml) { $numbers = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); @@ -1006,17 +1006,17 @@ class Server_Manager_Plesk extends Server_Manager * @param string $request * @return string */ - public function request($request) + public function _makeRequest($request) { $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, "$this->_protocol://$this->_host:$this->_port/enterprise/control/agent.php"); + curl_setopt($curl, CURLOPT_URL, '"$this->_protocol://$this->_host:$this->_port/enterprise/control/agent.php"'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, $this->_getHeaders()); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request); + curl_setopt($curl, CURLOPT_POSTFIELDS, '$request'); $result = curl_exec($curl); diff --git a/src/bb-modules/Servicehosting/Service.php b/src/bb-modules/Servicehosting/Service.php index bf8520b54..1159715fc 100644 --- a/src/bb-modules/Servicehosting/Service.php +++ b/src/bb-modules/Servicehosting/Service.php @@ -76,7 +76,7 @@ class Service implements InjectionAwareInterface $c = $orderService->getConfig($order); $this->validateOrderData($c); - $server = $this->di['db']->getExistingModelById('ServiceHosting', $c['server_id'], 'Server from order configuration was not found'); + $server = $this->di['db']->getExistingModelById('ServiceHostingServer', $c['server_id'], 'Server from order configuration was not found'); $hp = $this->di['db']->getExistingModelById('ServiceHostingHp', $c['hosting_plan_id'], 'Hosting plan from order configuration was not found'); @@ -339,7 +339,7 @@ class Service implements InjectionAwareInterface return TRUE; } - public function sync(\Model_ClientOrder $order, \Model_ServiceHosting $model, $data) + public function sync(\Model_ClientOrder $order, \Model_ServiceHosting $model) { list($adapter, $account) = $this->_getAM($model); $updated = $adapter->synchronizeAccount($account); @@ -398,7 +398,7 @@ class Service implements InjectionAwareInterface $hp = $this->di['db']->getExistingModelById('ServiceHostingHp', $model->service_hosting_hp_id, 'Hosting plan not found'); } - $server = $this->di['db']->getExistingModelById('ServiceHosting', $model->service_hosting_server_id, 'Server not found'); + $server = $this->di['db']->getExistingModelById('ServiceHostingServer', $model->service_hosting_server_id, 'Server not found'); $c = $this->di['db']->getExistingModelById('Client', $model->client_id, 'Client not found'); $hp_config = $hp->config; @@ -442,11 +442,11 @@ class Service implements InjectionAwareInterface return array($adapter, $a); } - public function toApiArray(\Model_ServiceHosting $model, $deep = false, $identity = null) + public function toApiArray(\Model_ServiceHostingServer $model, $deep, $identity) { - $serviceHostingModel = $this->di['db']->load('ServiceHosting', $model->service_hosting_server_id); + $serviceHostingServerModel = $this->di['db']->load('ServiceHostingServer', $model->service_hosting_server_id); $serviceHostingHpModel = $this->di['db']->load('ServiceHostingHp', $model->service_hosting_hp_id); - $server = $this->toHostingServerApiArray($serviceHostingModel, $deep, $identity); + $server = $this->toHostingServerApiArray($serviceHostingServerModel, $deep, $identity); $hp = $this->toHostingHpApiArray($serviceHostingHpModel, $deep, $identity); return array( @@ -462,9 +462,9 @@ class Service implements InjectionAwareInterface ); } - public function toHostingServerApiArray(\Model_ServiceHosting $model, $deep = false, $identity = null) + public function toHostingServerApiArray(\Model_ServiceHostingServer $model, $deep = false, $identity = null) { - list($cpanel_url, $whm_url) = $this->getmanagerUrls($model); + list($cpanel_url, $whm_url) = $this->getManagerUrls($model); $result = array( 'name' => $model->name, 'hostname' => $model->hostname, @@ -567,7 +567,7 @@ class Service implements InjectionAwareInterface return $d; } - private function _getServerManagers($manager) + private function _getServerManagers() { $dir = BB_PATH_LIBRARY . '/Server/Manager'; $files = array(); @@ -621,7 +621,7 @@ class Service implements InjectionAwareInterface public function createServer($name, $ip, $manager, $data) { - $model = $this->di['db']->dispense('ServiceHosting'); + $model = $this->di['db']->dispense('ServiceHostingServer'); $model->name = $name; $model->ip = $ip; @@ -652,7 +652,7 @@ class Service implements InjectionAwareInterface return $newId; } - public function deleteServer(\Model_ServiceHosting $model) + public function deleteServer(\Model_ServiceHostingServer $model) { $id = $model->id; $this->di['db']->trash($model); @@ -660,7 +660,7 @@ class Service implements InjectionAwareInterface return true; } - public function updateServer(\Model_ServiceHosting $model, array $data) + public function updateServer(\Model_ServiceHostingServer $model, array $data) { $model->name = $this->di['array_get']($data, 'name', $model->name); $model->ip = $this->di['array_get']($data, 'ip', $model->ip); @@ -696,7 +696,7 @@ class Service implements InjectionAwareInterface return true; } - public function getServerManager(\Model_ServiceHosting $model) + public function getServerManager(\Model_ServiceHostingServer $model) { if(empty($model->manager)) { throw new \Box_Exception('Invalid server manager. Server was not configured properly.', null, 654); @@ -720,7 +720,7 @@ class Service implements InjectionAwareInterface return $manager; } - public function testConnection(\Model_ServiceHosting $model) + public function testConnection(\Model_ServiceHostingServer $model) { $m = $this->getServerManager($model); return $m->testConnection(); @@ -871,7 +871,7 @@ class Service implements InjectionAwareInterface return $p; } - public function getServerManagerWithLog(\Model_ServiceHosting $model, \Model_ClientOrder $order) + public function getServerManagerWithLog(\Model_ServiceHostingServer $model, \Model_ClientOrder $order) { $manager = $this->getServerManager($model); @@ -881,7 +881,7 @@ class Service implements InjectionAwareInterface return $manager; } - public function getmanagerUrls(\Model_ServiceHosting $model) + public function getManagerUrls(\Model_ServiceHostingServer $model) { try { $m = $this->getServerManager($model);