/** * Deletes the selected zone and all associated records */ function delete($domain_id) { global $fmdb, $__FM_CONFIG; /** Does the domain_id exist for this account? */ basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $domain_id, 'domain_', 'domain_id', 'active'); if ($fmdb->num_rows) { $domain_result = $fmdb->last_result[0]; unset($fmdb->num_rows); /** Delete all associated configs */ basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', $domain_id, 'cfg_', 'domain_id'); if ($fmdb->num_rows) { if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', $domain_id, 'cfg_', 'deleted', 'domain_id') === false) { return __('The associated configs for this zone could not be deleted because a database error occurred.'); } unset($fmdb->num_rows); } /** Delete all associated records */ basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', $domain_id, 'record_', 'domain_id'); if ($fmdb->num_rows) { if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', $domain_id, 'record_', 'deleted', 'domain_id') === false) { return __('The associated records for this zone could not be deleted because a database error occurred.'); } unset($fmdb->num_rows); } basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records_skipped', $domain_id, 'record_', 'domain_id'); if ($fmdb->num_rows) { if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records_skipped', $domain_id, 'record_', 'deleted', 'domain_id') === false) { return __('The associated records for this zone could not be deleted because a database error occurred.'); } unset($fmdb->num_rows); } /** Delete all associated SOA */ if (!$domain_result->domain_clone_domain_id && $domain_result->soa_id) { basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'soa', $domain_result->soa_id, 'soa_', 'soa_id', "AND soa_template='no'"); if ($fmdb->num_rows) { if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'soa', $domain_result->soa_id, 'soa_', 'deleted', 'soa_id') === false) { return __('The SOA for this zone could not be deleted because a database error occurred.'); } unset($fmdb->num_rows); } } /** Delete associated records from fm_{$__FM_CONFIG['fmDNS']['prefix']}track_builds */ if (basicDelete('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_builds', $domain_id, 'domain_id', false) === false) { return sprintf(__('The zone could not be removed from the %s table because a database error occurred.'), 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_builds'); } /** Force buildconf for all associated DNS servers */ setBuildUpdateConfigFlag(getZoneServers($domain_id, array('masters', 'slaves')), 'yes', 'build'); /** Delete cloned zones */ basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $domain_id, 'domain_', 'domain_clone_domain_id'); if ($fmdb->num_rows) { unset($fmdb->num_rows); /** Delete cloned zone records first */ basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_id', 'domain_', "AND domain_clone_domain_id={$domain_id}"); if ($fmdb->num_rows) { $clone_domain_result = $fmdb->last_result; $clone_domain_num_rows = $fmdb->num_rows; for ($i = 0; $i < $clone_domain_num_rows; $i++) { if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', $clone_domain_result[$i]->domain_id, 'record_', 'deleted', 'domain_id') === false) { return __('The associated records for the cloned zones could not be deleted because a database error occurred.'); } } unset($fmdb->num_rows); } if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $domain_id, 'domain_', 'deleted', 'domain_clone_domain_id') === false) { return __('The associated clones for this zone could not be deleted because a database error occurred.'); } } /** Delete zone */ $tmp_name = displayFriendlyDomainName(getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')); if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $domain_id, 'domain_', 'deleted', 'domain_id') === false) { return __('This zone could not be deleted because a database error occurred.'); } addLogEntry("Deleted zone '{$tmp_name}' and all associated records."); return true; } return __('This zone does not exist.'); }
/** * Update fm_{$__FM_CONFIG['fmDNS']['prefix']}track_builds * * @since 1.0 * @package fmDNS */ function setBuiltDomainIDs($server_serial_no, $built_domain_ids) { global $fmdb, $__FM_CONFIG; if (!empty($built_domain_ids)) { /** Delete old records first */ basicDelete('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_builds', $server_serial_no, 'server_serial_no', false); basicDelete('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_reloads', $server_serial_no, 'server_serial_no', false); /** Add new records */ $sql = "INSERT INTO `fm_{$__FM_CONFIG['fmDNS']['prefix']}track_builds` VALUES "; foreach ($built_domain_ids as $id) { $sql .= '(' . $id . ',' . $server_serial_no . '),'; } $sql = rtrim($sql, ','); $fmdb->query($sql); } }
/** * Deletes the selected server/group */ function delete($server_id, $type) { global $fmdb, $__FM_CONFIG; /** Does the server_id exist for this account? */ if ($type == 'servers') { $server_serial_no = getNameFromID($server_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_', 'server_id', 'server_serial_no'); basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', $server_serial_no, 'server_', 'server_serial_no'); if ($fmdb->num_rows) { /** Update all associated domains */ $query = "SELECT domain_id,domain_name_servers FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE (`domain_name_servers` LIKE '%;s_{$server_id};%' OR `domain_name_servers` LIKE '%;s_{$server_id}' OR `domain_name_servers` LIKE 's_{$server_id};%' OR `domain_name_servers`='s_{$server_id}') AND `account_id`='{$_SESSION['user']['account_id']}'"; $fmdb->query($query); if ($fmdb->num_rows) { $result = $this->updateNameServerAssignments($fmdb->last_result, $fmdb->num_rows, 's_' . $server_id); if ($result !== true) { return $result; } } /** Delete associated config options */ if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', $server_serial_no, 'cfg_', 'deleted', 'server_serial_no') === false) { return __('The associated server configs could not be deleted because a database error occurred.'); } /** Delete associated records from fm_{$__FM_CONFIG['fmDNS']['prefix']}track_builds */ if (basicDelete('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_builds', $server_serial_no, 'server_serial_no', false) === false) { return sprintf(__('The server could not be removed from the %s table because a database error occurred.'), 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'track_builds'); } /** Delete server */ $tmp_name = getNameFromID($server_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_', 'server_id', 'server_name'); if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', $server_id, 'server_', 'deleted', 'server_id')) { addLogEntry(sprintf(__("Server '%s' (%s) was deleted"), $tmp_name, $server_serial_no)); return true; } } return __('This server could not be deleted.'); } else { basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'server_groups', $server_id, 'group_', 'group_id'); if ($fmdb->num_rows) { /** Update all associated domains */ $query = "SELECT domain_id,domain_name_servers FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE (`domain_name_servers` LIKE '%;g_{$server_id};%' OR `domain_name_servers` LIKE '%;g_{$server_id}' OR `domain_name_servers` LIKE 'g_{$server_id};%' OR `domain_name_servers`='g_{$server_id}') AND `account_id`='{$_SESSION['user']['account_id']}'"; $fmdb->query($query); if ($fmdb->num_rows) { $result = $this->updateNameServerAssignments($fmdb->last_result, $fmdb->num_rows, 'g_' . $server_id); if ($result !== true) { return $result; } } /** Delete group */ $tmp_name = getNameFromID($server_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'server_groups', 'group_', 'group_id', 'group_name'); if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'server_groups', $server_id, 'group_', 'deleted', 'group_id')) { addLogEntry(sprintf(__("Server group '%s' was deleted."), $tmp_name)); return true; } } return __('This server group could not be deleted.'); } return __('There is something wrong with your request.'); }