6dbc63a36a
Move service-specific deletion code to functions
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
function nsCommonRequirements() {
|
|
return (isset($_POST['action'])
|
|
AND isset($_POST['zone'])
|
|
AND isset($_POST['ttl-value'])
|
|
AND isset($_POST['ttl-multiplier'])
|
|
AND isset($_SESSION['username'])
|
|
);
|
|
}
|
|
|
|
function nsParseCommonRequirements() {
|
|
nsCheckZonePossession($_POST['zone']);
|
|
|
|
if (($_POST['subdomain'] === "") OR ($_POST['subdomain'] === "@"))
|
|
$values['domain'] = $_POST['zone'];
|
|
else
|
|
$values['domain'] = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . $_POST['zone']);
|
|
|
|
$values['ttl'] = $_POST['ttl-value'] * $_POST['ttl-multiplier'];
|
|
|
|
if (!($values['ttl'] >= 300 AND $values['ttl'] <= 432000))
|
|
userError("Le TTL doit être compris entre 5 minutes et 5 jours (entre 300 et 432000 secondes).");
|
|
|
|
return $values;
|
|
}
|
|
|
|
function nsListUserZones($username) {
|
|
return query('select', 'zones', ['username' => $username], 'zone');
|
|
}
|
|
|
|
function nsCheckZonePossession($zone) {
|
|
checkAbsoluteDomainFormat($zone);
|
|
|
|
if (!in_array($zone, query('select', 'zones', ['username' => $_SESSION['username']], 'zone'), true))
|
|
userError("You don't own this zone on the nameserver.");
|
|
}
|
|
|
|
function nsDeleteZone($zone) {
|
|
// Remove from Knot configuration
|
|
knotcConfExec(["unset 'zone[$zone]'"]);
|
|
|
|
// Remove Knot zone file
|
|
if(unlink(CONF['ns']['knot_zones_path'] . '/' . $zone . 'zone') !== true)
|
|
serverError("Failed to remove Knot zone file.");
|
|
|
|
// Remove Knot related data
|
|
exec(CONF['dns']['knotc_path'] . " zone-purge " . $zone);
|
|
|
|
// Remove from database
|
|
query('delete', 'zones', [
|
|
'zone' => $zone,
|
|
'username' => $_SESSION['username'],
|
|
]);
|
|
}
|