servnest/public/reg/ns.php

66 lines
1.6 KiB
PHP

<?php require "../../common/html.php"; ?>
<form method="post">
<label for="action">Action</label>
<select name="action" id="action">
<option value="add">Ajouter</option>
<option value="delete">Retirer</option>
</select>
<br>
<label for="domain">Domaine</label>
<br>
<select required="" name="domain" id="domain">
<option value="" disabled="" selected="">---</option>
<?php
$domains = regListUserDomains($_SESSION['username']);
if ($domains) {
foreach($domains as $domain) {
echo "<option value='" . $domain . "'>" . $domain . "</option>";
}
}
?>
</select>
<br>
<label for="ns">Serveur de nom</label>
<br>
<input id="ns" placeholder="ns1.<?= CONF['common']['domain_example'] ?>." name="ns" type="text">
<br>
<input value="Valider" type="submit">
</form>
<?php
if (isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns']) AND isset($_SESSION['username'])) {
regCheckDomainPossession($_POST['domain']);
checkAbsoluteDomainFormat($_POST['ns']);
$action = checkAction($_POST['action']);
$suffix = regGetUpperDomain($_POST['domain']);
exec(CONF['reg']['knotc_path'] . " zone-begin " . $suffix, $output);
exec(CONF['reg']['knotc_path'] . " zone-" . $action . "set " . $suffix . " " . $_POST['domain'] . " 86400 IN NS " . $_POST['ns'], $output);
exec(CONF['reg']['knotc_path'] . " zone-commit " . $suffix, $output);
$error = false;
var_dump($output);
foreach ($output as $line) {
if ($line !== "OK") {
$error = true;
}
}
if ($error) {
echo "An ERROR occured!";
} else {
echo "Modification effectuée avec succès";
}
}
?>
<?php closeHTML(); ?>