servnest/public/ns/tlsa.php

79 lines
2.6 KiB
PHP

<?php require "../../common/html.php"; ?>
<form method="post">
<?php require "../../form.ns.php"; ?>
<br>
<label for="use">Utilisation</label>
<br>
<select required="" name="use" id="use">
<option value="" selected="" disabled="">-</option>
<option value="0">0 (PKIX-TA, <abbr title="also known as">aka<abbr> CA constraint)</option>
<option value="1">1 (PKIX-EE, <abbr title="also known as">aka<abbr> Service certificate constraint)</option>
<option value="2">2 (DANE-TA, <abbr title="also known as">aka<abbr> Trust Anchor Assertion)</option>
<option value="3">3 (DANE-EE, <abbr title="also known as">aka<abbr> Domain issued certificate)</option>
</select>
<br>
<label for="selector">Selecteur</label>
<br>
<select required="" name="selector" id="selector">
<option value="" selected="" disabled="">-</option>
<option value="0">0 (le certificat entier doit correspondre)</option>
<option value="1">1 (la clé publique du certificat doit correspondre)</option>
</select>
<br>
<label for="type">Type de correspondance</label>
<br>
<select required="" name="type" id="type">
<option value="" selected="" disabled="">-</option>
<option value="0">0 (certificat entier)</option>
<option value="1">1 (SHA-256)</option>
<option value="2">2 (SHA-512)</option>
</select>
<br>
<label for="content">Contenu</label>
<br>
<input id="content" minlenght="3" maxlength="1024" pattern="^[a-zA-Z0-9.-]{3,1024}$" placeholder="gjioerjgioer" name="content" type="text">
<br>
<input value="Valider" type="submit">
</form>
<?php
if (nsCommonRequirements()
AND isset($_POST['use'])
AND isset($_POST['selector'])
AND isset($_POST['type'])
AND isset($_POST['content'])
) {
$values = nsParseCommonRequirements();
if (!($_POST['use'] >= 0 AND $_POST['use'] <= 3))
userError("Wrong value for <code>use</code>.");
if (!($_POST['selector'] === "0" OR $_POST['selector'] === "1"))
userError("Wrong value for <code>selector</code>.");
if (!($_POST['type'] >= 0 OR $_POST['type'] <= 2))
userError("Wrong value for <code>type</code>.");
if (!(preg_match("/^[a-zA-Z0-9.-]{1,1024}$/", $_POST['content'])))
userError("Wrong value for <code>content</code>.");
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 TLSA " . $_POST['use'] . " " . $_POST['selector'] . " " . $_POST['type'] . " " . $_POST['content']);
exec(CONF['ns']['knotc_path'] . " zone-commit " . $_POST['zone']);
echo "Enregistrement ajouté";
}
?>
<?php closeHTML(); ?>