servnest/public/ns/sshfp.php

62 lines
1.7 KiB
PHP

<?php require "../../common/top.php"; ?>
<form method="post">
<?php require "../../form.ns.php"; ?>
<br>
<label for="algo">Algorithme</label>
<br>
<select required="" name="algo" id="algo">
<option value="1">1 (RSA)</option>
<option value="2" disabled="">2 (DSA)</option>
<option value="3">3 (ECDSA)</option>
<option value="4" selected="">4 (ED25519)</option>
</select>
<br>
<label for="type">Type de hash</label>
<br>
<select required="" name="type" id="type">
<option value="1" disabled="">1 (SHA-1)</option>
<option value="2" selected="">2 (SHA-256)</option>
</select>
<br>
<label for="fp">Empreinte</label>
<br>
<input required="" id="fp" size="65" minlenght="64" maxlength="64" placeholder="26e6bbb4796c4fb78632e737d31a8acaba43c3a92d9c047031f04e9b70826e1d" name="fp" type="text">
<br>
<input value="Valider" type="submit">
</form>
<?php
if (nsCommonRequirements()
AND isset($_POST['algo'])
AND isset($_POST['fp'])
) {
$values = nsParseCommonRequirements();
if (!($_POST['algo'] === "1" OR $_POST['algo'] === "3" OR $_POST['algo'] === "4"))
exit("ERROR: Wrong value for algo");
if (!($_POST['type'] === "2"))
exit("ERROR: Wrong value for type");
if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
exit("ERROR: Wrong value for fp");
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 SSHFP " . $_POST['algo'] . " " . $_POST['type'] . " " . $_POST['fp']);
exec(CONF['ns']['knotc_path'] . " zone-commit " . $_POST['zone']);
echo "Enregistrement ajouté";
}
?>
<?php require "../../common/bottom.php"; ?>