servnest/public/ns/srv.php

66 lines
1.8 KiB
PHP

<?php require "../../common/html.php"; ?>
<form method="post">
<?php require "../../form.ns.php"; ?>
<br>
<label for="priority">Priorité</label>
<br>
<input id="priority" min="0" max="65535" value="0" placeholder="0" name="priority" type="number">
<br>
<label for="weight">Poids</label>
<br>
<input id="weight" min="0" max="65535" value="0" placeholder="0" name="weight" type="number">
<br>
<label for="port">Port</label>
<br>
<input id="port" min="0" max="65535" placeholder="32768" name="port" type="number">
<br>
<label for="target">Cible</label>
<br>
<input id="target" minlenght="1" maxlength="128" placeholder="service.<?= CONF['common']['domain_example'] ?>." name="target" type="text">
<br>
<input value="Valider" type="submit">
</form>
<?php
if (nsCommonRequirements()
AND isset($_POST['priority'])
AND isset($_POST['weight'])
AND isset($_POST['port'])
AND isset($_POST['target'])
) {
$values = nsParseCommonRequirements();
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 65535))
userError("Wrong value for <code>priority</code>.");
if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
userError("Wrong value for <code>weight</code>.");
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
userError("Wrong value for <code>port</code>.");
checkAbsoluteDomainFormat($_POST['target']);
exec(CONF['ns']['knotc_path'] . " zone-begin " . $_POST['zone']);
exec(CONF['ns']['knotc_path'] . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $values['domain'] . " " . $values['ttl'] . " IN SRV " . $_POST['priority'] . " " . $_POST['weight'] . " " . $_POST['port'] . " " . $_POST['target']);
exec(CONF['ns']['knotc_path'] . " zone-commit " . $_POST['zone']);
echo "Enregistrement ajouté";
}
?>
<?php closeHTML(); ?>