From be65d40cdfefed6216e42cc8232c0f678c5ad23e Mon Sep 17 00:00:00 2001 From: pmill Date: Sun, 19 Jun 2016 16:24:11 +0100 Subject: [PATCH 1/4] Added extra php options to UpdateSite --- src/pmill/Plesk/UpdateSite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pmill/Plesk/UpdateSite.php b/src/pmill/Plesk/UpdateSite.php index 6a48ca6..a32344a 100644 --- a/src/pmill/Plesk/UpdateSite.php +++ b/src/pmill/Plesk/UpdateSite.php @@ -54,7 +54,7 @@ public function __construct(array $config, $params = []) { $properties = []; - foreach (['php', 'php_handler_type', 'webstat', 'www_root'] as $key) { + foreach (['php', 'php_handler_type', 'webstat', 'www_root', 'php', 'php_handler_id', 'php_version'] as $key) { if (isset($params[$key])) { $properties[$key] = $params[$key]; } From 39aa45d197e85dfc1f29efa3d9c5a6b89a6ae85f Mon Sep 17 00:00:00 2001 From: pmill Date: Sun, 19 Jun 2016 16:26:49 +0100 Subject: [PATCH 2/4] Updated README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index cc36b3a..61d2ea6 100755 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ Unversioned (13 Apr 2013) * Updated GetServicePlan to accept 'guid' as a filter option * Updated DeleteSiteAlias to accept 'alias' as a filter option +New + +* Updated available parameters on UpdateSite + Copyright and License --------------------- From 16e697ff273a687c96b21b346b7b6e536ce2a9d3 Mon Sep 17 00:00:00 2001 From: Jarrod Linahan Date: Wed, 13 Jul 2016 13:24:13 +1000 Subject: [PATCH 3/4] Add support for get_traffic --- examples/Subscriptions/get_traffic.php | 23 ++++++ src/pmill/Plesk/GetTraffic.php | 104 +++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 examples/Subscriptions/get_traffic.php create mode 100644 src/pmill/Plesk/GetTraffic.php diff --git a/examples/Subscriptions/get_traffic.php b/examples/Subscriptions/get_traffic.php new file mode 100644 index 0000000..03bdfde --- /dev/null +++ b/examples/Subscriptions/get_traffic.php @@ -0,0 +1,23 @@ +'1', +// 'name' => 'demo.parallels.com', +// 'owner-login' => 'customer', +// 'since_date' => '2016-06-01', +// 'to_date' => '2016-06-10' +); + +$request = new \pmill\Plesk\GetTraffic($config, $params); +$info = $request->process(); + +var_dump($info); + +if ($info === false) { + var_dump($request->error); +} diff --git a/src/pmill/Plesk/GetTraffic.php b/src/pmill/Plesk/GetTraffic.php new file mode 100644 index 0000000..c7fde7d --- /dev/null +++ b/src/pmill/Plesk/GetTraffic.php @@ -0,0 +1,104 @@ + + + + + {FILTER} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'filter' => null, + ]; + + /** + * @param array $config + * @param array $params + * @throws ApiRequestException + */ + public function __construct($config, $params = []) + { + $filterChildNodes = []; + + foreach (['name', 'owner-id', 'owner-login', 'guid', 'id'] as $nodeName) { + if (isset($params[$nodeName])) { + if (!is_array($params[$nodeName])) { + $params[$nodeName] = [$params[$nodeName]]; + } + + foreach ($params[$nodeName] as $value) { + $filterChildNodes[] = new Node($nodeName, $value); + } + } + } + + $filter = [ new Node('filter', new NodeList($filterChildNodes)) ]; + + if (isset($params['since_date'])) { + $filter[] = new Node('since_date', $params['since_date']); + } + + if (isset($params['to_date'])) { + $filter[] = new Node('to_date', $params['to_date']); + } + + $params = [ + 'filter' => new NodeList($filter) + ]; + + parent::__construct($config, $params); + } + + /** + * @param $xml + * @return array + */ + protected function processResponse($xml) + { + $result = []; + + for ($i = 0; $i < count($xml->webspace->get_traffic->result); $i++) { + $webspace = $xml->webspace->get_traffic->result[$i]; + + $traffic = []; + foreach ($webspace->traffic as $day) { + $traffic[] = [ + 'date' => (string)$day->date, + 'http_in' => (int)$day->http_in, + 'http_out' => (int)$day->http_out, + 'ftp_in' => (int)$day->ftp_in, + 'ftp_out' => (int)$day->ftp_out, + 'smtp_in' => (int)$day->smtp_in, + 'smtp_out' => (int)$day->smtp_out, + 'pop3_imap_in' => (int)$day->pop3_imap_in, + 'pop3_imap_out' => (int)$day->pop3_imap_out + ]; + } + + $result[] = [ + 'id' => (string)$webspace->id, + 'status' => (string)$webspace->status, + 'error_code' => (int)$webspace->errcode, + 'error_text' => (string)$webspace->errtext, + 'traffic' => $traffic, + ]; + } + + return $result; + } +} From 2701fc6d6890cdee2bc3f6d96d9dc8ad24bac362 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 1 Sep 2016 19:08:36 +0100 Subject: [PATCH 4/4] Fixed error checking --- examples/config.php | 2 +- src/pmill/Plesk/BaseRequest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/config.php b/examples/config.php index 5cbdd4d..7ee9d45 100644 --- a/examples/config.php +++ b/examples/config.php @@ -5,7 +5,7 @@ $classLoader->register(); $config = array( - 'host'=>'plesk12-webhost.demo.parallels.com', + 'host'=>'plesk12-webadmin.demo.parallels.com', 'username'=>'admin', 'password'=>'panel', ); diff --git a/src/pmill/Plesk/BaseRequest.php b/src/pmill/Plesk/BaseRequest.php index 1cba619..0aa049a 100644 --- a/src/pmill/Plesk/BaseRequest.php +++ b/src/pmill/Plesk/BaseRequest.php @@ -229,7 +229,7 @@ private function sendRequest($packet) */ private function checkResponse(SimpleXMLElement $response) { - if ($response->system->status === 'error') { + if ((string)$response->system->status === 'error') { throw new ApiRequestException($response->system); } }