Browse Source

Fuller zone removal

Miraty 3 years ago
parent
commit
fdfec134b9
1 changed files with 11 additions and 3 deletions
  1. 11 3
      ns/zone.php

+ 11 - 3
ns/zone.php

@@ -26,7 +26,6 @@ if (isset($_POST['domain']) AND isset($_SESSION['username'])) {
   $knotZonePath = KNOT_ZONES_PATH . "/" . $_POST['domain'] . "zone";
   $knotZone = file_get_contents(NIVER_TEMPLATE_PATH . "/knot.template");
   $knotZone = preg_replace("/DOMAIN/", $_POST['domain'], $knotZone);
-
   file_put_contents($knotZonePath, $knotZone);
   chmod($knotZonePath, 0660);
 
@@ -64,9 +63,18 @@ if (isset($_POST['zone']) AND isset($_SESSION['username'])) {
 
   nsCheckZonePossession($_POST['zone']);
 
-  $knotZonePath = KNOT_ZONES_PATH . "/" . $_POST['zone'] . "zone";
-  unlink($knotZonePath);
+  // Remove Knot zone file
+  unlink(KNOT_ZONES_PATH . "/" . $_POST['zone'] . "zone");
+
+  // Remove Knot tied data
+  exec(KNOTC_PATH . " zone-purge" . $_POST['zone']);
+
+  // Remove from Knot configuration
+  exec(KNOTC_PATH . " conf-begin");
+  exec(KNOTC_PATH . " conf-unset 'zone[" . $_POST['domain'] . "]'");
+  exec(KNOTC_PATH . " conf-commit");
 
+  // Remove from Niver's database
   $db = new PDO('sqlite:' . DB_PATH);
   $stmt = $db->prepare("DELETE FROM zones WHERE zone = :zone AND username = :username");