From 7b3484b937be8e195bfc3e30a57289d668884565 Mon Sep 17 00:00:00 2001
From: Miraty
Date: Sun, 16 May 2021 16:55:39 +0200
Subject: [PATCH] Unify ns/ forms
---
exe.php | 14 +++++++++
inc/form/form.ns.inc.php | 46 ++++++++++++++++++++++++++++
inc/ns.inc.php | 25 +++++++++++++---
inc/pages.inc.php | 8 ++++-
less/form.less | 1 -
ns/caa.php | 53 +++++++-------------------------
ns/index.php | 13 ++++----
ns/ip.php | 42 +++++---------------------
ns/mx.php | 53 ++++++++++++++++++++++++++++++++
ns/ns.php | 35 ++++------------------
ns/srv.php | 65 ++++++++++++++++++++++++++++++++++++++++
ns/txt.php | 41 +++++--------------------
ns/zone.php | 9 ++++--
13 files changed, 251 insertions(+), 154 deletions(-)
create mode 100644 exe.php
create mode 100644 inc/form/form.ns.inc.php
create mode 100644 ns/mx.php
create mode 100644 ns/srv.php
diff --git a/exe.php b/exe.php
new file mode 100644
index 0000000..e1ed964
--- /dev/null
+++ b/exe.php
@@ -0,0 +1,14 @@
+Action
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/inc/ns.inc.php b/inc/ns.inc.php
index 7c4755b..9a4c008 100644
--- a/inc/ns.inc.php
+++ b/inc/ns.inc.php
@@ -2,13 +2,30 @@
if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
exit("This file is meant to be included.");
-function nsTtl($value, $multiplier) {
- $ttl = $value * $multiplier;
+function nsCommonRequirements() {
+ if (isset($_POST['action'])
+ AND isset($_POST['zone'])
+ AND isset($_POST['domain'])
+ AND isset($_POST['ttl-value'])
+ AND isset($_POST['ttl-multiplier'])
+ AND isset($_SESSION['username'])
+ ) {
+ return true;
+ }
+}
- if (!($ttl >= 300 AND $ttl <= 432000))
+function nsParseCommonRequirements() {
+ $values['action'] = checkAction($_POST['action']);
+
+ nsCheckZonePossession($_POST['zone']);
+ checkAbsoluteDomainFormat($_POST['domain']);
+
+ $values['ttl'] = $_POST['ttl-value'] * $_POST['ttl-multiplier'];
+
+ if (!($values['ttl'] >= 300 AND $values['ttl'] <= 432000))
exit("Erreur : le TTL doit être compris entre 5 minutes et 5 jours (entre 300 et 432000 secondes)");
- return $ttl;
+ return $values;
}
function nsListUserZones($username) {
diff --git a/inc/pages.inc.php b/inc/pages.inc.php
index 592ac66..37d7f78 100644
--- a/inc/pages.inc.php
+++ b/inc/pages.inc.php
@@ -14,7 +14,7 @@ switch (SERVICE) {
$page['title'] = "Obtenir les enregistrements DS";
break;
case "ip":
- $page['title'] = "Enregistrements A ou AAAA";
+ $page['title'] = "Enregistrements A et AAAA";
break;
case "ns":
$page['title'] = "Enregistrement NS";
@@ -25,6 +25,12 @@ switch (SERVICE) {
case "caa":
$page['title'] = "Enregistrement CAA";
break;
+ case "srv":
+ $page['title'] = "Enregistrement SRV";
+ break;
+ case "mx":
+ $page['title'] = "Enregistrement MX";
+ break;
case "zone":
$page['title'] = "Ajouter une zone";
break;
diff --git a/less/form.less b/less/form.less
index cd1ec29..25a5ef4 100644
--- a/less/form.less
+++ b/less/form.less
@@ -10,7 +10,6 @@ form {
input, select {
border-radius: 12px;
- height: 30px;
font-size: @fontSize;
margin: 5px;
height: 100%;
diff --git a/ns/caa.php b/ns/caa.php
index ea7a60c..6b408dc 100644
--- a/ns/caa.php
+++ b/ns/caa.php
@@ -1,31 +1,9 @@
+
+
+
+= 0 AND $_POST['priority'] <= 255))
+ exit("ERROR: Wrong value for priority");
+
+ if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 255))
+ exit("ERROR: Wrong value for weight");
+
+ if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
+ exit("ERROR: Wrong value for port");
+
+ checkAbsoluteDomainFormat($_POST['target']);
+
+ exec(KNOTC_PATH . " zone-begin " . $_POST['zone']);
+ exec(KNOTC_PATH . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $values['ttl'] . " IN MX " . $_POST['priority'] . " " . $_POST['weight'] . " " . $_POST['port'] . " " . $_POST['target']);
+ exec(KNOTC_PATH . " zone-commit " . $_POST['zone']);
+ echo "Enregistrement ajouté";
+}
+
+?>
+
+
diff --git a/ns/ns.php b/ns/ns.php
index c2be49b..aa3e0aa 100644
--- a/ns/ns.php
+++ b/ns/ns.php
@@ -1,29 +1,7 @@
+
+
+
+= 0 AND $_POST['priority'] <= 65535))
+ exit("ERROR: Wrong value for priority");
+
+ if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
+ exit("ERROR: Wrong value for weight");
+
+ if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
+ exit("ERROR: Wrong value for port");
+
+ checkAbsoluteDomainFormat($_POST['target']);
+
+ exec(KNOTC_PATH . " zone-begin " . $_POST['zone']);
+ exec(KNOTC_PATH . " zone-" . $values['action'] . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $values['ttl'] . " IN SRV " . $_POST['priority'] . " " . $_POST['weight'] . " " . $_POST['port'] . " " . $_POST['target']);
+ exec(KNOTC_PATH . " zone-commit " . $_POST['zone']);
+ echo "Enregistrement ajouté";
+}
+
+?>
+
+
diff --git a/ns/txt.php b/ns/txt.php
index 1c3af0d..4e598a3 100644
--- a/ns/txt.php
+++ b/ns/txt.php
@@ -1,29 +1,7 @@