From 805176648d54df2b75cd8100928da7c8ddd22270 Mon Sep 17 00:00:00 2001 From: margau Date: Tue, 17 Apr 2018 18:53:31 +0200 Subject: [PATCH] Fixed from paulgiordanozethcon suggestion in https://github.com/tuxis-ie/nsedit/issues/162 --- includes/class/ApiHandler.php | 7 ++++--- includes/class/PdnsApi.php | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/class/ApiHandler.php b/includes/class/ApiHandler.php index 07b6cdf..cda5c66 100644 --- a/includes/class/ApiHandler.php +++ b/includes/class/ApiHandler.php @@ -29,11 +29,12 @@ class ApiHandler { private function apiurl() { $tmp = new ApiHandler(); - $tmp->url = '/api'; + $tmp->url = '/api/v1/servers/localhost'; $tmp->go(); - if ($tmp->json[0]['version'] <= 1) { - $this->apiurl = $tmp->json[0]['url']; + $v = intval(substr($tmp->json["version"],0,1)); + if ($v == 4) { + $this->apiurl = $tmp->json["url"]; } else { throw new Exception("Unsupported API version"); } diff --git a/includes/class/PdnsApi.php b/includes/class/PdnsApi.php index 25a1581..6acaa10 100644 --- a/includes/class/PdnsApi.php +++ b/includes/class/PdnsApi.php @@ -11,7 +11,7 @@ class PdnsAPI { $api = clone $this->http; $api->method = 'GET'; if ($q) { - $api->url = "/servers/localhost/search-data?q=*".$q."*&max=25"; + $api->url = "/search-data?q=*".$q."*&max=25"; $api->call(); $ret = Array(); $seen = Array(); @@ -28,7 +28,7 @@ class PdnsAPI { return $ret; } - $api->url = "/servers/localhost/zones"; + $api->url = "/zones"; $api->call(); return $api->json; @@ -37,7 +37,7 @@ class PdnsAPI { public function loadzone($zoneid) { $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid"; + $api->url = "/zones/$zoneid"; $api->call(); return $api->json; @@ -46,7 +46,7 @@ class PdnsAPI { public function exportzone($zoneid) { $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid/export"; + $api->url = "/zones/$zoneid/export"; $api->call(); return $api->json; @@ -64,7 +64,7 @@ class PdnsAPI { if (!isset($zone['serial']) or gettype($zone['serial']) != 'integer') { $api->method = 'POST'; - $api->url = '/servers/localhost/zones'; + $api->url = '/localhost/zones'; $api->content = json_encode($zonedata); $api->call(); @@ -88,7 +88,7 @@ class PdnsAPI { public function deletezone($zoneid) { $api = clone $this->http; $api->method = 'DELETE'; - $api->url = "/servers/localhost/zones/$zoneid"; + $api->url = "/zones/$zoneid"; $api->call(); return $api->json; @@ -98,7 +98,7 @@ class PdnsAPI { $ret = array(); $api = clone $this->http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid/cryptokeys"; + $api->url = "/zones/$zoneid/cryptokeys"; $api->call();