From a94d0e0b314370f4cd9842476242fccd15c505b2 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Wed, 3 Aug 2016 14:08:33 +0200 Subject: [PATCH] Fix all kind of development and trying code. --- includes/class/ApiHandler.php | 12 ++++++------ includes/class/PdnsApi.php | 4 ++-- includes/class/Zone.php | 27 ++++++++++++++++----------- zones.php | 13 ++++++++----- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/includes/class/ApiHandler.php b/includes/class/ApiHandler.php index 80b5a9a..15efef8 100644 --- a/includes/class/ApiHandler.php +++ b/includes/class/ApiHandler.php @@ -1,6 +1,6 @@ curlh, CURLOPT_URL, $this->baseurl().$this->url); - print "Here we go:\n"; - print "Request: ".$this->method.' '.$this->baseurl().$this->url."\n"; - if ($this->content != '') { - print "Content: ".$this->content."\n"; - } + //print "Here we go:\n"; + //print "Request: ".$this->method.' '.$this->baseurl().$this->url."\n"; + //if ($this->content != '') { + // print "Content: ".$this->content."\n"; + //} $return = curl_exec($this->curlh); $code = curl_getinfo($this->curlh, CURLINFO_HTTP_CODE); diff --git a/includes/class/PdnsApi.php b/includes/class/PdnsApi.php index 1dc7a44..5fe11a0 100644 --- a/includes/class/PdnsApi.php +++ b/includes/class/PdnsApi.php @@ -1,6 +1,6 @@ http; $api->method = 'GET'; - $api->url = "/servers/localhost/zones/$zoneid/cryptokeys" + $api->url = "/servers/localhost/zones/$zoneid/cryptokeys"; $api->call(); diff --git a/includes/class/Zone.php b/includes/class/Zone.php index 0791902..9dfb0d8 100644 --- a/includes/class/Zone.php +++ b/includes/class/Zone.php @@ -25,23 +25,28 @@ class Zone { $this->setaccount($data['account']); $this->setserial($data['serial']); $this->url = $data['url']; - $this->setsoaedit($data['soa_edit']); - $this->setsoaeditapi($data['soa_edit_api']); + if (isset($data['soa_edit'])) + $this->setsoaedit($data['soa_edit']); + if (isset($data['soa_edit_api'])) + $this->setsoaeditapi($data['soa_edit_api']); foreach ($data['masters'] as $master) { $this->addmaster($master); } - foreach ($data['rrsets'] as $rrset) { - $toadd = new RRSet($rrset['name'], $rrset['type']); - foreach ($rrset['comments'] as $comment) { - $toadd->addComment($comment['content'], $comment['account'], $comment['modified_at']); + if (isset($data['rrsets'])) { + foreach ($data['rrsets'] as $rrset) { + $toadd = new RRSet($rrset['name'], $rrset['type']); + foreach ($rrset['comments'] as $comment) { + $toadd->addComment($comment['content'], $comment['account'], $comment['modified_at']); + } + foreach ($rrset['records'] as $record) { + $toadd->addRecord($record['content'], $record['disabled']); + } + $toadd->setttl($rrset['ttl']); + array_push($this->rrsets, $toadd); } - foreach ($rrset['records'] as $record) { - $toadd->addRecord($record['content'], $record['disabled']); - } - $toadd->setttl($rrset['ttl']); - array_push($this->rrsets, $toadd); } + } } public function setkeyinfo($info) { diff --git a/zones.php b/zones.php index e98922c..3b23639 100644 --- a/zones.php +++ b/zones.php @@ -3,8 +3,8 @@ include_once('includes/config.inc.php'); include_once('includes/session.inc.php'); include_once('includes/misc.inc.php'); -include_once('include/class/PdnsAPI.php'); -include_once('include/class/Zone.php'); +include_once('includes/class/PdnsApi.php'); +include_once('includes/class/Zone.php'); if (!is_csrf_safe()) { header('Status: 403'); @@ -283,15 +283,18 @@ switch ($action) { case "list": case "listslaves": + $return = Array(); $q = isset($_POST['domsearch']) ? $_POST['domsearch'] : false; - foreach ($api->listzones($q) as $zone) { - $zone->setaccount(get_zone_owner($zone['name'], 'admin')); + foreach ($api->listzones($q) as $sresult) { + $zone = new Zone(); + $zone->parse($sresult); + $zone->setaccount(get_zone_owner($zone->name, 'admin')); if (!check_owner($zone)) continue; if ($action == "listslaves" and $zone->kind == "Slave") { - array_push($return, $zone); + array_push($return, $zone->export()); } elseif ($action == "list" and $zone->kind != "Slave") { if ($zone->dnssec) { $zone->setkeyinfo($api->getzonekeys($zone->id));