Fixed from paulgiordanozethcon suggestion in https://github.com/tuxis-ie/nsedit/issues/162

This commit is contained in:
margau 2018-04-17 18:53:31 +02:00
parent ebd12ebeb2
commit 805176648d
2 changed files with 11 additions and 10 deletions

View file

@ -29,11 +29,12 @@ class ApiHandler {
private function apiurl() { private function apiurl() {
$tmp = new ApiHandler(); $tmp = new ApiHandler();
$tmp->url = '/api'; $tmp->url = '/api/v1/servers/localhost';
$tmp->go(); $tmp->go();
if ($tmp->json[0]['version'] <= 1) { $v = intval(substr($tmp->json["version"],0,1));
$this->apiurl = $tmp->json[0]['url']; if ($v == 4) {
$this->apiurl = $tmp->json["url"];
} else { } else {
throw new Exception("Unsupported API version"); throw new Exception("Unsupported API version");
} }

View file

@ -11,7 +11,7 @@ class PdnsAPI {
$api = clone $this->http; $api = clone $this->http;
$api->method = 'GET'; $api->method = 'GET';
if ($q) { if ($q) {
$api->url = "/servers/localhost/search-data?q=*".$q."*&max=25"; $api->url = "/search-data?q=*".$q."*&max=25";
$api->call(); $api->call();
$ret = Array(); $ret = Array();
$seen = Array(); $seen = Array();
@ -28,7 +28,7 @@ class PdnsAPI {
return $ret; return $ret;
} }
$api->url = "/servers/localhost/zones"; $api->url = "/zones";
$api->call(); $api->call();
return $api->json; return $api->json;
@ -37,7 +37,7 @@ class PdnsAPI {
public function loadzone($zoneid) { public function loadzone($zoneid) {
$api = clone $this->http; $api = clone $this->http;
$api->method = 'GET'; $api->method = 'GET';
$api->url = "/servers/localhost/zones/$zoneid"; $api->url = "/zones/$zoneid";
$api->call(); $api->call();
return $api->json; return $api->json;
@ -46,7 +46,7 @@ class PdnsAPI {
public function exportzone($zoneid) { public function exportzone($zoneid) {
$api = clone $this->http; $api = clone $this->http;
$api->method = 'GET'; $api->method = 'GET';
$api->url = "/servers/localhost/zones/$zoneid/export"; $api->url = "/zones/$zoneid/export";
$api->call(); $api->call();
return $api->json; return $api->json;
@ -64,7 +64,7 @@ class PdnsAPI {
if (!isset($zone['serial']) or gettype($zone['serial']) != 'integer') { if (!isset($zone['serial']) or gettype($zone['serial']) != 'integer') {
$api->method = 'POST'; $api->method = 'POST';
$api->url = '/servers/localhost/zones'; $api->url = '/localhost/zones';
$api->content = json_encode($zonedata); $api->content = json_encode($zonedata);
$api->call(); $api->call();
@ -88,7 +88,7 @@ class PdnsAPI {
public function deletezone($zoneid) { public function deletezone($zoneid) {
$api = clone $this->http; $api = clone $this->http;
$api->method = 'DELETE'; $api->method = 'DELETE';
$api->url = "/servers/localhost/zones/$zoneid"; $api->url = "/zones/$zoneid";
$api->call(); $api->call();
return $api->json; return $api->json;
@ -98,7 +98,7 @@ class PdnsAPI {
$ret = array(); $ret = array();
$api = clone $this->http; $api = clone $this->http;
$api->method = 'GET'; $api->method = 'GET';
$api->url = "/servers/localhost/zones/$zoneid/cryptokeys"; $api->url = "/zones/$zoneid/cryptokeys";
$api->call(); $api->call();