mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
add "notifyafterupdate" flag
This commit is contained in:
parent
1dfd47ae70
commit
03d9d88026
3 changed files with 20 additions and 2 deletions
|
@ -84,6 +84,14 @@ class PdnsAPI {
|
||||||
|
|
||||||
return $this->loadzone($zone['id']);
|
return $this->loadzone($zone['id']);
|
||||||
}
|
}
|
||||||
|
public function notifyzone($zoneid) {
|
||||||
|
$api = clone $this->http;
|
||||||
|
$api->method = 'PUT';
|
||||||
|
$api->url = "/servers/localhost/zones/$zoneid/notify";
|
||||||
|
$api->call();
|
||||||
|
|
||||||
|
return $api->json;
|
||||||
|
}
|
||||||
|
|
||||||
public function deletezone($zoneid) {
|
public function deletezone($zoneid) {
|
||||||
$api = clone $this->http;
|
$api = clone $this->http;
|
||||||
|
|
|
@ -8,7 +8,8 @@ $apisslverify = FALSE; # Verify SSL Certificate if using https for apiproto
|
||||||
$allowzoneadd = FALSE; # Allow normal users to add zones
|
$allowzoneadd = FALSE; # Allow normal users to add zones
|
||||||
$logging = TRUE;
|
$logging = TRUE;
|
||||||
$allowclearlogs = TRUE; # Allow clearing of log entries
|
$allowclearlogs = TRUE; # Allow clearing of log entries
|
||||||
$allowrotatelogs = FALSE;# Allow rotation to text file on server
|
$allowrotatelogs = FALSE;# Allow rotation to text file on serveri
|
||||||
|
$notifyafterupdate = TRUE;# send notify to slaves after zone update
|
||||||
|
|
||||||
# Log directory - if allowrotatelogs is set, this is where the logs will
|
# Log directory - if allowrotatelogs is set, this is where the logs will
|
||||||
# be written. It must be writeable by the web server user.
|
# be written. It must be writeable by the web server user.
|
||||||
|
|
11
zones.php
11
zones.php
|
@ -304,6 +304,7 @@ case "create":
|
||||||
}
|
}
|
||||||
|
|
||||||
$api->savezone($zone->export());
|
$api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
$zone = new Zone();
|
$zone = new Zone();
|
||||||
$zone->parse($api->loadzone($zonename));
|
$zone->parse($api->loadzone($zonename));
|
||||||
|
@ -327,7 +328,8 @@ case "create":
|
||||||
$rrset->delete();
|
$rrset->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$api->savezone($zone->export());
|
$api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
foreach ($template['records'] as $record) {
|
foreach ($template['records'] as $record) {
|
||||||
$name = $record['name'] != '' ? join(Array($record['name'],'.',$zonename)) : $zonename;
|
$name = $record['name'] != '' ? join(Array($record['name'],'.',$zonename)) : $zonename;
|
||||||
|
@ -340,6 +342,7 @@ case "create":
|
||||||
}
|
}
|
||||||
|
|
||||||
$zone = $api->savezone($zone->export());
|
$zone = $api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
writelog("Created zone ".$zone['name']);
|
writelog("Created zone ".$zone['name']);
|
||||||
jtable_respond($zone, 'single');
|
jtable_respond($zone, 'single');
|
||||||
break;
|
break;
|
||||||
|
@ -370,6 +373,7 @@ case "update":
|
||||||
|
|
||||||
writelog("Updated zone ".$zone->name);
|
writelog("Updated zone ".$zone->name);
|
||||||
jtable_respond($api->savezone($zone->export()), 'single');
|
jtable_respond($api->savezone($zone->export()), 'single');
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "createrecord":
|
case "createrecord":
|
||||||
|
@ -411,6 +415,7 @@ case "createrecord":
|
||||||
|
|
||||||
$record = $zone->addRecord($name, $type, $content, $_POST['disabled'], $_POST['ttl'], $_POST['setptr']);
|
$record = $zone->addRecord($name, $type, $content, $_POST['disabled'], $_POST['ttl'], $_POST['setptr']);
|
||||||
$api->savezone($zone->export());
|
$api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
writelog("Created record: ".$record['id']);
|
writelog("Created record: ".$record['id']);
|
||||||
jtable_respond($record, 'single');
|
jtable_respond($record, 'single');
|
||||||
|
@ -436,6 +441,7 @@ case "editrecord":
|
||||||
$zone->addRecord($_POST['name'], $_POST['type'], $content, $_POST['disabled'], $_POST['ttl'], $_POST['setptr']);
|
$zone->addRecord($_POST['name'], $_POST['type'], $content, $_POST['disabled'], $_POST['ttl'], $_POST['setptr']);
|
||||||
|
|
||||||
$api->savezone($zone->export());
|
$api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
$record = $zone->getRecord($_POST['name'], $_POST['type'], $content);
|
$record = $zone->getRecord($_POST['name'], $_POST['type'], $content);
|
||||||
writelog("Updated record ".$_POST['id']." to ".$record['id']);
|
writelog("Updated record ".$_POST['id']." to ".$record['id']);
|
||||||
|
@ -453,6 +459,7 @@ case "deleterecord":
|
||||||
$rrset->deleteRecord($old_record['content']);
|
$rrset->deleteRecord($old_record['content']);
|
||||||
|
|
||||||
$api->savezone($zone->export());
|
$api->savezone($zone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
writelog("Deleted record ".$_POST['id']);
|
writelog("Deleted record ".$_POST['id']);
|
||||||
jtable_respond(null, 'delete');
|
jtable_respond(null, 'delete');
|
||||||
|
@ -486,6 +493,7 @@ case "clone":
|
||||||
$srczone->setKind($_POST['kind']);
|
$srczone->setKind($_POST['kind']);
|
||||||
|
|
||||||
$zone = $api->savezone($srczone->export());
|
$zone = $api->savezone($srczone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
$srczone->parse($zone);
|
$srczone->parse($zone);
|
||||||
|
|
||||||
|
@ -504,6 +512,7 @@ case "clone":
|
||||||
}
|
}
|
||||||
|
|
||||||
$zone = $api->savezone($srczone->export());
|
$zone = $api->savezone($srczone->export());
|
||||||
|
$api->notifyzone($_GET['zoneid']) if $notifyafterupdate;
|
||||||
|
|
||||||
writelog("Cloned zone $src into $name");
|
writelog("Cloned zone $src into $name");
|
||||||
jtable_respond($zone, 'single');
|
jtable_respond($zone, 'single');
|
||||||
|
|
Loading…
Add table
Reference in a new issue