|
@@ -7,8 +7,22 @@
|
|
|
<option value="delete">Retirer</option>
|
|
|
</select>
|
|
|
<br>
|
|
|
- <label for="ns">Serveur de nom</label><br>
|
|
|
- <input required="" id="ns" placeholder="ns1.atope.art." name="ns" type="text">
|
|
|
+ <input required="" id="subdomain" placeholder="ns1" name="subdomain" type="text">
|
|
|
+ <select required="" name="suffix" id="suffix">
|
|
|
+ <option value="" disabled="" selected="">---</option>
|
|
|
+
|
|
|
+ <?php
|
|
|
+
|
|
|
+ $domains = regListUserDomains($_SESSION['username']);
|
|
|
+
|
|
|
+ if ($domains) {
|
|
|
+ foreach($domains as $domain) {
|
|
|
+ echo "<option value='" . $domain . "'>." . $domain . "</option>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ?>
|
|
|
+ </select>
|
|
|
<br>
|
|
|
<label for="ip">IP</label><br>
|
|
|
<input required="" pattern="^[a-f0-9:.]+$" id="ip" name="ip" minlength="7" maxlength="39" size="40" type="text" placeholder="2a0b:cbc0:1103:2::106f ou 45.13.104.169">
|
|
@@ -18,9 +32,22 @@
|
|
|
|
|
|
<?php
|
|
|
|
|
|
-if (isset($_POST['action']) AND isset($_POST['ns']) AND isset($_POST['ip'])) {
|
|
|
+if (isset($_POST['action']) AND isset($_POST['subdomain']) AND isset($_POST['suffix']) AND isset($_POST['ip'])) {
|
|
|
|
|
|
- checkAbsoluteDomainFormat($_POST['ns']);
|
|
|
+ if ($domains) {
|
|
|
+ foreach($domains as $domain) {
|
|
|
+ if ($_POST['suffix'] == $domain) goto ownedSuffix;
|
|
|
+ }
|
|
|
+ exit("ERROR : You don't own this suffix");
|
|
|
+ } else {
|
|
|
+ exit("ERROR : You don't own any domain");
|
|
|
+ }
|
|
|
+
|
|
|
+ ownedSuffix:
|
|
|
+
|
|
|
+ $domain = $_POST['subdomain'] . "." . $_POST['suffix'];
|
|
|
+
|
|
|
+ checkAbsoluteDomainFormat($domain);
|
|
|
|
|
|
checkIpFormat($_POST['ip']);
|
|
|
|
|
@@ -38,8 +65,11 @@ if (isset($_POST['action']) AND isset($_POST['ns']) AND isset($_POST['ip'])) {
|
|
|
else
|
|
|
exit("ERROR : Wrong value for action");
|
|
|
|
|
|
+ // Remove anything before the first dot and the first dot itself
|
|
|
+ $suffix = preg_replace("/^[^.]+\./", "", $_POST['suffix']);
|
|
|
+
|
|
|
exec(KNOTC_PATH . " zone-begin " . $suffix);
|
|
|
- exec(KNOTC_PATH . " zone-" . $action . "set " . $suffix . " " . $_POST['ns'] . " 86400 " . $record . " " . $_POST['ip']);
|
|
|
+ exec(KNOTC_PATH . " zone-" . $action . "set " . $suffix . " " . $_POST['subdomain'] . " 86400 " . $record . " " . $_POST['ip']);
|
|
|
exec(KNOTC_PATH . " zone-commit " . $suffix);
|
|
|
echo "Glue record ajouté";
|
|
|
}
|