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

Commit

Permalink
Add retransfer option
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jul 22, 2021
1 parent 2eb4649 commit 3b8f5b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dns/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
$theword = "$_GET[host].domcloud.io.\tIN\t$record\t$_GET[value]\n";
echo str_contains($dns_file, $theword) ? '1' : '0';
die();
} else if ($_GET['action'] === 'retransfer') {
if (!isset($_SERVER['DNS_RETRANSFER']) || !preg_match('/^[\w.]+$/', $_GET['domain']))
exit;
exec($_SERVER['DNS_RETRANSFER'] . ' ' . $_GET['domain']);
die('OK');
} else if ($_GET['action'] === 'add') {
$dns_file = file_get_contents($_SERVER['DNS_PATH']);
if (!$dns_file) {
Expand All @@ -32,7 +37,7 @@
die("Updated, nothing changed\n");
}
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);
$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");
}
Expand All @@ -53,7 +58,7 @@
die("Updated, Nothing changed\n");
}
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);
$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");
}
Expand Down

0 comments on commit 3b8f5b2

Please sign in to comment.