mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
Implement set-ptr. Closes #51 . Make 'true/false' prettier
This commit is contained in:
parent
5cd225cb43
commit
d103c7b04f
3 changed files with 42 additions and 16 deletions
|
@ -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;
|
||||
}
|
||||
|
|
27
index.php
27
index.php
|
@ -252,7 +252,11 @@ function displayContent(fieldName, zone) {
|
|||
var zspan = $('<span class="lightgrey">').text(zone);
|
||||
return lspan.add(zspan);
|
||||
} else {
|
||||
return $('<span>').text(data.record[fieldName]);
|
||||
var text = data.record[fieldName];
|
||||
if (typeof data.record[fieldName] == 'boolean') {
|
||||
text == false ? text = 'No' : text = 'Yes';
|
||||
}
|
||||
return $('<span>').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: '<?php echo $defaults['disabled'] ? 'false' : 'true'; ?>',
|
||||
defaultValue: '<?php echo $defaults['disabled'] ? 'No' : 'Yes'; ?>',
|
||||
inputClass: 'disabled',
|
||||
listClass: 'disabled',
|
||||
options: function() {
|
||||
return {
|
||||
'0': 'false',
|
||||
'1': 'true',
|
||||
'0': 'No',
|
||||
'1': 'Yes',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue