2021-01-22 20:58:46 +00:00
|
|
|
<?php require "../top.inc.php"; ?>
|
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
<form method="post">
|
2021-07-15 13:36:34 +00:00
|
|
|
<h2>Ajouter une zone</h2>
|
2021-02-17 21:48:49 +00:00
|
|
|
<label for="domain">Domaine</label><br>
|
2021-08-05 00:34:00 +00:00
|
|
|
<input required="" placeholder="domain.<?= DOMAIN_EXAMPLE ?>." id="domain" name="domain" type="text"><br>
|
2021-07-15 13:36:34 +00:00
|
|
|
<input value="Ajouter" type="submit">
|
2021-02-17 21:48:49 +00:00
|
|
|
</form>
|
2021-01-22 20:58:46 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
<?php
|
2021-01-22 20:58:46 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
if (isset($_POST['domain']) AND isset($_SESSION['username'])) {
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
checkAbsoluteDomainFormat($_POST['domain']);
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
$stmt = $db->prepare("INSERT INTO zones(zone, username) VALUES(:zone, :username)");
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
$stmt->bindParam(':zone', $_POST['domain']);
|
|
|
|
$stmt->bindParam(':username', $_SESSION['username']);
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
$stmt->execute();
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
$knotZonePath = KNOT_ZONES_PATH . "/" . $_POST['domain'] . "zone";
|
|
|
|
$knotZone = file_get_contents(NIVER_TEMPLATE_PATH . "/knot.template");
|
|
|
|
$knotZone = preg_replace("/DOMAIN/", $_POST['domain'], $knotZone);
|
2021-05-14 19:10:56 +00:00
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
file_put_contents($knotZonePath, $knotZone);
|
|
|
|
chmod($knotZonePath, 0660);
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-19 12:29:04 +00:00
|
|
|
exec(KNOTC_PATH . " conf-begin");
|
|
|
|
exec(KNOTC_PATH . " conf-set 'zone[" . $_POST['domain'] . "]'");
|
2021-05-14 19:10:56 +00:00
|
|
|
exec(KNOTC_PATH . " conf-set 'zone[" . $_POST['domain'] . "].template' 'niver'");
|
2021-05-16 14:55:39 +00:00
|
|
|
exec(KNOTC_PATH . " conf-commit");
|
2021-07-15 13:36:34 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
echo "La requête a été traitée.";
|
2021-02-08 11:57:32 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
}
|
2021-01-22 20:58:46 +00:00
|
|
|
|
2021-02-17 21:48:49 +00:00
|
|
|
?>
|
2021-01-22 20:58:46 +00:00
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
<form method="post">
|
|
|
|
<h2>Supprimer une zone</h2>
|
|
|
|
<label for="zone">Zone</label>
|
|
|
|
<select required="" name="zone" id="zone">
|
|
|
|
<option value="" disabled="" selected="">-</option><?php
|
|
|
|
$zones = nsListUserZones($_SESSION['username']);
|
|
|
|
|
|
|
|
if (!empty($zones)) {
|
|
|
|
foreach ($zones as $zone)
|
|
|
|
echo "<option value='" . $zone . "'>" . $zone . "</option>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
<br>
|
|
|
|
<input value="Supprimer toutes les données liées à cette zone" type="submit">
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
if (isset($_POST['zone']) AND isset($_SESSION['username'])) {
|
|
|
|
|
|
|
|
nsCheckZonePossession($_POST['zone']);
|
|
|
|
|
|
|
|
$knotZonePath = KNOT_ZONES_PATH . "/" . $_POST['zone'] . "zone";
|
|
|
|
unlink($knotZonePath);
|
|
|
|
|
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
$stmt = $db->prepare("DELETE FROM zones WHERE zone = :zone AND username = :username");
|
|
|
|
|
|
|
|
$stmt->bindParam(':zone', $_POST['zone']);
|
|
|
|
$stmt->bindParam(':username', $_SESSION['username']);
|
|
|
|
|
|
|
|
$stmt->execute();
|
|
|
|
|
|
|
|
echo "La requête a été traitée.";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2021-01-22 20:58:46 +00:00
|
|
|
<?php require "../bottom.inc.php"; ?>
|