First commit

This commit is contained in:
2024-06-13 09:45:05 +02:00
commit 8073f47c48
11 changed files with 2082 additions and 0 deletions

33
api/addrecord.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
// header("Content-Type: content/json");
header("Content-Type: text/plain");
function stop($error)
{
http_response_code(513);
$RESPONSE = new stdClass();
$RESPONSE->status = "error";
$RESPONSE->response = $error;
printf(json_encode($RESPONSE));
die;
}
$_SERVER['REQUEST_METHOD'] !== "POST" && stop("Method " . $_SERVER['REQUEST_METHOD'] . " not allowed");
$POST = json_decode(file_get_contents('php://input'));
$DATA = "<< EOF
server 127.0.0.1
update add $POST->name $POST->ttl $POST->class $POST->type $POST->rr
send
EOF";
passthru("/usr/bin/nsupdate $DATA", $result_code);
$result_code === 0 || stop("Unable to update zone");
$RESPONSE = new stdClass();
$RESPONSE->status = "success";
$RESPONSE->response = "zone added successfully";
printf(json_encode($RESPONSE));