diff --git a/includes/class/Zone.php b/includes/class/Zone.php index 4ddf359..a9bfd9a 100644 --- a/includes/class/Zone.php +++ b/includes/class/Zone.php @@ -112,21 +112,21 @@ class Zone { $this->masters = Array(); } - public function addRRSet($name, $type, $content, $disabled = FALSE, $ttl = 3600) { + public function addRRSet($name, $type, $content, $disabled = FALSE, $ttl = 3600, $setptr = FALSE) { if ($this->getRRSet($name, $type) !== FALSE) { throw new Exception("This rrset already exists."); } - $rrset = new RRSet($name, $type, $content, $disabled, $ttl); + $rrset = new RRSet($name, $type, $content, $disabled, $ttl, $setptr); array_push($this->rrsets, $rrset); } - public function addRecord($name, $type, $content, $disabled = FALSE, $ttl = 3600) { + public function addRecord($name, $type, $content, $disabled = FALSE, $ttl = 3600, $setptr = FALSE) { $rrset = $this->getRRSet($name, $type); if ($rrset) { - $rrset->addRecord($content, $disabled); + $rrset->addRecord($content, $disabled, $setptr); } else { - $this->addRRSet($name, $type, $content, $disabled, $ttl); + $this->addRRSet($name, $type, $content, $disabled, $ttl, $setptr); } return $this->getRecord($name, $type, $content); @@ -211,7 +211,7 @@ class Zone { } class RRSet { - public function __construct($name = '', $type = '', $content = '', $disabled = FALSE, $ttl = 3600) { + public function __construct($name = '', $type = '', $content = '', $disabled = FALSE, $ttl = 3600, $setptr = FALSE) { $this->name = $name; $this->type = $type; $this->ttl = $ttl; @@ -220,7 +220,7 @@ class RRSet { $this->comments = Array(); if (isset($content) and $content != '') { - $this->addRecord($content, $disabled); + $this->addRecord($content, $disabled, $setptr); } } @@ -236,14 +236,14 @@ class RRSet { $this->name = $name; } - public function addRecord($content, $disabled = FALSE) { + public function addRecord($content, $disabled = FALSE, $setptr) { foreach ($this->records as $record) { if ($record->content == $content) { throw Exception("Record already exists"); } } - $record = new Record($content, $disabled); + $record = new Record($content, $disabled, $setptr); array_push($this->records, $record); } @@ -275,6 +275,9 @@ class RRSet { public function exportRecords() { $ret = Array(); foreach ($this->records as $record) { + if ($this->type != "A" and $this->type != "AAAA") { + $record->setptr = FALSE; + } array_push($ret, $record->export()); } @@ -293,9 +296,10 @@ class RRSet { } class Record { - public function __construct($content, $disabled = FALSE) { + public function __construct($content, $disabled = FALSE, $setptr = FALSE) { $this->content = $content; $this->disabled = $disabled; + $this->setptr = $setptr; } public function export() { @@ -303,6 +307,9 @@ class Record { $ret['content'] = $this->content; $ret['disabled'] = ( bool ) $this->disabled; + if ($this->setptr) { + $ret['set-ptr'] = ( bool ) TRUE; + } return $ret; } diff --git a/index.php b/index.php index ddb1b9b..b17dd82 100644 --- a/index.php +++ b/index.php @@ -252,7 +252,11 @@ function displayContent(fieldName, zone) { var zspan = $('').text(zone); return lspan.add(zspan); } else { - return $('').text(data.record[fieldName]); + var text = data.record[fieldName]; + if (typeof data.record[fieldName] == 'boolean') { + text == false ? text = 'No' : text = 'Yes'; + } + return $('').text(text); } } } @@ -657,18 +661,33 @@ $(document).ready(function () { inputClass: 'ttl', listClass: 'ttl' }, + setptr: { + title: 'Set PTR Record', + width: '2%', + list: false, + create: true, + defaultValue: 'false', + inputClass: 'setptr', + listClass: 'setptr', + options: function() { + return { + '0': 'No', + '1': 'Yes', + }; + }, + }, disabled: { title: 'Disabled', width: '2%', create: true, display: displayContent('disabled'), - defaultValue: '', + defaultValue: '', inputClass: 'disabled', listClass: 'disabled', options: function() { return { - '0': 'false', - '1': 'true', + '0': 'No', + '1': 'Yes', }; }, }, diff --git a/zones.php b/zones.php index 2e9afc9..753f1cb 100644 --- a/zones.php +++ b/zones.php @@ -324,7 +324,7 @@ case "createrecord": jtable_respond(null, 'error', "Please only use ASCII-characters in your fields"); } - $record = $zone->addRecord($name, $type, $content, $_POST['disabled'], $_POST['ttl']); + $record = $zone->addRecord($name, $type, $content, $_POST['disabled'], $_POST['ttl'], $_POST['setptr']); $api->savezone($zone->export()); jtable_respond($record, 'single'); @@ -338,7 +338,7 @@ case "editrecord": $rrset = $zone->getRRSet($old_record['name'], $old_record['type']); $rrset->deleteRecord($old_record['content']); - $zone->addRecord($_POST['name'], $_POST['type'], $_POST['content'], $_POST['disabled'], $_POST['ttl']); + $zone->addRecord($_POST['name'], $_POST['type'], $_POST['content'], $_POST['disabled'], $_POST['ttl'], $_POST['setptr']); $api->savezone($zone->export());