浏览代码

ns: add CNAME, DNAME and LOC records forms

Miraty 3 年之前
父节点
当前提交
1167b52fc6
共有 5 个文件被更改,包括 221 次插入2 次删除
  1. 8 2
      common/pages.php
  2. 4 0
      public/css/form.css
  3. 28 0
      public/ns/cname.php
  4. 28 0
      public/ns/dname.php
  5. 153 0
      public/ns/loc.php

+ 8 - 2
common/pages.php

@@ -26,12 +26,15 @@ define('TITLES', [
 			'print' => 'Afficher les données',
 			'print' => 'Afficher les données',
 			'ip' => 'Enregistrements A et AAAA',
 			'ip' => 'Enregistrements A et AAAA',
 			'ns' => 'Enregistrement <abbr title="Name Server">NS</abbr>',
 			'ns' => 'Enregistrement <abbr title="Name Server">NS</abbr>',
-			'txt' => 'Enregistrement TXT',
+			'txt' => 'Enregistrement <abbr title="TeXT">TXT</abbr>',
 			'caa' => 'Enregistrement <abbr title="Certification Authority Authorization">CAA</abbr>',
 			'caa' => 'Enregistrement <abbr title="Certification Authority Authorization">CAA</abbr>',
-			'srv' => 'Enregistrement SRV',
+			'srv' => 'Enregistrement <abbr title="SeRVice">SRV</abbr>',
 			'mx' => 'Enregistrement <abbr title="Mail eXchanger">MX</abbr>',
 			'mx' => 'Enregistrement <abbr title="Mail eXchanger">MX</abbr>',
 			'sshfp' => 'Enregistrement <abbr title="Secure SHell FingerPrint">SSHFP</abbr>',
 			'sshfp' => 'Enregistrement <abbr title="Secure SHell FingerPrint">SSHFP</abbr>',
 			'tlsa' => 'Enregistrement <abbr title="Transport Layer Security Association">TLSA</abbr>',
 			'tlsa' => 'Enregistrement <abbr title="Transport Layer Security Association">TLSA</abbr>',
+			'cname' => 'Enregistrement <abbr title="Canonical NAME">CNAME</abbr>',
+			'dname' => 'Enregistrement <abbr title="Delegation NAME">DNAME</abbr>',
+			'loc' => 'Enregistrement <abbr title="LOCation">LOC</abbr>',
 		],
 		],
 		'ht' => [
 		'ht' => [
 			'index' => '<span aria-hidden="true">🕸️ </span>Hypertexte',
 			'index' => '<span aria-hidden="true">🕸️ </span>Hypertexte',
@@ -75,6 +78,9 @@ define('DESCRIPTIONS', [
 			'mx' => 'Indiquer l\'adresse du serveur recevant les courriels',
 			'mx' => 'Indiquer l\'adresse du serveur recevant les courriels',
 			'sshfp' => 'Indiquer les empreintes des clés <abbr title="Secure SHell">SSH</abbr>',
 			'sshfp' => 'Indiquer les empreintes des clés <abbr title="Secure SHell">SSH</abbr>',
 			'tlsa' => 'Mettre en place <abbr title="DNS-based Authentication of Named Entities">DANE</abbr> en indiquant l\'empreinte d\'un certificat <abbr title="Transport Layer Security">TLS</abbr>',
 			'tlsa' => 'Mettre en place <abbr title="DNS-based Authentication of Named Entities">DANE</abbr> en indiquant l\'empreinte d\'un certificat <abbr title="Transport Layer Security">TLS</abbr>',
+			'cname' => 'Définir un domaine comme étant l\'alias d\'un autre',
+			'dname' => 'Définir les sous-domaines d\'un domaine comme étant les alias des sous-domaines d\'un autre domaine',
+			'loc' => 'Indiquer des coordonnées géographiques',
 		],
 		],
 		'ht' => [
 		'ht' => [
 			'index' => 'Mettre en ligne son site statique sur un espace <abbr title="SSH File Transfert Protocol">SFTP</abbr>, et le faire répondre en <abbr title="HyperText Transfert Protocol">HTTP</abbr> par DNS ou Tor',
 			'index' => 'Mettre en ligne son site statique sur un espace <abbr title="SSH File Transfert Protocol">SFTP</abbr>, et le faire répondre en <abbr title="HyperText Transfert Protocol">HTTP</abbr> par DNS ou Tor',

+ 4 - 0
public/css/form.css

@@ -18,6 +18,10 @@ input[type=text] {
 	font-family: monospace;
 	font-family: monospace;
 }
 }
 
 
+input[type=number] {
+	width: 8ch;
+}
+
 input#subdomain, input#ttl-value {
 input#subdomain, input#ttl-value {
 	text-align: right;
 	text-align: right;
 }
 }

+ 28 - 0
public/ns/cname.php

@@ -0,0 +1,28 @@
+<?php require "../../common/html.php"; ?>
+
+<form method="post">
+	<?php require "../../form.ns.php"; ?>
+	<br>
+	<label for="cname">Nom canonique</label>
+	<br>
+	<input id="cname" placeholder="main.<?= PLACEHOLDER_DOMAIN ?>" name="cname" type="text">
+	<br>
+	<input value="Procéder" type="submit">
+</form>
+
+<?php
+
+switchToFormProcess();
+
+$values = nsParseCommonRequirements();
+
+$_POST['cname'] = formatAbsoluteDomain($_POST['cname']);
+
+knotcZoneExec($_POST['zone'], array(
+	$values['domain'],
+	$values['ttl'],
+	"CNAME",
+	$_POST['cname']
+));
+
+success("Enregistrement ajouté");

+ 28 - 0
public/ns/dname.php

@@ -0,0 +1,28 @@
+<?php require "../../common/html.php"; ?>
+
+<form method="post">
+	<?php require "../../form.ns.php"; ?>
+	<br>
+	<label for="dname">Nom délégué</label>
+	<br>
+	<input id="dname" placeholder="main.<?= PLACEHOLDER_DOMAIN ?>" name="dname" type="text">
+	<br>
+	<input value="Procéder" type="submit">
+</form>
+
+<?php
+
+switchToFormProcess();
+
+$values = nsParseCommonRequirements();
+
+$_POST['dname'] = formatAbsoluteDomain($_POST['dname']);
+
+knotcZoneExec($_POST['zone'], array(
+	$values['domain'],
+	$values['ttl'],
+	"DNAME",
+	$_POST['dname']
+));
+
+success("Enregistrement ajouté");

+ 153 - 0
public/ns/loc.php

@@ -0,0 +1,153 @@
+<?php require "../../common/html.php"; ?>
+
+<form method="post">
+
+	<?php require "../../form.ns.php"; ?>
+
+	<fieldset>
+		<legend>Latitude</legend>
+		<div>
+			<label for="lat-deg">Degrés</label>
+			<br>
+			<input name="lat-deg" id="lat-deg" min="0" max="90" type="number" required="">
+		</div>
+		<div>
+			<label for="lat-min">Minutes</label>
+			<br>
+			<input name="lat-min" id="lat-min" min="0" max="59" placeholder="0" type="number" required="">
+		</div>
+		<div>
+			<label for="lat-sec">Secondes</label>
+			<br>
+			<input name="lat-sec" id="lat-sec" step="0.001" min="0" max="59.999" placeholder="0" type="number" required="">
+		</div>
+		<div>
+			<label for="lat-dir">Direction</label>
+			<br>
+			<select required="" name="lat-dir" id="lat-dir">
+				<option value="" selected="" disabled="">-</option>
+				<option value="N">N - Nord</option>
+				<option value="S">S - Sud</option>
+			</select>
+		</div>
+	</fieldset>
+
+	<fieldset>
+		<legend>Longitude</legend>
+		<div>
+			<label for="lon-deg">Degrés</label>
+			<br>
+			<input name="lon-deg" id="lon-deg" min="0" max="180" type="number" required="">
+		</div>
+		<div>
+			<label for="lon-min">Minutes</label>
+			<br>
+			<input name="lon-min" id="lon-min" min="0" max="59" placeholder="0" type="number" required="">
+		</div>
+		<div>
+			<label for="lon-sec">Secondes</label>
+			<br>
+			<input name="lon-sec" id="lon-sec" step="0.001" min="0" max="59.999" placeholder="0" type="number" required="">
+		</div>
+		<div>
+			<label for="lon-dir">Direction</label>
+			<br>
+			<select required="" name="lon-dir" id="lon-dir">
+				<option value="" selected="" disabled="">-</option>
+				<option value="E">E - Est</option>
+				<option value="W">W - Ouest</option>
+			</select>
+		</div>
+	</fieldset>
+
+	<label for="alt">Altitude</label>
+	<br>
+	<input name="alt" id="alt" step="0.01" min="-100000.00" max="42849672.95" type="number" required="">m
+	<br>
+	<label for="size">Taille</label>
+	<br>
+	<input name="size" id="size" min="0" max="90000000" placeholder="1" type="number">m
+	<br>
+	<label for="hp">Précision horizontale</label>
+	<br>
+	<input name="hp" id="hp" min="0" max="90000000" placeholder="10000" type="number" required="">m
+	<br>
+	<label for="vp">Précision verticale</label>
+	<br>
+	<input name="vp" id="vp" min="0" max="90000000" placeholder="10" type="number" required="">m
+	<br>
+	<input value="Valider" type="submit">
+</form>
+
+<?php
+
+switchToFormProcess();
+
+$values = nsParseCommonRequirements();
+
+if (empty($_POST['lat-min']))
+	$_POST['lat-min'] = 0;
+if (empty($_POST['lat-sec']))
+	$_POST['lat-sec'] = 0;
+if (empty($_POST['lon-min']))
+	$_POST['lon-min'] = 0;
+if (empty($_POST['lon-sec']))
+	$_POST['lon-sec'] = 0;
+if (empty($_POST['size']))
+	$_POST['size'] = 1;
+if (empty($_POST['hp']))
+	$_POST['hp'] = 10000;
+if (empty($_POST['vp']))
+	$_POST['vp'] = 10;
+
+if (!($_POST['lat-deg'] >= 0 AND $_POST['lat-deg'] <= 90))
+	userError("Wrong value for <code>lat-deg</code>.");
+if (!($_POST['lat-min'] >= 0 AND $_POST['lat-min'] <= 59))
+	userError("Wrong value for <code>lat-min</code>.");
+if (!($_POST['lat-sec'] >= 0 AND $_POST['lat-sec'] <= 59.999))
+	userError("Wrong value for <code>lat-sec</code>.");
+
+if ($_POST['lat-dir'] !== "N" AND $_POST['lat-dir'] !== "S")
+	userError("Wrong value for <code>lat-dir</code>.");
+
+if (!($_POST['lon-deg'] >= 0 AND $_POST['lon-deg'] <= 180))
+	userError("Wrong value for <code>lon-deg</code>.");
+if (!($_POST['lon-min'] >= 0 AND $_POST['lon-min'] <= 59))
+	userError("Wrong value for <code>lon-min</code>.");
+if (!($_POST['lon-sec'] >= 0 AND $_POST['lon-sec'] <= 59.999))
+	userError("Wrong value for <code>lon-sec</code>.");
+
+if ($_POST['lon-dir'] !== "E" AND $_POST['lon-dir'] !== "W")
+	userError("Wrong value for <code>lon-dir</code>.");
+
+if (!($_POST['alt'] >= -100000 AND $_POST['alt'] <= 42849672.95))
+	userError("Wrong value for <code>alt</code>.");
+
+if (!($_POST['size'] >= 0 AND $_POST['size'] <= 90000000))
+	userError("Wrong value for <code>size</code>.");
+
+if (!($_POST['hp'] >= 0 AND $_POST['hp'] <= 90000000))
+	userError("Wrong value for <code>hp</code>.");
+
+if (!($_POST['vp'] >= 0 AND $_POST['vp'] <= 90000000))
+	userError("Wrong value for <code>vp</code>.");
+
+knotcZoneExec($_POST['zone'], array(
+	$values['domain'],
+	$values['ttl'],
+	"LOC",
+	$_POST['lat-deg'],
+	$_POST['lat-min'],
+	$_POST['lat-sec'],
+	$_POST['lat-dir'],
+	$_POST['lon-deg'],
+	$_POST['lon-min'],
+	$_POST['lon-sec'],
+	$_POST['lon-dir'],
+	$_POST['alt'] . 'm',
+	$_POST['size'] . 'm',
+	$_POST['hp'] . 'm',
+	$_POST['vp'] . 'm',
+));
+
+success("Enregistrement ajouté");