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));