Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Also increment SOA serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jul 22, 2021
1 parent 25ec9d9 commit ba20ea5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dns/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
if ($dns_file === $replaced_file) {
die("Updated, nothing changed\n");
}
if (file_put_contents($_SERVER['DNS_PATH'], $replaced_file, LOCK_EX) === false) {
preg_match('/(IN\tSOA.+?)(\d+)/s', $replaced_file, $matches);
$replaced_file = preg_replace('/(IN\tSOA.+?)(\d+)/s', '$1'.(intval($matches[2]) + 1), $replaced_file, 1);
if (!$replaced_file || file_put_contents($_SERVER['DNS_PATH'], $replaced_file, LOCK_EX) === false) {
die("ERROR: unable to write config\n");
}
exec($_SERVER['DNS_RELOAD']);
echo "Updated for A Record\n";
echo "Updated for $record Record\n";
} else if ($_GET['action'] === 'del') {
$dns_file = file_get_contents($_SERVER['DNS_PATH']);
if (!$dns_file) {
Expand All @@ -50,9 +52,11 @@
if ($dns_file === $replaced_file) {
die("Updated, Nothing changed\n");
}
if (file_put_contents($_SERVER['DNS_PATH'], $replaced_file, LOCK_EX) === false) {
preg_match('/(IN\tSOA.+?)(\d+)/s', $replaced_file, $matches);
$replaced_file = preg_replace('/(IN\tSOA.+?)(\d+)/s', '$1'.(intval($matches[2]) + 1), $replaced_file, 1);
if (!$replaced_file || file_put_contents($_SERVER['DNS_PATH'], $replaced_file, LOCK_EX) === false) {
die("ERROR: unable to write config\n");
}
exec($_SERVER['DNS_RELOAD']);
echo "Updated for A Record\n";
echo "Updated for $record Record\n";
}

0 comments on commit ba20ea5

Please sign in to comment.