diff --git a/common/pages.php b/common/pages.php index ca92315..ce13290 100644 --- a/common/pages.php +++ b/common/pages.php @@ -66,11 +66,11 @@ define('DESCRIPTIONS', [ 'ip' => 'Indiquer l\'adresse IP d\'un domaine', 'ns' => 'Indiquer le serveur de noms d\'une zone', 'txt' => 'Associer du texte à un domaine', - 'caa' => 'Enregistrement CAA', - 'srv' => 'Indiquer l\'adresse pour un service spécifique', - 'mx' => 'Indiquer le serveur mail pour un domaine', - 'sshfp' => 'Indiquer les empreintes de clés SSH d\'un domaine', - 'tlsa' => 'Indiquer les seules autorités de certifications autorisée à signer les domaines', + 'caa' => 'Limiter les autorités de certification autorisées à émettre des certificats', + 'srv' => 'Indiquer l\'adresse d\'un service spécifique', + 'mx' => 'Indiquer l\'adresse du serveur recevant les courriels', + 'sshfp' => 'Indiquer les empreintes des clés SSH', + 'tlsa' => 'Mettre en place DANE en indiquant l\'empreinte d\'un certificat TLS', ], 'ht' => [ 'index' => 'Mettre en ligne son site statique sur un espace SFTP, et le faire répondre en HTTP par DNS ou Tor', diff --git a/fn/dns.php b/fn/dns.php index 282aa2f..db58ab1 100644 --- a/fn/dns.php +++ b/fn/dns.php @@ -38,6 +38,18 @@ function checkAbsoluteDomainFormat($domain) { userError("Domain malformed."); } +function formatEndWithDot($str) { + if (!str_ends_with($str, '.')) + $str .= '.'; + return $str; +} + +function formatAbsoluteDomain($domain) { + $domain = formatEndWithDot(strtolower($domain)); + checkAbsoluteDomainFormat($domain); + return $domain; +} + function checkAction($action) { return match ($action) { 'add' => '', diff --git a/fn/ns.php b/fn/ns.php index d63c87c..a598661 100644 --- a/fn/ns.php +++ b/fn/ns.php @@ -15,8 +15,7 @@ function nsParseCommonRequirements() { if (($_POST['subdomain'] === "") OR ($_POST['subdomain'] === "@")) $values['domain'] = $_POST['zone']; else - $values['domain'] = $_POST['subdomain'] . "." . $_POST['zone']; - checkAbsoluteDomainFormat($values['domain']); + $values['domain'] = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . $_POST['zone']); $values['ttl'] = $_POST['ttl-value'] * $_POST['ttl-multiplier']; @@ -30,9 +29,9 @@ function nsListUserZones($username) { return query('select', 'zones', ['username' => $username], 'zone'); } -function nsCheckZonePossession($submittedZone) { - checkAbsoluteDomainFormat($submittedZone); +function nsCheckZonePossession($zone) { + checkAbsoluteDomainFormat($zone); - if (!in_array($submittedZone, query('select', 'zones', ['username' => $_SESSION['username']], 'zone'), true)) + if (!in_array($zone, query('select', 'zones', ['username' => $_SESSION['username']], 'zone'), true)) userError("You don't own this zone on the nameserver."); } diff --git a/fn/reg.php b/fn/reg.php index c865a97..03953c1 100644 --- a/fn/reg.php +++ b/fn/reg.php @@ -1,20 +1,11 @@ $username], 'domain'); } function regCheckDomainPossession($domain) { - checkAbsoluteDomainFormat($domain); - - $ownedDomains = regListUserDomains($_SESSION['username']); - - if (in_array($domain, $ownedDomains, true) !== true) + if (in_array($domain, regListUserDomains($_SESSION['username']), true) !== true) userError("You don't own this domain."); } diff --git a/public/css/main.css b/public/css/main.css index 3f35403..91ce6fa 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -1,5 +1,5 @@ body { - margin: 0; + margin: 1rem; padding: 0; background-color: var(--background-color); color: var(--foreground-color); diff --git a/public/ns/dnssec.php b/public/ns/dnssec.php index 27ce8ef..3a1009d 100644 --- a/public/ns/dnssec.php +++ b/public/ns/dnssec.php @@ -17,52 +17,42 @@ if (isset($_SESSION['username'])) +?> -
= $_POST['zone'] ?>
- = $tag ?>
- = $algo ?>
- = $digestType ?>
- = $digest ?>
- = $_POST['zone'] ?>
+ = $tag ?>
+ = $algo ?>
+ = $digestType ?>
+ = $digest ?>
+ priority
.");
-checkAbsoluteDomainFormat($_POST['host']);
+$_POST['host'] = formatAbsoluteDomain($_POST['host']);
knotcExec($_POST['zone'], array(
$values['domain'],
diff --git a/public/ns/ns.php b/public/ns/ns.php
index 450af27..d6b3695 100644
--- a/public/ns/ns.php
+++ b/public/ns/ns.php
@@ -16,7 +16,7 @@ switchToFormProcess();
$values = nsParseCommonRequirements();
-checkAbsoluteDomainFormat($_POST['ns']);
+$_POST['ns'] = formatAbsoluteDomain($_POST['ns']);
knotcExec($_POST['zone'], array(
$values['domain'],
diff --git a/public/ns/srv.php b/public/ns/srv.php
index f00a01b..bfd68ba 100644
--- a/public/ns/srv.php
+++ b/public/ns/srv.php
@@ -47,7 +47,7 @@ if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
userError("Wrong value for port
.");
-checkAbsoluteDomainFormat($_POST['target']);
+$_POST['target'] = formatAbsoluteDomain($_POST['target']);
knotcExec($_POST['zone'], array(
$values['domain'],
diff --git a/public/ns/zone-add.php b/public/ns/zone-add.php
index c270689..a8d910a 100644
--- a/public/ns/zone-add.php
+++ b/public/ns/zone-add.php
@@ -10,7 +10,7 @@
switchToFormProcess();
-checkAbsoluteDomainFormat($_POST['domain']);
+$_POST['domain'] = formatAbsoluteDomain($_POST['domain']);
$db = new PDO('sqlite:' . DB_PATH);
$stmt = $db->prepare("INSERT INTO zones(zone, username) VALUES(:zone, :username)");
diff --git a/public/reg/ds.php b/public/reg/ds.php
index 790e9ca..2223f68 100644
--- a/public/reg/ds.php
+++ b/public/reg/ds.php
@@ -86,9 +86,7 @@ regCheckDomainPossession($_POST['zone']);
$action = checkAction($_POST['action']);
-$suffix = regGetUpperDomain($_POST['zone']);
-
-knotcExec($suffix, array(
+knotcExec(CONF['reg']['registry'], array(
$_POST['zone'],
CONF['reg']['ttl'],
"DS",
diff --git a/public/reg/glue.php b/public/reg/glue.php
index a10cf31..ad55497 100644
--- a/public/reg/glue.php
+++ b/public/reg/glue.php
@@ -41,15 +41,11 @@ switchToFormProcess();
regCheckDomainPossession($_POST['suffix']);
-$domain = $_POST['subdomain'] . "." . $_POST['suffix'];
-
-checkAbsoluteDomainFormat($domain);
+$domain = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . CONF['reg']['registry']);
$record = checkIpFormat($_POST['ip']);
-$publicSuffix = regGetUpperDomain($_POST['suffix']);
-
-knotcExec($publicSuffix, array(
+knotcExec(CONF['reg']['registry'], array(
$domain,
CONF['reg']['ttl'],
$record,
diff --git a/public/reg/ns.php b/public/reg/ns.php
index 28eb5bb..3f1043e 100644
--- a/public/reg/ns.php
+++ b/public/reg/ns.php
@@ -31,11 +31,9 @@ if (isset($_SESSION['username']))
switchToFormProcess();
regCheckDomainPossession($_POST['domain']);
-checkAbsoluteDomainFormat($_POST['ns']);
+$_POST['ns'] = formatAbsoluteDomain($_POST['ns']);
-$suffix = regGetUpperDomain($_POST['domain']);
-
-knotcExec($suffix, array(
+knotcExec(CONF['reg']['registry'], array(
$_POST['domain'],
CONF['reg']['ttl'],
"NS",
diff --git a/public/reg/register.php b/public/reg/register.php
index 9003172..95a53fd 100644
--- a/public/reg/register.php
+++ b/public/reg/register.php
@@ -20,9 +20,7 @@ switchToFormProcess();
if (preg_match("/" . CONF['reg']['subdomain_regex'] . "/", $_POST['subdomain']) !== 1)
userError("Erreur : Le nom de domaine doit être composé uniquement d'entre 4 et 63 lettres minuscules (a-z)");
-$domain = $_POST['subdomain'] . "." . CONF['reg']['registry'];
-
-checkAbsoluteDomainFormat($domain);
+$domain = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . CONF['reg']['registry']);
if (regIsFree($domain) !== true)
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");