From c8fb3253aa2cfa7474ca14c2e323ea205a7dd2f5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 3 Jul 2012 23:05:08 +1000 Subject: [PATCH] Added getDNS() to plesk --- modules/host/classes/controller/task/host.php | 13 ++++++++++ modules/host/classes/host/plugin/plesk/10.php | 23 +++++++++++++++++ modules/host/classes/host/plugin/plesk/9.php | 25 +++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/modules/host/classes/controller/task/host.php b/modules/host/classes/controller/task/host.php index 752363ec..a13a097c 100644 --- a/modules/host/classes/controller/task/host.php +++ b/modules/host/classes/controller/task/host.php @@ -20,6 +20,7 @@ class Controller_Task_Host extends Controller_Task { switch (Request::current()->action()) { case 'getclient': case 'getdomain': + case 'getdns': case 'getreseller': case 'gettraffic': case 'provision': @@ -85,6 +86,18 @@ class Controller_Task_Host extends Controller_Task { print_r($result); } + /** + * Get DNS Details from Host Server + */ + public function action_getdns() { + $result = $this->hpo->cmd_getdns($this->so,'/tmp/z'); + + #if ($result->loaded()) + # $this->verify('d',$result); + + print_r($result); + } + /** * Get Reseller */ diff --git a/modules/host/classes/host/plugin/plesk/10.php b/modules/host/classes/host/plugin/plesk/10.php index 068faf65..cc17a8fa 100644 --- a/modules/host/classes/host/plugin/plesk/10.php +++ b/modules/host/classes/host/plugin/plesk/10.php @@ -66,6 +66,29 @@ class Host_Plugin_Plesk_10 extends Host_Plugin_Plesk { return $this; } + /** + * Get a DNS Configuration + */ + public function cmd_getdns(Model_Service $so,$file='') { + $do = $this->cmd_getdomain($so); + + $this->init(); + $domain = $this->packet->add_node('dns'); + $get = $domain->add_node('get_rec'); + $filter = $get->add_node('filter'); + $filter->add_node('site-id',$do->id); + + $result = $this->server_command($this->xml); + if (! $this->loaded()) + throw new Kohana_Exception('Unable to get PLESK Domain data - Error :error',array(':error'=>(string)$result)); + + $this->_object = $this->collapse($result); + if ($file) + file_put_contents($file,(string)$result); + + return $this; + } + /** * Get a Domain Configuration */ diff --git a/modules/host/classes/host/plugin/plesk/9.php b/modules/host/classes/host/plugin/plesk/9.php index d1e08024..70851fa3 100644 --- a/modules/host/classes/host/plugin/plesk/9.php +++ b/modules/host/classes/host/plugin/plesk/9.php @@ -99,6 +99,7 @@ class Host_Plugin_Plesk_9 extends Host_Plugin_Plesk { if (! $this->loaded()) throw new Kohana_Exception('Unable to get PLESK Client data - Error :error',array(':error'=>(string)$result)); + $this->_object['id'] = $result->id->value(); foreach ($items as $k) foreach ($result->get($k) as $a=>$b) $this->_object[$k] = $this->collapse($b); @@ -106,6 +107,29 @@ class Host_Plugin_Plesk_9 extends Host_Plugin_Plesk { return $this; } + /** + * Get a DNS Configuration + */ + public function cmd_getdns(Model_Service $so,$file='') { + $do = $this->cmd_getdomain($so); + + $this->init(); + $domain = $this->packet->add_node('dns'); + $get = $domain->add_node('get_rec'); + $filter = $get->add_node('filter'); + $filter->add_node('domain_id',$do->id); + + $result = $this->server_command($this->xml); + if (! $this->loaded()) + throw new Kohana_Exception('Unable to get PLESK Domain data - Error :error',array(':error'=>(string)$result)); + + $this->_object = $this->collapse($result); + if ($file) + file_put_contents($file,(string)$result); + + return $this; + } + /** * Get a Domain Configuration */ @@ -126,6 +150,7 @@ class Host_Plugin_Plesk_9 extends Host_Plugin_Plesk { if (! $this->loaded()) throw new Kohana_Exception('Unable to get PLESK Domain data - Error :error',array(':error'=>(string)$result)); + $this->_object['id'] = $result->id->value(); foreach ($items as $k) foreach ($result->get($k) as $a=>$b) $this->_object[$k] = $this->collapse($b);