From 6067420423a331401e008029e18c97af8ba828fa Mon Sep 17 00:00:00 2001 From: Peter Millard Date: Thu, 10 Mar 2016 14:23:40 +0000 Subject: [PATCH 01/26] Added wordpress ListInstances command --- examples/Wordpress/list_instances.php | 11 ++++++ src/pmill/Plesk/Wordpress/ListInstances.php | 39 +++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 examples/Wordpress/list_instances.php create mode 100644 src/pmill/Plesk/Wordpress/ListInstances.php diff --git a/examples/Wordpress/list_instances.php b/examples/Wordpress/list_instances.php new file mode 100644 index 0000000..d525b78 --- /dev/null +++ b/examples/Wordpress/list_instances.php @@ -0,0 +1,11 @@ +process(); + +var_dump($info); diff --git a/src/pmill/Plesk/Wordpress/ListInstances.php b/src/pmill/Plesk/Wordpress/ListInstances.php new file mode 100644 index 0000000..53b4526 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/ListInstances.php @@ -0,0 +1,39 @@ + + + + + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + */ + protected function processResponse($xml) + { + $response = array(); + + foreach ($xml->{'wp-instance'}->{'get-list'}->result as $result) { + $result = $result->{'wp-instance'}; + + $response[] = [ + 'id' => (int) $result->id, + 'url' => (string) $result->url, + 'owner' => (string) $result->owner, + ]; + } + + return $response; + } +} From 7442924219d5a8c91d55969f9cac4a1277126de2 Mon Sep 17 00:00:00 2001 From: Peter Millard Date: Thu, 10 Mar 2016 14:45:35 +0000 Subject: [PATCH 02/26] Added wordpress EnableAutoUpdates feature --- examples/Wordpress/enable_auto_updates.php | 15 +++++++ .../Plesk/Wordpress/EnableAutoUpdates.php | 43 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/Wordpress/enable_auto_updates.php create mode 100644 src/pmill/Plesk/Wordpress/EnableAutoUpdates.php diff --git a/examples/Wordpress/enable_auto_updates.php b/examples/Wordpress/enable_auto_updates.php new file mode 100644 index 0000000..c56dfa2 --- /dev/null +++ b/examples/Wordpress/enable_auto_updates.php @@ -0,0 +1,15 @@ + 2, +]; + +$request = new \pmill\Plesk\Wordpress\EnableAutoUpdates($config, $params); + +$info = $request->process(); +var_dump($info); diff --git a/src/pmill/Plesk/Wordpress/EnableAutoUpdates.php b/src/pmill/Plesk/Wordpress/EnableAutoUpdates.php new file mode 100644 index 0000000..0734a8e --- /dev/null +++ b/src/pmill/Plesk/Wordpress/EnableAutoUpdates.php @@ -0,0 +1,43 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'enable-auto-updates'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'enable-auto-updates'}->result); + } + + return true; + } +} From d57b18c6404cbddce4a8aeee696e13bad28e0941 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:01:43 +0000 Subject: [PATCH 03/26] Added wordpress DisableAutoUpdates feature --- examples/Wordpress/disable_auto_updates.php | 19 ++++++++ examples/Wordpress/enable_auto_updates.php | 6 ++- .../Plesk/Wordpress/DisableAutoUpdates.php | 43 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 examples/Wordpress/disable_auto_updates.php create mode 100644 src/pmill/Plesk/Wordpress/DisableAutoUpdates.php diff --git a/examples/Wordpress/disable_auto_updates.php b/examples/Wordpress/disable_auto_updates.php new file mode 100644 index 0000000..b4f948a --- /dev/null +++ b/examples/Wordpress/disable_auto_updates.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\DisableAutoUpdates($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/examples/Wordpress/enable_auto_updates.php b/examples/Wordpress/enable_auto_updates.php index c56dfa2..d9944f6 100644 --- a/examples/Wordpress/enable_auto_updates.php +++ b/examples/Wordpress/enable_auto_updates.php @@ -6,10 +6,14 @@ * Enables */ $params = [ - 'id' => 2, + 'id' => 1, ]; $request = new \pmill\Plesk\Wordpress\EnableAutoUpdates($config, $params); $info = $request->process(); var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/DisableAutoUpdates.php b/src/pmill/Plesk/Wordpress/DisableAutoUpdates.php new file mode 100644 index 0000000..53bd7df --- /dev/null +++ b/src/pmill/Plesk/Wordpress/DisableAutoUpdates.php @@ -0,0 +1,43 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'disable-auto-updates'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'disable-auto-updates'}->result); + } + + return true; + } +} From cda8004597ab1b0bed34d7563f558daf5a8843ad Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:05:40 +0000 Subject: [PATCH 04/26] Added wordpress UpdateCore feature --- examples/Wordpress/update_core.php | 19 +++++++++++ src/pmill/Plesk/Wordpress/UpdateCore.php | 43 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/Wordpress/update_core.php create mode 100644 src/pmill/Plesk/Wordpress/UpdateCore.php diff --git a/examples/Wordpress/update_core.php b/examples/Wordpress/update_core.php new file mode 100644 index 0000000..d2fab02 --- /dev/null +++ b/examples/Wordpress/update_core.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\UpdateCore($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/UpdateCore.php b/src/pmill/Plesk/Wordpress/UpdateCore.php new file mode 100644 index 0000000..2f5fe30 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/UpdateCore.php @@ -0,0 +1,43 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'update-core'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'update-core'}->result); + } + + return true; + } +} From 5c5441a813d7b5b3e573db5ca3e761652d09e6be Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:11:09 +0000 Subject: [PATCH 05/26] Added wordpress RemoveInstance feature --- examples/Wordpress/remove_instance.php | 19 +++++++++ src/pmill/Plesk/Wordpress/RemoveInstance.php | 43 ++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/Wordpress/remove_instance.php create mode 100644 src/pmill/Plesk/Wordpress/RemoveInstance.php diff --git a/examples/Wordpress/remove_instance.php b/examples/Wordpress/remove_instance.php new file mode 100644 index 0000000..780eeaa --- /dev/null +++ b/examples/Wordpress/remove_instance.php @@ -0,0 +1,19 @@ + 2, +]; + +$request = new \pmill\Plesk\Wordpress\RemoveInstance($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/RemoveInstance.php b/src/pmill/Plesk/Wordpress/RemoveInstance.php new file mode 100644 index 0000000..317763f --- /dev/null +++ b/src/pmill/Plesk/Wordpress/RemoveInstance.php @@ -0,0 +1,43 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'remove'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'remove'}->result); + } + + return true; + } +} From 41a61b04c03d4291bc2e768a02abd5784c624482 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:12:34 +0000 Subject: [PATCH 06/26] Added wordpress ClearCache feature --- examples/Wordpress/clear_cache.php | 19 +++++++++++ src/pmill/Plesk/Wordpress/ClearCache.php | 43 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/Wordpress/clear_cache.php create mode 100644 src/pmill/Plesk/Wordpress/ClearCache.php diff --git a/examples/Wordpress/clear_cache.php b/examples/Wordpress/clear_cache.php new file mode 100644 index 0000000..15acf8e --- /dev/null +++ b/examples/Wordpress/clear_cache.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\ClearCache($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/ClearCache.php b/src/pmill/Plesk/Wordpress/ClearCache.php new file mode 100644 index 0000000..18538eb --- /dev/null +++ b/src/pmill/Plesk/Wordpress/ClearCache.php @@ -0,0 +1,43 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'clear-cache'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'clear-cache'}->result); + } + + return true; + } +} From 4f93bca2bb317347c29a3fe979cce545c9f14d07 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:18:55 +0000 Subject: [PATCH 07/26] Added wordpress GetSecurityStatus feature --- examples/Wordpress/get_security_status.php | 19 +++++++++ .../Plesk/Wordpress/GetSecurityStatus.php | 39 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/Wordpress/get_security_status.php create mode 100644 src/pmill/Plesk/Wordpress/GetSecurityStatus.php diff --git a/examples/Wordpress/get_security_status.php b/examples/Wordpress/get_security_status.php new file mode 100644 index 0000000..15983c9 --- /dev/null +++ b/examples/Wordpress/get_security_status.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\GetSecurityStatus($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/GetSecurityStatus.php b/src/pmill/Plesk/Wordpress/GetSecurityStatus.php new file mode 100644 index 0000000..3148fa2 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/GetSecurityStatus.php @@ -0,0 +1,39 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + */ + protected function processResponse($xml) + { + $response = []; + + foreach ($xml->{'wp-instance'}->{'get-security-status'}->result as $result) { + $response[] = [ + 'status' => (string) $result->status, + 'security-status' => (string) $result->{'security-status'}, + ]; + } + + return $response; + } +} From d30ce477c85c3ac19165246e0a4d016eb69dc3a4 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:25:12 +0000 Subject: [PATCH 08/26] Added wordpress GetPluginList feature --- examples/Wordpress/get_plugin_list.php | 19 +++++++++ src/pmill/Plesk/Wordpress/GetPluginList.php | 45 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 examples/Wordpress/get_plugin_list.php create mode 100644 src/pmill/Plesk/Wordpress/GetPluginList.php diff --git a/examples/Wordpress/get_plugin_list.php b/examples/Wordpress/get_plugin_list.php new file mode 100644 index 0000000..f22172e --- /dev/null +++ b/examples/Wordpress/get_plugin_list.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\GetPluginList($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/GetPluginList.php b/src/pmill/Plesk/Wordpress/GetPluginList.php new file mode 100644 index 0000000..9dc43ce --- /dev/null +++ b/src/pmill/Plesk/Wordpress/GetPluginList.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'get-plugin-list'}->result->status == "error") { + throw new ApiRequestException($xml->{'wp-instance'}->{'get-plugin-list'}->result); + } + + $response = []; + + foreach ($xml->{'wp-instance'}->{'get-plugin-list'}->result->item as $result) { + $response[] = [ + 'title' => (string) $result->title, + 'id' => (string) $result->id, + ]; + } + + return $response; + } +} From 914d3f1eb20fbecd6c1c60efb32d81077bdd7588 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:27:11 +0000 Subject: [PATCH 09/26] Added wordpress GetThemeList feature --- examples/Wordpress/get_theme_list.php | 19 +++++++++ src/pmill/Plesk/Wordpress/GetThemeList.php | 45 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 examples/Wordpress/get_theme_list.php create mode 100644 src/pmill/Plesk/Wordpress/GetThemeList.php diff --git a/examples/Wordpress/get_theme_list.php b/examples/Wordpress/get_theme_list.php new file mode 100644 index 0000000..4a1f58f --- /dev/null +++ b/examples/Wordpress/get_theme_list.php @@ -0,0 +1,19 @@ + 1, +]; + +$request = new \pmill\Plesk\Wordpress\GetThemeList($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/GetThemeList.php b/src/pmill/Plesk/Wordpress/GetThemeList.php new file mode 100644 index 0000000..54d4a86 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/GetThemeList.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'get-theme-list'}->result->status == "error") { + throw new ApiRequestException($xml->{'wp-instance'}->{'get-theme-list'}->result); + } + + $response = []; + + foreach ($xml->{'wp-instance'}->{'get-theme-list'}->result->item as $result) { + $response[] = [ + 'title' => (string) $result->title, + 'id' => (string) $result->id, + ]; + } + + return $response; + } +} From f3fb780e02b3c4ab8df3bf15388cb5a8cbeb6294 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:30:47 +0000 Subject: [PATCH 10/26] Added wordpress SearchPlugins feature --- examples/Wordpress/search_plugins.php | 19 +++++++++ src/pmill/Plesk/Wordpress/SearchPlugins.php | 43 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/Wordpress/search_plugins.php create mode 100644 src/pmill/Plesk/Wordpress/SearchPlugins.php diff --git a/examples/Wordpress/search_plugins.php b/examples/Wordpress/search_plugins.php new file mode 100644 index 0000000..5ed819d --- /dev/null +++ b/examples/Wordpress/search_plugins.php @@ -0,0 +1,19 @@ + 'Responsify', +]; + +$request = new \pmill\Plesk\Wordpress\SearchPlugins($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/SearchPlugins.php b/src/pmill/Plesk/Wordpress/SearchPlugins.php new file mode 100644 index 0000000..267a2b2 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/SearchPlugins.php @@ -0,0 +1,43 @@ + + + + + {QUERY} + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'search-plugins'}->result->status == "error") { + throw new ApiRequestException($xml->{'wp-instance'}->{'search-plugins'}->result); + } + + $response = []; + + foreach ($xml->{'wp-instance'}->{'search-plugins'}->result->item as $result) { + $response[] = [ + 'title' => (string) $result->title, + 'id' => (string) $result->id, + ]; + } + + return $response; + } +} From 1f6eba6ff0b2095b9447781a7e04d0aa0e7909ea Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:32:31 +0000 Subject: [PATCH 11/26] Added wordpress SearchThemes feature --- examples/Wordpress/search_themes.php | 19 ++++++++++ src/pmill/Plesk/Wordpress/SearchThemes.php | 43 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 examples/Wordpress/search_themes.php create mode 100644 src/pmill/Plesk/Wordpress/SearchThemes.php diff --git a/examples/Wordpress/search_themes.php b/examples/Wordpress/search_themes.php new file mode 100644 index 0000000..6625e54 --- /dev/null +++ b/examples/Wordpress/search_themes.php @@ -0,0 +1,19 @@ + 'Lite', +]; + +$request = new \pmill\Plesk\Wordpress\SearchThemes($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/SearchThemes.php b/src/pmill/Plesk/Wordpress/SearchThemes.php new file mode 100644 index 0000000..2c21419 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/SearchThemes.php @@ -0,0 +1,43 @@ + + + + + {QUERY} + + + +EOT; + + /** + * @param SimpleXMLElement $xml + * @return array + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'search-themes'}->result->status == "error") { + throw new ApiRequestException($xml->{'wp-instance'}->{'search-themes'}->result); + } + + $response = []; + + foreach ($xml->{'wp-instance'}->{'search-themes'}->result->item as $result) { + $response[] = [ + 'title' => (string) $result->title, + 'id' => (string) $result->id, + ]; + } + + return $response; + } +} From cd7fb8ef9d216236a514680879d82ea6a8b6a7c3 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:36:31 +0000 Subject: [PATCH 12/26] Added wordpress InstallPlugin feature --- examples/Wordpress/install_plugin.php | 20 +++++++++ src/pmill/Plesk/Wordpress/InstallPlugin.php | 45 +++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/install_plugin.php create mode 100644 src/pmill/Plesk/Wordpress/InstallPlugin.php diff --git a/examples/Wordpress/install_plugin.php b/examples/Wordpress/install_plugin.php new file mode 100644 index 0000000..75f5568 --- /dev/null +++ b/examples/Wordpress/install_plugin.php @@ -0,0 +1,20 @@ + 1, + 'plugin_id' => 'wp-super-cache', +]; + +$request = new \pmill\Plesk\Wordpress\InstallPlugin($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/InstallPlugin.php b/src/pmill/Plesk/Wordpress/InstallPlugin.php new file mode 100644 index 0000000..1fec89f --- /dev/null +++ b/src/pmill/Plesk/Wordpress/InstallPlugin.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {PLUGIN_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'plugin_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'install-plugin'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'install-plugin'}->result); + } + + return true; + } +} From 80857f98dfcd91be0de4770b6093a18ddf681b89 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:40:30 +0000 Subject: [PATCH 13/26] Added wordpress UpdatePlugin feature --- examples/Wordpress/update_plugin.php | 20 ++++++++++ src/pmill/Plesk/Wordpress/UpdatePlugin.php | 45 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/update_plugin.php create mode 100644 src/pmill/Plesk/Wordpress/UpdatePlugin.php diff --git a/examples/Wordpress/update_plugin.php b/examples/Wordpress/update_plugin.php new file mode 100644 index 0000000..efa7a8a --- /dev/null +++ b/examples/Wordpress/update_plugin.php @@ -0,0 +1,20 @@ + 1, + 'plugin_id' => 'wp-super-cache_1.4.8', +]; + +$request = new \pmill\Plesk\Wordpress\UpdatePlugin($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/UpdatePlugin.php b/src/pmill/Plesk/Wordpress/UpdatePlugin.php new file mode 100644 index 0000000..0ef3a8e --- /dev/null +++ b/src/pmill/Plesk/Wordpress/UpdatePlugin.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {PLUGIN_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'plugin_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'update-plugin'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'update-plugin'}->result); + } + + return true; + } +} From 88b9541731b54be9cfb84aab6c36d6cbd9a4ad0a Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:41:33 +0000 Subject: [PATCH 14/26] Added wordpress ActivatePlugin feature --- examples/Wordpress/activate_plugin.php | 20 +++++++++ src/pmill/Plesk/Wordpress/ActivatePlugin.php | 45 ++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/activate_plugin.php create mode 100644 src/pmill/Plesk/Wordpress/ActivatePlugin.php diff --git a/examples/Wordpress/activate_plugin.php b/examples/Wordpress/activate_plugin.php new file mode 100644 index 0000000..27aa42a --- /dev/null +++ b/examples/Wordpress/activate_plugin.php @@ -0,0 +1,20 @@ + 1, + 'plugin_id' => 'wp-super-cache_1.4.8', +]; + +$request = new \pmill\Plesk\Wordpress\ActivatePlugin($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/ActivatePlugin.php b/src/pmill/Plesk/Wordpress/ActivatePlugin.php new file mode 100644 index 0000000..ed3d35b --- /dev/null +++ b/src/pmill/Plesk/Wordpress/ActivatePlugin.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {PLUGIN_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'plugin_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'activate-plugin'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'activate-plugin'}->result); + } + + return true; + } +} From 5e4ca7727e44c9b67a08a9696f5501a516a4a111 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:42:30 +0000 Subject: [PATCH 15/26] Added wordpress DeactivatePlugin feature --- examples/Wordpress/deactivate_plugin.php | 20 +++++++++ .../Plesk/Wordpress/DeactivatePlugin.php | 45 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/deactivate_plugin.php create mode 100644 src/pmill/Plesk/Wordpress/DeactivatePlugin.php diff --git a/examples/Wordpress/deactivate_plugin.php b/examples/Wordpress/deactivate_plugin.php new file mode 100644 index 0000000..f8c6aff --- /dev/null +++ b/examples/Wordpress/deactivate_plugin.php @@ -0,0 +1,20 @@ + 1, + 'plugin_id' => 'wp-super-cache_1.4.8', +]; + +$request = new \pmill\Plesk\Wordpress\DeactivatePlugin($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/DeactivatePlugin.php b/src/pmill/Plesk/Wordpress/DeactivatePlugin.php new file mode 100644 index 0000000..7b1d931 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/DeactivatePlugin.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {PLUGIN_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'plugin_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'deactivate-plugin'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'deactivate-plugin'}->result); + } + + return true; + } +} From 23c2421fa7ce195f9010dd8e0046d2977ba76816 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:44:12 +0000 Subject: [PATCH 16/26] Added wordpress UninstallPlugin feature --- examples/Wordpress/uninstall_plugin.php | 20 +++++++++ src/pmill/Plesk/Wordpress/UninstallPlugin.php | 45 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/uninstall_plugin.php create mode 100644 src/pmill/Plesk/Wordpress/UninstallPlugin.php diff --git a/examples/Wordpress/uninstall_plugin.php b/examples/Wordpress/uninstall_plugin.php new file mode 100644 index 0000000..9b793c6 --- /dev/null +++ b/examples/Wordpress/uninstall_plugin.php @@ -0,0 +1,20 @@ + 1, + 'plugin_id' => 'wp-super-cache_1.4.8', +]; + +$request = new \pmill\Plesk\Wordpress\UninstallPlugin($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/UninstallPlugin.php b/src/pmill/Plesk/Wordpress/UninstallPlugin.php new file mode 100644 index 0000000..e9faa5c --- /dev/null +++ b/src/pmill/Plesk/Wordpress/UninstallPlugin.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {PLUGIN_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'plugin_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'uninstall-plugin'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'uninstall-plugin'}->result); + } + + return true; + } +} From 623798f89732ae9d8db0af2d2d9c721648a8d26c Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:46:48 +0000 Subject: [PATCH 17/26] Added wordpress InstallTheme feature --- examples/Wordpress/install_theme.php | 20 ++++++++++ src/pmill/Plesk/Wordpress/InstallTheme.php | 45 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/install_theme.php create mode 100644 src/pmill/Plesk/Wordpress/InstallTheme.php diff --git a/examples/Wordpress/install_theme.php b/examples/Wordpress/install_theme.php new file mode 100644 index 0000000..5541068 --- /dev/null +++ b/examples/Wordpress/install_theme.php @@ -0,0 +1,20 @@ + 1, + 'theme_id' => 'emmet-lite', +]; + +$request = new \pmill\Plesk\Wordpress\InstallTheme($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/InstallTheme.php b/src/pmill/Plesk/Wordpress/InstallTheme.php new file mode 100644 index 0000000..ee879b1 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/InstallTheme.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {THEME_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'theme_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'install-theme'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'install-theme'}->result); + } + + return true; + } +} From d2174d2068c634da30dd3fed15254895dc84f0db Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:48:41 +0000 Subject: [PATCH 18/26] Added wordpress UpdateTheme feature --- examples/Wordpress/update_theme.php | 20 ++++++++++ src/pmill/Plesk/Wordpress/UpdateTheme.php | 45 +++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/update_theme.php create mode 100644 src/pmill/Plesk/Wordpress/UpdateTheme.php diff --git a/examples/Wordpress/update_theme.php b/examples/Wordpress/update_theme.php new file mode 100644 index 0000000..105f4f1 --- /dev/null +++ b/examples/Wordpress/update_theme.php @@ -0,0 +1,20 @@ + 1, + 'theme_id' => 'emmet-lite_1.4.0', +]; + +$request = new \pmill\Plesk\Wordpress\UpdateTheme($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/UpdateTheme.php b/src/pmill/Plesk/Wordpress/UpdateTheme.php new file mode 100644 index 0000000..00d0c34 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/UpdateTheme.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {THEME_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'theme_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'update-theme'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'update-theme'}->result); + } + + return true; + } +} From 987ebdb13f895e72ce8d7eaa5a6d13c8b94a1ceb Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:48:56 +0000 Subject: [PATCH 19/26] Added wordpress ActivateTheme feature --- examples/Wordpress/activate_theme.php | 20 +++++++++ src/pmill/Plesk/Wordpress/ActivateTheme.php | 45 +++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/activate_theme.php create mode 100644 src/pmill/Plesk/Wordpress/ActivateTheme.php diff --git a/examples/Wordpress/activate_theme.php b/examples/Wordpress/activate_theme.php new file mode 100644 index 0000000..e729e26 --- /dev/null +++ b/examples/Wordpress/activate_theme.php @@ -0,0 +1,20 @@ + 1, + 'theme_id' => 'emmet-lite_1.4.0', +]; + +$request = new \pmill\Plesk\Wordpress\ActivateTheme($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/ActivateTheme.php b/src/pmill/Plesk/Wordpress/ActivateTheme.php new file mode 100644 index 0000000..5da4b78 --- /dev/null +++ b/src/pmill/Plesk/Wordpress/ActivateTheme.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {THEME_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'theme_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'activate-theme'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'activate-theme'}->result); + } + + return true; + } +} From 190e5616c574fdd956c777f6ff9d0e3fe6c9ff68 Mon Sep 17 00:00:00 2001 From: pmill Date: Thu, 10 Mar 2016 20:52:14 +0000 Subject: [PATCH 20/26] Added wordpress UninstallTheme feature --- examples/Wordpress/uninstall_theme.php | 20 +++++++++ src/pmill/Plesk/Wordpress/UninstallTheme.php | 45 ++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 examples/Wordpress/uninstall_theme.php create mode 100644 src/pmill/Plesk/Wordpress/UninstallTheme.php diff --git a/examples/Wordpress/uninstall_theme.php b/examples/Wordpress/uninstall_theme.php new file mode 100644 index 0000000..419cfb7 --- /dev/null +++ b/examples/Wordpress/uninstall_theme.php @@ -0,0 +1,20 @@ + 1, + 'theme_id' => 'emmet-lite_1.4.0', +]; + +$request = new \pmill\Plesk\Wordpress\UninstallTheme($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Wordpress/UninstallTheme.php b/src/pmill/Plesk/Wordpress/UninstallTheme.php new file mode 100644 index 0000000..6e4929a --- /dev/null +++ b/src/pmill/Plesk/Wordpress/UninstallTheme.php @@ -0,0 +1,45 @@ + + + + + + {ID} + + {THEME_ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'theme_id' => null, + ]; + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'wp-instance'}->{'uninstall-theme'}->result->status === 'error') { + throw new ApiRequestException($xml->{'wp-instance'}->{'uninstall-theme'}->result); + } + + return true; + } +} From 6cc612e7750702cace19793e110a4b8e0ad5a71c Mon Sep 17 00:00:00 2001 From: Peter Millard Date: Fri, 11 Mar 2016 13:32:52 +0000 Subject: [PATCH 21/26] Added mail service UpdatePreferences functionality --- examples/MailService/update_preferences.php | 24 +++++++ src/pmill/Plesk/Helper/MailPreferences.php | 54 +++++++++++++++ .../Plesk/MailService/UpdatePreferences.php | 66 +++++++++++++++++++ src/pmill/Plesk/Node.php | 4 ++ 4 files changed, 148 insertions(+) create mode 100644 examples/MailService/update_preferences.php create mode 100644 src/pmill/Plesk/Helper/MailPreferences.php create mode 100644 src/pmill/Plesk/MailService/UpdatePreferences.php diff --git a/examples/MailService/update_preferences.php b/examples/MailService/update_preferences.php new file mode 100644 index 0000000..d6341dc --- /dev/null +++ b/examples/MailService/update_preferences.php @@ -0,0 +1,24 @@ + 1, + 'nonexistent-user' => \pmill\Plesk\Helper\MailPreferences::NONEXISTENT_USER_BOUNCE, + 'mailservice' => false, + 'webmail' => true, + 'spam-protect-sign' => true, + 'greylisting' => false, +]; + +$request = new \pmill\Plesk\MailService\UpdatePreferences($config, $params); + +$info = $request->process(); +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/Helper/MailPreferences.php b/src/pmill/Plesk/Helper/MailPreferences.php new file mode 100644 index 0000000..dc90d1f --- /dev/null +++ b/src/pmill/Plesk/Helper/MailPreferences.php @@ -0,0 +1,54 @@ + $value) { + if ($node = $this->createNode($key, $value)) { + $nodes[] = $node; + } + } + + return new NodeList($nodes); + } + + /** + * @param $key + * @param $value + * @return null|Node + */ + protected function createNode($key, $value) + { + switch ($key) { + case 'nonexistent-user': + if (in_array($value, [self::NONEXISTENT_USER_BOUNCE, self::NONEXISTENT_USER_FORWARD, self::NONEXISTENT_USER_REJECT])) { + return new Node($key, new Node($value)); + } + break; + case 'web_mail': + case 'spam_protect_sign': + case 'grey_listing': + case 'mailservice': + if (is_bool($value)) { + return new Node($key, $value); + } + break; + } + + return null; + } +} diff --git a/src/pmill/Plesk/MailService/UpdatePreferences.php b/src/pmill/Plesk/MailService/UpdatePreferences.php new file mode 100644 index 0000000..3645246 --- /dev/null +++ b/src/pmill/Plesk/MailService/UpdatePreferences.php @@ -0,0 +1,66 @@ + + + + + + {SITE-ID} + + + {PREFS} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'site-id' => null, + 'nonexistent-user' => null, + 'mailservice' => null, + ]; + + /** + * @param array $config + * @param array $params + * @param HttpRequestContract|null $http + */ + public function __construct(array $config, array $params = [], HttpRequestContract $http = null) + { + $helper = new MailPreferences(); + $params['prefs'] = $helper->generate($params); + + parent::__construct($config, $params, $http); + } + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'mail'}->{'set_prefs'}->result->status === 'error') { + throw new ApiRequestException($xml->{'mail'}->{'set_prefs'}->result); + } + + return true; + } +} diff --git a/src/pmill/Plesk/Node.php b/src/pmill/Plesk/Node.php index d7554d0..00099dd 100644 --- a/src/pmill/Plesk/Node.php +++ b/src/pmill/Plesk/Node.php @@ -71,6 +71,10 @@ public function __toString() $this->value = Xml::sanitize($this->value); } + if (is_bool($this->value)) { + $this->value = $this->value ? 'true' : 'false'; + } + return sprintf('<%s>%s', $this->tag, (string)$this->value, $this->tag); } } From 66046ceea1308e3354308904c4d969e73e53c7ac Mon Sep 17 00:00:00 2001 From: pmill Date: Sat, 12 Mar 2016 20:42:17 +0000 Subject: [PATCH 22/26] Added aps ListAvailablePackages feature --- examples/APS/list_available_packages.php | 12 ++++ src/pmill/Plesk/ListAvailablePackages.php | 86 +++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 examples/APS/list_available_packages.php create mode 100644 src/pmill/Plesk/ListAvailablePackages.php diff --git a/examples/APS/list_available_packages.php b/examples/APS/list_available_packages.php new file mode 100644 index 0000000..49038d8 --- /dev/null +++ b/examples/APS/list_available_packages.php @@ -0,0 +1,12 @@ +process(); + +var_dump($info); \ No newline at end of file diff --git a/src/pmill/Plesk/ListAvailablePackages.php b/src/pmill/Plesk/ListAvailablePackages.php new file mode 100644 index 0000000..b170883 --- /dev/null +++ b/src/pmill/Plesk/ListAvailablePackages.php @@ -0,0 +1,86 @@ + + + + + {FILTER} + + + +EOT; + + /** + * @param array $config + * @param array $params + * @param HttpRequestContract $http + * @throws ApiRequestException + */ + public function __construct(array $config, array $params = [], HttpRequestContract $http = null) + { + $filterNode = new Node('filter'); + + if (isset($params['package-id'])) { + if (!is_array($params['package-id'])) { + $params['package-id'] = [$params['package-id']]; + } + + $idNodes = []; + foreach ($params['package-id'] as $id) { + $idNodes[] = new Node('package-id', $id); + } + + $filterNode->setValue(new Node('package-id', new NodeList($idNodes))); + } + + $params['filter'] = $filterNode; + + parent::__construct($config, $params, $http); + } + + /** + * @param SimpleXMLElement $xml + * @return array + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + $response = []; + + foreach ($xml->{'aps'}->{'get-packages-list'}->result as $result) { + if ((string) $result->status == "error") { + $response[] = [ + 'status' => (string) $result->status, + 'filter-id' => (int) $result->{'filter-id'}, + 'errcode' => (string) $result->errcode, + 'errtext' => (string) $result->errtext, + ]; + } else { + $response[] = [ + 'status' => (string) $result->status, + 'id' => (int) $result->package->id, + 'filter-id' => (int) $result->{'filter-id'}, + 'title' => (string) $result->package->title, + 'version' => (string) $result->package->version, + 'release' => (string) $result->package->release, + 'vendor' => (string) $result->package->vendor, + 'packager' => (string) $result->package->packager, + 'is_uploaded' => (int) $result->package->is_uploaded === 1, + 'is_visible' => (int) $result->package->is_visible === 1, + 'global_settings_not_set' => (int) $result->package->global_settings_not_set === 1, + ]; + } + } + + return $response; + } +} From 25cbd9d4aa868a784b9a50cd0c196d0b0ac49136 Mon Sep 17 00:00:00 2001 From: Peter Millard Date: Mon, 14 Mar 2016 13:49:42 +0000 Subject: [PATCH 23/26] Moved ListAvailablePackages to APS directory --- examples/APS/list_available_packages.php | 2 +- src/pmill/Plesk/{ => APS}/ListAvailablePackages.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) rename src/pmill/Plesk/{ => APS}/ListAvailablePackages.php (93%) diff --git a/examples/APS/list_available_packages.php b/examples/APS/list_available_packages.php index 49038d8..8376f5b 100644 --- a/examples/APS/list_available_packages.php +++ b/examples/APS/list_available_packages.php @@ -6,7 +6,7 @@ ]; -$request = new \pmill\Plesk\ListAvailablePackages($config, $params); +$request = new \pmill\Plesk\APS\ListAvailablePackages($config, $params); $info = $request->process(); var_dump($info); \ No newline at end of file diff --git a/src/pmill/Plesk/ListAvailablePackages.php b/src/pmill/Plesk/APS/ListAvailablePackages.php similarity index 93% rename from src/pmill/Plesk/ListAvailablePackages.php rename to src/pmill/Plesk/APS/ListAvailablePackages.php index b170883..781debb 100644 --- a/src/pmill/Plesk/ListAvailablePackages.php +++ b/src/pmill/Plesk/APS/ListAvailablePackages.php @@ -1,6 +1,11 @@ Date: Mon, 14 Mar 2016 14:12:01 +0000 Subject: [PATCH 24/26] Added aps InstallApplication functionality --- examples/APS/install_application.php | 17 +++ src/pmill/Plesk/APS/InstallApplication.php | 135 +++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 examples/APS/install_application.php create mode 100644 src/pmill/Plesk/APS/InstallApplication.php diff --git a/examples/APS/install_application.php b/examples/APS/install_application.php new file mode 100644 index 0000000..2299d0b --- /dev/null +++ b/examples/APS/install_application.php @@ -0,0 +1,17 @@ + 'example.org', + 'package-id' => 1, +]; + +$request = new \pmill\Plesk\APS\InstallApplication($config, $params); +$info = $request->process(); + +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/APS/InstallApplication.php b/src/pmill/Plesk/APS/InstallApplication.php new file mode 100644 index 0000000..2eafe12 --- /dev/null +++ b/src/pmill/Plesk/APS/InstallApplication.php @@ -0,0 +1,135 @@ + + + + + {OPTIONS} + {PACKAGE-ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'package-id' => null, + ]; + + /** + * @param array $config + * @param array $params + * @param HttpRequestContract|null $http + */ + public function __construct(array $config, array $params = [], HttpRequestContract $http = null) + { + $optionsNodes = []; + $optionsNodes[] = $this->getIdentifierNode($params); + + if ($databaseNode = $this->getDatabaseNode($params)) { + $optionsNodes[] = $databaseNode; + } + + if ($settingsNode = $this->getSettingsNode($params)) { + $optionsNodes[] = $settingsNode ; + } + + if (isset($params['ssl'])) { + $optionsNodes[] = new Node('ssl', $params['ssl']); + } + + if (isset($params['url-prefix'])) { + $optionsNodes[] = new Node('url-prefix', $params['url-prefix']); + } + + $params['options'] = new NodeList($optionsNodes); + + parent::__construct($config, $params, $http); + } + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'aps'}->{'install'}->result->status === 'error') { + throw new ApiRequestException($xml->{'aps'}->{'install'}->result); + } + + return true; + } + + /** + * @param array $params + * @return null|Node + */ + protected function getIdentifierNode(array $params) + { + foreach (['domain-id', 'domain-name', 'subdomain-id', 'subdomain-name'] as $key) { + if (isset($params[$key])) { + return new Node($key, $params[$key]); + } + } + + return null; + } + + /** + * @param array $params + * @return null|Node + */ + protected function getDatabaseNode(array $params) + { + if (isset($params['database']) && is_array($params['database'])) { + $nodes = []; + + foreach (['name', 'login', 'password', 'prefix', 'server'] as $key) { + if (isset($params['database'][$key])) { + $nodes[] = new Node($key, $params['database'][$key]); + } + } + + return new Node('database', $nodes); + } + + return null; + } + + /** + * @param array $params + * @return null|Node + */ + protected function getSettingsNode(array $params) + { + if (isset($params['settings']) && is_array($params['settings'])) { + $nodes = []; + + foreach ($params['settings'] as $key => $value) { + $nodes[] = new Node($key, $value); + } + + return new Node('settings', $nodes); + } + + return null; + } +} From 793c8d679f294386a9a7731770c4030349c15f19 Mon Sep 17 00:00:00 2001 From: pmill Date: Mon, 14 Mar 2016 20:43:34 +0000 Subject: [PATCH 25/26] Added ssl InstallCertificate feature --- examples/SSL/install_certificate.php | 21 +++++ src/pmill/Plesk/SSL/InstallCertificate.php | 94 ++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 examples/SSL/install_certificate.php create mode 100644 src/pmill/Plesk/SSL/InstallCertificate.php diff --git a/examples/SSL/install_certificate.php b/examples/SSL/install_certificate.php new file mode 100644 index 0000000..dc4ae18 --- /dev/null +++ b/examples/SSL/install_certificate.php @@ -0,0 +1,21 @@ + 'test-ssl', + 'admin' => true, + 'csr' => '', + 'cert' => '', + 'pvt' => '', + 'ip-address' => '127.0.0.1', +]; + +$request = new \pmill\Plesk\SSL\InstallCertificate($config, $params); +$info = $request->process(); + +var_dump($info); + +if ($info === false) { + var_dump($request->error->getMessage()); +} diff --git a/src/pmill/Plesk/SSL/InstallCertificate.php b/src/pmill/Plesk/SSL/InstallCertificate.php new file mode 100644 index 0000000..d0999ed --- /dev/null +++ b/src/pmill/Plesk/SSL/InstallCertificate.php @@ -0,0 +1,94 @@ + + + + + {NAME} + {DESTINATION} + + {CSR} + {PVT} + {CRT} + {CA} + + {IP-ADDRESS} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'name' => null, + 'csr' => null, + 'pvt' => null, + 'ip-address' => null, + ]; + + /** + * @param array $config + * @param array $params + * @param HttpRequestContract $http + * @throws ApiRequestException + */ + public function __construct(array $config, array $params = [], HttpRequestContract $http = null) + { + if (isset($params['admin']) && $params['admin'] === true) { + $params['destination'] = new Node('admin'); + } + + if (isset($params['webspace'])) { + $params['destination'] = new Node('webspace', $params['webspace']); + } + + if (!isset($params['destination'])) { + throw new ApiRequestException('admin or webspace parameter is required'); + } + + if (isset($params['crt'])) { + $params['crt'] = new Node('crt', $params['crt']); + } else { + $params['crt'] = ''; + } + + if (isset($params['ca'])) { + $params['ca'] = new Node('ca', $params['ca']); + } else { + $params['ca'] = ''; + } + + parent::__construct($config, $params, $http); + } + + /** + * @param SimpleXMLElement $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ((string) $xml->{'certificate'}->{'install'}->result->status === 'error') { + throw new ApiRequestException($xml->{'certificate'}->{'install'}->result); + } + + return true; + } +} From 9fa0930763405b5d705b067d4f596fc6956f30b5 Mon Sep 17 00:00:00 2001 From: pmill Date: Tue, 5 Apr 2016 11:08:33 +0100 Subject: [PATCH 26/26] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 3fbd1ab..6370053 100755 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ The following features are currently supported: * List database servers * List/add/delete databases * Add database users +* Further functionality can be seen in the examples folder * Email dev.pmill@gmail.com with requests for exposing further functionality Requirements @@ -82,6 +83,13 @@ Unversioned (13 Apr 2013) * Updated error handling to expose Plesk error code * Added html entity escaping +0.5.1 (05/04/2016) + +* Added mail preferences functionality +* Added wordpress functionality +* Added APS functionality +* Added ssl certificate functionality + Copyright and License ---------------------