dir
.');
-if (query('select', 'sites', ['address' => $_POST['domain']], 'address') !== [])
+if (query('select', 'sites', ['address' => $_POST['domain']], ['address']) !== [])
output(403, _('This domain already exists on this service. Use another one.'));
$remoteAaaaRecords = dns_get_record($_POST['domain'], DNS_AAAA);
diff --git a/pg-act/ht/del.php b/pg-act/ht/del.php
index 8b25929..03e67a8 100644
--- a/pg-act/ht/del.php
+++ b/pg-act/ht/del.php
@@ -3,7 +3,7 @@
if (preg_match('/^(?site
.');
-if (isset(query('select', 'sites', ['username' => $_SESSION['id'], 'address' => $site['address'], 'type' => $site['type']], 'address')[0]) !== true)
+if (isset(query('select', 'sites', ['username' => $_SESSION['id'], 'address' => $site['address'], 'type' => $site['type']], ['address'])[0]) !== true)
output(403, 'Unavailable value for site
.');
htDeleteSite($site['address'], $site['type'], $_SESSION['id']);
diff --git a/pg-act/ns/sync.php b/pg-act/ns/sync.php
index 78ba6bd..251e15c 100644
--- a/pg-act/ns/sync.php
+++ b/pg-act/ns/sync.php
@@ -4,7 +4,7 @@ $el_nb = count($_POST['syncs']);
if ($el_nb < 1 OR $el_nb > 8)
output(403, 'Wrong elements number.');
-foreach ($_POST['syncs'] as $i => $sync) {
+foreach ($_POST['syncs'] as $i => &$sync) {
if (($sync['source'] ?? '') === '') {
unset($_POST['syncs'][$i]);
continue;
@@ -12,25 +12,41 @@ foreach ($_POST['syncs'] as $i => $sync) {
$sync['source'] = formatAbsoluteDomain($sync['source']);
nsCheckZonePossession($sync['destination']);
}
-$syncs = array_values($_POST['syncs']);
+$new_syncs = array_values($_POST['syncs']);
-$destinations = array_column($syncs, 'destination');
-if (count($destinations) !== count(array_unique($destinations)))
+$new_destinations = array_column($new_syncs, 'destination');
+if (count($new_destinations) !== count(array_unique($new_destinations)))
output(403, _('Multiple source domains can\'t be applied to the same target domain.'));
rateLimit();
+$current_syncs = query('select', 'ns-syncs', ['username' => $_SESSION['id']], ['source', 'destination']);
+
+try {
+ foreach ($new_syncs as $new_sync)
+ if (!in_array($new_sync, $current_syncs))
+ nsSync($new_sync['source'], $new_sync['destination']);
+} catch (KdigException | NoDnssecException $e) {
+ output(403, $e->getMessage() . LF);
+}
+
try {
DB->beginTransaction();
- query('delete', 'ns-syncs', ['username' => $_SESSION['id']]);
-
- foreach ($syncs as $sync)
- insert('ns-syncs', [
- 'username' => $_SESSION['id'],
- 'source' => $sync['source'],
- 'destination' => $sync['destination'],
- ]);
+ foreach ($current_syncs as $current_sync) // Deletions
+ if (!in_array($current_sync, $new_syncs))
+ query('delete', 'ns-syncs', [
+ 'username' => $_SESSION['id'],
+ 'source' => $current_sync['source'],
+ 'destination' => $current_sync['destination'],
+ ]);
+ foreach ($new_syncs as $new_sync) // Adds
+ if (!in_array($new_sync, $current_syncs))
+ insert('ns-syncs', [
+ 'username' => $_SESSION['id'],
+ 'source' => $new_sync['source'],
+ 'destination' => $new_sync['destination'],
+ ]);
DB->commit();
} catch (Exception $e) {
diff --git a/pg-act/ns/zone-add.php b/pg-act/ns/zone-add.php
index 420c200..b81b030 100644
--- a/pg-act/ns/zone-add.php
+++ b/pg-act/ns/zone-add.php
@@ -2,7 +2,7 @@
$domain = formatAbsoluteDomain($_POST['domain']);
-if (query('select', 'zones', ['zone' => $domain], 'zone') !== [])
+if (query('select', 'zones', ['zone' => $domain], ['zone']) !== [])
output(403, _('This zone already exists on the service.'));
$parent_domain = ltrim(strstr($domain, '.'), '.');
diff --git a/pg-act/reg/transfer.php b/pg-act/reg/transfer.php
index 4d46619..f27ded1 100644
--- a/pg-act/reg/transfer.php
+++ b/pg-act/reg/transfer.php
@@ -8,7 +8,7 @@ if (array_key_exists($_POST['suffix'], CONF['reg']['suffixes']) !== true)
$domain = formatAbsoluteDomain($_POST['subdomain'] . '.' . $_POST['suffix']);
-if (query('select', 'registry', ['username' => $_SESSION['id'], 'domain' => $domain], 'domain') !== [])
+if (query('select', 'registry', ['username' => $_SESSION['id'], 'domain' => $domain], ['domain']) !== [])
output(403, _('The current account already owns this domain.'));
$ns_records = array_column(kdig(name: $domain, type: 'NS', server: CONF['reg']['address'])['authorityRRs'], 'rdataNS');
diff --git a/pg-view/ns/index.php b/pg-view/ns/index.php
index 37f94b7..3c44f70 100644
--- a/pg-view/ns/index.php
+++ b/pg-view/ns/index.php
@@ -10,7 +10,7 @@
$_SESSION['id'] ?? ''], 'zone');
+$zones = query('select', 'zones', ['username' => $_SESSION['id'] ?? ''], ['zone']);
if ($zones === [])
echo '∅
' . LF; else { diff --git a/pg-view/ns/sync.php b/pg-view/ns/sync.php index 28555e2..0a914ad 100644 --- a/pg-view/ns/sync.php +++ b/pg-view/ns/sync.php @@ -25,7 +25,7 @@ foreach (array_slice(array_merge(query('select', 'ns-syncs', ['username' => $_SE