servnest/ns/zone.php

48 lines
1.6 KiB
PHP
Raw Normal View History

2021-01-22 21:58:46 +01:00
<?php require "../top.inc.php"; ?>
2021-02-17 22:48:49 +01:00
<form method="post">
<label for="domain">Domaine</label><br>
<input required="" placeholder="niver.atope.art." id="domain" name="domain" type="text"><br>
<input value="Valider" type="submit">
</form>
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
<?php
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
if (isset($_POST['domain']) AND isset($_SESSION['username'])) {
2021-02-17 22:48:49 +01:00
checkAbsoluteDomainFormat($_POST['domain']);
2021-02-17 22:48:49 +01:00
$db = new PDO('sqlite:' . DB_PATH);
$stmt = $db->prepare("INSERT INTO zones(zone, username) VALUES(:zone, :username)");
2021-02-17 22:48:49 +01:00
$stmt->bindParam(':zone', $_POST['domain']);
$stmt->bindParam(':username', $_SESSION['username']);
2021-02-17 22:48:49 +01:00
$stmt->execute();
2021-05-14 21:10:56 +02:00
$knotConf = file_get_contents(NIVER_TEMPLATE_PATH . "/knot.template");
$knotConf = preg_replace("/DOMAIN/", $_POST['domain'], $knotConf);
file_put_contents(KNOT_ZONES_PATH . "/" . $_POST['domain'] . "zone", $knotConf);
// Previous system
//exec("cp /var/lib/knot/zones/template /var/lib/knot/zones/" . $_POST['domain'] . "zone");
//exec("sed -i 's/DOMAIN/" . $_POST['domain'] . "/g' /var/lib/knot/zones/" . $_POST['domain'] . "zone");
2021-02-19 13:29:04 +01:00
exec(KNOTC_PATH . " conf-begin");
exec(KNOTC_PATH . " conf-set 'zone[" . $_POST['domain'] . "]'");
2021-05-14 21:10:56 +02:00
exec(KNOTC_PATH . " conf-set 'zone[" . $_POST['domain'] . "].template' 'niver'");
2021-05-16 16:55:39 +02:00
exec(KNOTC_PATH . " conf-commit");
/*
exec("/usr/sbin/knotc conf-begin");
exec("/usr/sbin/knotc conf-set 'zone[gaalde.atope.art.]'");
exec("/usr/sbin/knotc conf-set 'zone[gaalde.atope.art.].template' 'niver'");
exec("/usr/sbin/knotc conf-commit");
*/
2021-02-17 22:48:49 +01:00
echo "La requête a été traitée.";
2021-02-17 22:48:49 +01:00
}
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
?>
2021-01-22 21:58:46 +01:00
<?php require "../bottom.inc.php"; ?>