diff --git a/dynamic_update.php b/dynamic_update.php index db131cbdc..e175982ba 100644 --- a/dynamic_update.php +++ b/dynamic_update.php @@ -38,19 +38,22 @@ require_once __DIR__ . '/vendor/autoload.php'; -$configuration = new LegacyConfiguration(); -$db_type = $configuration->get('db_type'); +$config = new LegacyConfiguration(); +$db_type = $config->get('db_type'); + +$pdns_db_name = $config->get('pdns_db_name'); +$records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; $credentials = [ - 'db_host' => $configuration->get('db_host'), - 'db_port' => $configuration->get('db_port'), - 'db_user' => $configuration->get('db_user'), - 'db_pass' => $configuration->get('db_pass'), - 'db_name' => $configuration->get('db_name'), - 'db_charset' => $configuration->get('db_charset'), - 'db_collation' => $configuration->get('db_collation'), + 'db_host' => $config->get('db_host'), + 'db_port' => $config->get('db_port'), + 'db_user' => $config->get('db_user'), + 'db_pass' => $config->get('db_pass'), + 'db_name' => $config->get('db_name'), + 'db_charset' => $config->get('db_charset'), + 'db_collation' => $config->get('db_collation'), 'db_type' => $db_type, - 'db_file' => $configuration->get('db_file'), + 'db_file' => $config->get('db_file'), ]; $databaseConnection = new PDODatabaseConnection(); @@ -204,8 +207,8 @@ function valid_ip_address(string $ip): int|string )"); $userAuthService = new UserAuthenticationService( - $configuration->get('password_encryption'), - $configuration->get('password_encryption_cost') + $config->get('password_encryption'), + $config->get('password_encryption_cost') ); if (!$user || !$userAuthService->verifyPassword($auth_password, $user['password'])) { return status_exit('badauth2'); @@ -218,7 +221,7 @@ function valid_ip_address(string $ip): int|string while ($zone = $zones_query->fetch()) { $zone_updated = false; - $name_query = $db->prepare("SELECT name, type, content FROM records WHERE domain_id=:domain_id and (type = 'A' OR type = 'AAAA')"); + $name_query = $db->prepare("SELECT name, type, content FROM $records_table WHERE domain_id=:domain_id and (type = 'A' OR type = 'AAAA')"); $name_query->execute([':domain_id' => $zone["domain_id"]]); while ($record = $name_query->fetch()) { @@ -227,7 +230,7 @@ function valid_ip_address(string $ip): int|string if ($ip == $record['content']) { $no_update_necessary = true; } else { - $update_query = $db->prepare("UPDATE records SET content =:ip where name=:record_name and type='A'"); + $update_query = $db->prepare("UPDATE $records_table SET content =:ip where name=:record_name and type='A'"); $update_query->execute([':ip' => $ip, ':record_name' => $record['name']]); $zone_updated = true; $was_updated = true; @@ -236,7 +239,7 @@ function valid_ip_address(string $ip): int|string if ($ip6 == $record['content']) { $no_update_necessary = true; } else { - $update_query = $db->prepare("UPDATE records SET content =:ip6 where name=:record_name and type='AAAA'"); + $update_query = $db->prepare("UPDATE $records_table SET content =:ip6 where name=:record_name and type='AAAA'"); $update_query->execute([':ip6' => $ip6, ':record_name' => $record['name']]); $zone_updated = true; $was_updated = true; @@ -245,7 +248,7 @@ function valid_ip_address(string $ip): int|string } } if ($zone_updated) { - $dnsRecord = new DnsRecord($db, $configuration); + $dnsRecord = new DnsRecord($db, $config); $dnsRecord->update_soa_serial($zone['domain_id']); } } diff --git a/lib/Application/Controller/AddRecordController.php b/lib/Application/Controller/AddRecordController.php index e46fda8f0..3dd7559d4 100644 --- a/lib/Application/Controller/AddRecordController.php +++ b/lib/Application/Controller/AddRecordController.php @@ -59,7 +59,8 @@ public function run(): void $perm_edit = Permission::getEditPermission($this->db); $zone_id = htmlspecialchars($_GET['id']); - $zone_type = DnsRecord::get_domain_type($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_type = $dnsRecord->get_domain_type($zone_id); $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zone_id); $this->checkCondition($zone_type == "SLAVE" @@ -103,7 +104,8 @@ private function addRecord(): void private function showForm(): void { $zone_id = htmlspecialchars($_GET['id']); - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); $ttl = $this->config('dns_ttl'); $iface_add_reverse_record = $this->config('iface_add_reverse_record'); $is_reverse_zone = preg_match('/i(p6|n-addr).arpa/i', $zone_name); @@ -144,19 +146,20 @@ public function checkId(): void public function createReverseRecord($name, $type, $content, string $zone_id, $ttl, $prio): void { $iface_add_reverse_record = $this->config('iface_add_reverse_record'); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); if ((isset($_POST["reverse"])) && $name && $iface_add_reverse_record) { if ($type === 'A') { $content_array = preg_split("/\./", $content); $content_rev = sprintf("%d.%d.%d.%d.in-addr.arpa", $content_array[3], $content_array[2], $content_array[1], $content_array[0]); - $zone_rev_id = DnsRecord::get_best_matching_zone_id_from_name($this->db, $content_rev); + $zone_rev_id = $dnsRecord->get_best_matching_zone_id_from_name($content_rev); } elseif ($type === 'AAAA') { $content_rev = DnsRecord::convert_ipv6addr_to_ptrrec($content); - $zone_rev_id = DnsRecord::get_best_matching_zone_id_from_name($this->db, $content_rev); + $zone_rev_id = $dnsRecord->get_best_matching_zone_id_from_name($content_rev); } if (isset($zone_rev_id) && $zone_rev_id != -1) { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); $fqdn_name = sprintf("%s.%s", $name, $zone_name); $dnsRecord = new DnsRecord($this->db, $this->getConfig()); if ($dnsRecord->add_record($zone_rev_id, $content_rev, 'PTR', $fqdn_name, $ttl, $prio)) { @@ -179,7 +182,8 @@ public function createReverseRecord($name, $type, $content, string $zone_id, $tt public function createRecord(string $zone_id, $name, $type, $content, $ttl, $prio): bool { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); $dnsRecord = new DnsRecord($this->db, $this->getConfig()); if ($dnsRecord->add_record($zone_id, $name, $type, $content, $ttl, $prio)) { diff --git a/lib/Application/Controller/AddZoneMasterController.php b/lib/Application/Controller/AddZoneMasterController.php index 0a8bbcd4a..99d9b582b 100644 --- a/lib/Application/Controller/AddZoneMasterController.php +++ b/lib/Application/Controller/AddZoneMasterController.php @@ -89,13 +89,13 @@ private function addZone(): void } elseif ($dns_third_level_check && DnsRecord::get_domain_level($zone_name) > 2 && $dnsRecord->domain_exists(DnsRecord::get_second_level_domain($zone_name))) { $this->setMessage('add_zone_master', 'error', _('There is already a zone_name with this name.')); $this->showForm(); - } elseif ($dnsRecord->domain_exists($zone_name) || DnsRecord::record_name_exists($this->db, $zone_name)) { + } elseif ($dnsRecord->domain_exists($zone_name) || $dnsRecord->record_name_exists($zone_name)) { $this->setMessage('add_zone_master', 'error', _('There is already a zone_name with this name.')); $this->showForm(); } elseif ($dnsRecord->add_domain($this->db, $zone_name, $owner, $dom_type, '', $zone_template)) { $this->setMessage('list_zones', 'success', _('Zone has been added successfully.')); - $zone_id = DnsRecord::get_zone_id_from_name($this->db, $zone_name); + $zone_id = $dnsRecord->get_zone_id_from_name($zone_name); $this->logger->log_info(sprintf('client_ip:%s user:%s operation:add_zone zone_name:%s zone_type:%s zone_template:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $zone_name, $dom_type, $zone_template), $zone_id); diff --git a/lib/Application/Controller/AddZoneSlaveController.php b/lib/Application/Controller/AddZoneSlaveController.php index 5a8b93998..72d1f7de2 100644 --- a/lib/Application/Controller/AddZoneSlaveController.php +++ b/lib/Application/Controller/AddZoneSlaveController.php @@ -87,7 +87,7 @@ private function addZone(): void } elseif ($dns_third_level_check && DnsRecord::get_domain_level($zone) > 2 && $dnsRecord->domain_exists(DnsRecord::get_second_level_domain($zone))) { $this->setMessage('add_zone_slave', 'error', _('There is already a zone with this name.')); $this->showForm(); - } elseif ($dnsRecord->domain_exists($zone) || DnsRecord::record_name_exists($this->db, $zone)) { + } elseif ($dnsRecord->domain_exists($zone) || $dnsRecord->record_name_exists($zone)) { $this->setMessage('add_zone_slave', 'error', _('There is already a zone with this name.')); $this->showForm(); } elseif (!Dns::are_multiple_valid_ips($master)) { @@ -96,7 +96,7 @@ private function addZone(): void } else { $dnsRecord = new DnsRecord($this->db, $this->getConfig()); if ($dnsRecord->add_domain($this->db, $zone, $owner, $type, $master, 'none')) { - $zone_id = DnsRecord::get_zone_id_from_name($this->db, $zone); + $zone_id = $dnsRecord->get_zone_id_from_name($zone); $this->logger->log_info(sprintf('client_ip:%s user:%s operation:add_zone zone:%s zone_type:SLAVE zone_master:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $zone, $master), $zone_id); diff --git a/lib/Application/Controller/BulkRegistrationController.php b/lib/Application/Controller/BulkRegistrationController.php index 8a96f4155..8030f9973 100644 --- a/lib/Application/Controller/BulkRegistrationController.php +++ b/lib/Application/Controller/BulkRegistrationController.php @@ -87,7 +87,7 @@ private function doBulkRegistration(): void } elseif ($dnsRecord->domain_exists($domain)) { $failed_domains[] = $domain . " - " . _('There is already a zone with this name.'); } elseif ($dnsRecord->add_domain($this->db, $domain, $_POST['owner'], $dom_type, '', $zone_template)) { - $zone_id = DnsRecord::get_zone_id_from_name($this->db, $domain); + $zone_id = $dnsRecord->get_zone_id_from_name($domain); $this->logger->log_info(sprintf('client_ip:%s user:%s operation:add_zone zone:%s zone_type:%s zone_template:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $domain, $dom_type, $zone_template), $zone_id); diff --git a/lib/Application/Controller/DeleteDomainController.php b/lib/Application/Controller/DeleteDomainController.php index 84a8b4289..3037afe1b 100644 --- a/lib/Application/Controller/DeleteDomainController.php +++ b/lib/Application/Controller/DeleteDomainController.php @@ -77,19 +77,20 @@ public function run(): void private function deleteDomain(string $zone_id): void { - $zone_info = DnsRecord::get_zone_info_from_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_info = $dnsRecord->get_zone_info_from_id($zone_id); $pdnssec_use = $this->config('pdnssec_use'); if ($pdnssec_use && $zone_info['type'] == 'MASTER') { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); - if ($dnssecProvider->isZoneSecured($zone_name)) { + if ($dnssecProvider->isZoneSecured($zone_name, $this->getConfig())) { $dnssecProvider->unsecureZone($zone_name); } } - if (DnsRecord::delete_domain($this->db, $zone_id)) { + if ($dnsRecord->delete_domain($zone_id)) { $this->logger->log_info(sprintf('client_ip:%s user:%s operation:delete_zone zone:%s zone_type:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], $zone_info['name'], $zone_info['type']), $zone_id); @@ -101,13 +102,15 @@ private function deleteDomain(string $zone_id): void private function showDeleteDomain(string $zone_id): void { - $zone_info = DnsRecord::get_zone_info_from_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_info = $dnsRecord->get_zone_info_from_id($zone_id); $zone_owners = LegacyUsers::get_fullnames_owners_from_domainid($this->db, $zone_id); $slave_master_exists = false; if ($zone_info['type'] == 'SLAVE') { - $slave_master = DnsRecord::get_domain_slave_master($this->db, $zone_id); - if (DnsRecord::supermaster_exists($this->db, $slave_master)) { + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $slave_master = $dnsRecord->get_domain_slave_master($zone_id); + if ($dnsRecord->supermaster_exists($slave_master)) { $slave_master_exists = true; } } diff --git a/lib/Application/Controller/DeleteDomainsController.php b/lib/Application/Controller/DeleteDomainsController.php index 97bfe2522..089f6bf84 100644 --- a/lib/Application/Controller/DeleteDomainsController.php +++ b/lib/Application/Controller/DeleteDomainsController.php @@ -66,7 +66,7 @@ public function run(): void public function deleteDomains($zone_ids): void { $dnsRecord = new DnsRecord($this->db, $this->getConfig()); - $deleted_zones = DnsRecord::get_zone_info_from_ids($this->db, $zone_ids); + $deleted_zones = $dnsRecord->get_zone_info_from_ids($zone_ids); $delete_domains = $dnsRecord->delete_domains($zone_ids); if ($delete_domains) { @@ -98,18 +98,21 @@ public function showDomains($zone_ids): void private function getZoneInfo($zone_ids): array { $zones = []; + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + foreach ($zone_ids as $zone_id) { $zones[$zone_id]['id'] = $zone_id; - $zones[$zone_id] = DnsRecord::get_zone_info_from_id($this->db, $zone_id); + $zones[$zone_id] = $dnsRecord->get_zone_info_from_id($zone_id); $zones[$zone_id]['owner'] = LegacyUsers::get_fullnames_owners_from_domainid($this->db, $zone_id); $zones[$zone_id]['is_owner'] = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zone_id); $zones[$zone_id]['has_supermaster'] = false; $zones[$zone_id]['slave_master'] = null; if ($zones[$zone_id]['type'] == "SLAVE") { - $slave_master = DnsRecord::get_domain_slave_master($this->db, $zone_id); + $slave_master = $dnsRecord->get_domain_slave_master($zone_id); $zones[$zone_id]['slave_master'] = $slave_master; - if (DnsRecord::supermaster_exists($this->db, $slave_master)) { + + if ($dnsRecord->supermaster_exists($slave_master)) { $zones[$zone_id]['has_supermaster'] = true; } } diff --git a/lib/Application/Controller/DeleteRecordController.php b/lib/Application/Controller/DeleteRecordController.php index c3a14714f..2d38088ce 100644 --- a/lib/Application/Controller/DeleteRecordController.php +++ b/lib/Application/Controller/DeleteRecordController.php @@ -58,14 +58,15 @@ public function run(): void } $record_id = htmlspecialchars($_GET['id']); - $zid = DnsRecord::get_zone_id_from_record_id($this->db, $record_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zid = $dnsRecord->get_zone_id_from_record_id($record_id); if ($zid == NULL) { $this->showError(_('There is no zone with this ID.')); } if (isset($_GET['confirm'])) { - $record_info = DnsRecord::get_record_from_id($this->db, $record_id); - if (DnsRecord::delete_record($this->db, $record_id)) { + $record_info = $dnsRecord->get_record_from_id($record_id); + if ($dnsRecord->delete_record($record_id)) { if (isset($record_info['prio'])) { $this->logger->log_info(sprintf('client_ip:%s user:%s operation:delete_record record_type:%s record:%s content:%s ttl:%s priority:%s', $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"], @@ -81,7 +82,7 @@ public function run(): void $dnsRecord->update_soa_serial($zid); if ($this->config('pdnssec_use')) { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zid); + $zone_name = $dnsRecord->get_domain_name_by_id($zid); $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); $dnssecProvider->rectifyZone($zone_name); } @@ -93,8 +94,9 @@ public function run(): void $perm_edit = Permission::getEditPermission($this->db); - $zone_info = DnsRecord::get_zone_info_from_id($this->db, $zid); - $zone_id = DnsRecord::recid_to_domid($this->db, $record_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_info = $dnsRecord->get_zone_info_from_id($zid); + $zone_id = $dnsRecord->recid_to_domid($record_id); $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zone_id); if ($zone_info['type'] == "SLAVE" || $perm_edit == "none" || ($perm_edit == "own" || $perm_edit == "own_as_client") && $user_is_zone_owner == "0") { $this->showError(_("You do not have the permission to edit this record.")); @@ -105,7 +107,8 @@ public function run(): void public function showQuestion(string $record_id, $zid, int $zone_id): void { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); if (str_starts_with($zone_name, "xn--")) { $idn_zone_name = idn_to_utf8($zone_name, IDNA_NONTRANSITIONAL_TO_ASCII); @@ -118,7 +121,7 @@ public function showQuestion(string $record_id, $zid, int $zone_id): void 'zone_id' => $zid, 'zone_name' => $zone_name, 'idn_zone_name' => $idn_zone_name, - 'record_info' => DnsRecord::get_record_from_id($this->db, $record_id), + 'record_info' => $dnsRecord->get_record_from_id($record_id), ]); } } diff --git a/lib/Application/Controller/DeleteSuperMasterController.php b/lib/Application/Controller/DeleteSuperMasterController.php index c4aa0ae6d..5c11034b3 100644 --- a/lib/Application/Controller/DeleteSuperMasterController.php +++ b/lib/Application/Controller/DeleteSuperMasterController.php @@ -79,7 +79,8 @@ private function deleteSuperMaster(): void private function showDeleteSuperMaster(): void { $master_ip = htmlspecialchars($_GET['master_ip']); - $info = DnsRecord::get_supermaster_info_from_ip($this->db, $master_ip); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $info = $dnsRecord->get_supermaster_info_from_ip($master_ip); $this->render('delete_supermaster.html', [ 'master_ip' => $master_ip, diff --git a/lib/Application/Controller/DeleteUserController.php b/lib/Application/Controller/DeleteUserController.php index e1199a873..045a205c8 100644 --- a/lib/Application/Controller/DeleteUserController.php +++ b/lib/Application/Controller/DeleteUserController.php @@ -73,7 +73,8 @@ public function deleteUser(string $uid): void $zones = $_POST['zone']; } - if (LegacyUsers::delete_user($this->db, $uid, $zones)) { + $legacyUsers = new LegacyUsers($this->db, $this->getConfig()); + if ($legacyUsers->delete_user($uid, $zones)) { $this->setMessage('users', 'success', _('The user has been deleted successfully.')); $this->redirect('index.php', ['page'=> 'users']); } diff --git a/lib/Application/Controller/DnsSecAddKeyController.php b/lib/Application/Controller/DnsSecAddKeyController.php index e4b4ce6f4..8585b0167 100644 --- a/lib/Application/Controller/DnsSecAddKeyController.php +++ b/lib/Application/Controller/DnsSecAddKeyController.php @@ -54,7 +54,8 @@ public function run(): void $this->showError(_("You do not have the permission to view this zone.")); } - if (DnsRecord::zone_id_exists($this->db, $zone_id) == "0") { + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + if ($dnsRecord->zone_id_exists($zone_id) == "0") { $this->showError(_('There is no zone with this ID.')); } @@ -88,7 +89,8 @@ public function run(): void } } - $domain_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $domain_name = $dnsRecord->get_domain_name_by_id($zone_id); if (isset($_POST["submit"])) { $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); if ($dnssecProvider->addZoneKey($domain_name, $key_type, $bits, $algorithm)) { diff --git a/lib/Application/Controller/DnsSecController.php b/lib/Application/Controller/DnsSecController.php index a3d305fb5..e6fe3f48a 100644 --- a/lib/Application/Controller/DnsSecController.php +++ b/lib/Application/Controller/DnsSecController.php @@ -60,7 +60,8 @@ public function run(): void $this->showError(_("You do not have the permission to view this zone.")); } - if (DnsRecord::zone_id_exists($this->db, $zone_id) == "0") { + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + if ($dnsRecord->zone_id_exists($zone_id) == "0") { $this->showError(_('There is no zone with this ID.')); } @@ -69,7 +70,8 @@ public function run(): void public function showDnsSecKeys(string $zone_id): void { - $domain_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $domain_name = $dnsRecord->get_domain_name_by_id($zone_id); if (str_starts_with($domain_name, "xn--")) { $idn_zone_name = idn_to_utf8($domain_name, IDNA_NONTRANSITIONAL_TO_ASCII); } else { @@ -77,14 +79,15 @@ public function showDnsSecKeys(string $zone_id): void } $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $this->render('dnssec.html', [ 'domain_name' => $domain_name, 'idn_zone_name' => $idn_zone_name, - 'domain_type' => DnsRecord::get_domain_type($this->db, $zone_id), + 'domain_type' => $dnsRecord->get_domain_type($zone_id), 'keys' => $dnssecProvider->getKeys($domain_name), 'pdnssec_use' => $this->config('pdnssec_use'), - 'record_count' => DnsRecord::count_zone_records($this->db, $zone_id), + 'record_count' => $dnsRecord->count_zone_records($zone_id), 'zone_id' => $zone_id, 'zone_template_id' => DnsRecord::get_zone_template($this->db, $zone_id), 'zone_templates' => ZoneTemplate::get_list_zone_templ($this->db, $_SESSION['userid']), diff --git a/lib/Application/Controller/DnsSecDeleteKeyController.php b/lib/Application/Controller/DnsSecDeleteKeyController.php index f229b0756..6813d6587 100644 --- a/lib/Application/Controller/DnsSecDeleteKeyController.php +++ b/lib/Application/Controller/DnsSecDeleteKeyController.php @@ -64,7 +64,8 @@ public function run(): void $this->showError(_('Invalid or unexpected input given.')); } - $domain_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $domain_name = $dnsRecord->get_domain_name_by_id($zone_id); if ($key_id == "-1") { $this->showError(_('Invalid or unexpected input given.')); diff --git a/lib/Application/Controller/DnsSecDsDnsKeyController.php b/lib/Application/Controller/DnsSecDsDnsKeyController.php index 22f6b692d..1d324e6ee 100644 --- a/lib/Application/Controller/DnsSecDsDnsKeyController.php +++ b/lib/Application/Controller/DnsSecDsDnsKeyController.php @@ -66,7 +66,8 @@ public function run(): void $this->showError(_("You do not have the permission to view this zone.")); } - if (DnsRecord::zone_id_exists($this->db, $zone_id) == "0") { + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + if ($dnsRecord->zone_id_exists($zone_id) == "0") { $this->showError(_('There is no zone with this ID.')); } @@ -75,9 +76,11 @@ public function run(): void public function showKeys(string $zone_id, $pdnssec_use): void { - $domain_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); - $domain_type = DnsRecord::get_domain_type($this->db, $zone_id); - $record_count = DnsRecord::count_zone_records($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + + $domain_name = $dnsRecord->get_domain_name_by_id($zone_id); + $domain_type = $dnsRecord->get_domain_type($zone_id); + $record_count = $dnsRecord->count_zone_records($zone_id); $zone_templates = ZoneTemplate::get_list_zone_templ($this->db, $_SESSION['userid']); $zone_template_id = DnsRecord::get_zone_template($this->db, $zone_id); diff --git a/lib/Application/Controller/DnsSecEditKeyController.php b/lib/Application/Controller/DnsSecEditKeyController.php index 9cf89ed98..374df1863 100644 --- a/lib/Application/Controller/DnsSecEditKeyController.php +++ b/lib/Application/Controller/DnsSecEditKeyController.php @@ -64,7 +64,8 @@ public function run(): void $this->showError(_('Invalid or unexpected input given.')); } - $domain_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $domain_name = $dnsRecord->get_domain_name_by_id($zone_id); if ($key_id == "-1") { $this->showError(_('Invalid or unexpected input given.')); diff --git a/lib/Application/Controller/EditCommentController.php b/lib/Application/Controller/EditCommentController.php index f98f63929..26f20d55d 100644 --- a/lib/Application/Controller/EditCommentController.php +++ b/lib/Application/Controller/EditCommentController.php @@ -63,7 +63,8 @@ public function run(): void $this->showError(_("You do not have the permission to view this comment.")); } - $zone_type = DnsRecord::get_domain_type($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_type = $dnsRecord->get_domain_type($zone_id); $perm_edit_comment = $zone_type == "SLAVE" || $perm_edit == "none" || ($perm_edit == "own" || $perm_edit == "own_as_client") && $user_is_zone_owner == "0"; if (isset($_POST["commit"])) { @@ -72,7 +73,8 @@ public function run(): void $errorPresenter = new ErrorPresenter(); $errorPresenter->present($error); } else { - DnsRecord::edit_zone_comment($this->db, $zone_id, $_POST['comment']); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $dnsRecord->edit_zone_comment($zone_id, $_POST['comment']); $this->setMessage('edit', 'success', _('The comment has been updated successfully.')); $this->redirect('index.php', ['page'=> 'edit', 'id' => $zone_id]); } @@ -83,7 +85,8 @@ public function run(): void public function showCommentForm(string $zone_id, bool $perm_edit_comment): void { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); if (str_starts_with($zone_name, "xn--")) { $idn_zone_name = idn_to_utf8($zone_name, IDNA_NONTRANSITIONAL_TO_ASCII); diff --git a/lib/Application/Controller/EditController.php b/lib/Application/Controller/EditController.php index 032ed69fb..95ea0535a 100644 --- a/lib/Application/Controller/EditController.php +++ b/lib/Application/Controller/EditController.php @@ -65,7 +65,8 @@ public function run(): void $this->showError(_('Invalid or unexpected input given.')); } $zone_id = intval(htmlspecialchars($_GET['id'])); - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); if (isset($_POST['commit'])) { $this->saveRecords($zone_id, $iface_zone_comments, $zone_name); @@ -91,14 +92,14 @@ public function run(): void $meta_edit = $perm_meta_edit == "all" || ($perm_meta_edit == "own" && $user_is_zone_owner == "1"); if (isset($_POST['slave_master_change']) && is_numeric($_POST["domain"])) { - DnsRecord::change_zone_slave_master($this->db, $_POST['domain'], $_POST['new_master']); + $dnsRecord->change_zone_slave_master($_POST['domain'], $_POST['new_master']); } $types = ZoneType::getTypes(); $new_type = htmlspecialchars($_POST['newtype'] ?? ''); if (isset($_POST['type_change']) && in_array($new_type, $types)) { - DnsRecord::change_zone_type($this->db, $new_type, $zone_id); + $dnsRecord->change_zone_type($new_type, $zone_id); } if (isset($_POST["newowner"]) && is_numeric($_POST["domain"]) && is_numeric($_POST["newowner"])) { @@ -116,7 +117,6 @@ public function run(): void $new_zone_template = $_POST['zone_template']; } if ($_POST['current_zone_template'] != $new_zone_template) { - $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $dnsRecord->update_zone_records($this->config('db_type'), $this->config('dns_ttl'), $zone_id, $new_zone_template); } } @@ -125,12 +125,11 @@ public function run(): void $this->showError(_("You do not have the permission to view this zone.")); } - if (DnsRecord::zone_id_exists($this->db, $zone_id) == "0") { + if ($dnsRecord->zone_id_exists($zone_id) == "0") { $this->showError(_('There is no zone with this ID.')); } if (isset($_POST['sign_zone'])) { - $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $dnsRecord->update_soa_serial($zone_id); $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); @@ -146,17 +145,18 @@ public function run(): void $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); $dnssecProvider->unsecureZone($zone_name); - $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $dnsRecord->update_soa_serial($zone_id); $this->setMessage('edit', 'success', _('Zone has been unsigned successfully.')); } - $domain_type = DnsRecord::get_domain_type($this->db, $zone_id); - $record_count = DnsRecord::count_zone_records($this->db, $zone_id); + $domain_type = $dnsRecord->get_domain_type($zone_id); + $record_count = $dnsRecord->count_zone_records($zone_id); $zone_templates = ZoneTemplate::get_list_zone_templ($this->db, $_SESSION['userid']); $zone_template_id = DnsRecord::get_zone_template($this->db, $zone_id); $zone_template_details = ZoneTemplate::get_zone_templ_details($this->db, $zone_template_id); - $slave_master = DnsRecord::get_domain_slave_master($this->db, $zone_id); + + $slave_master = $dnsRecord->get_domain_slave_master($zone_id); + $users = LegacyUsers::show_users($this->db); $zone_comment = ''; @@ -165,16 +165,16 @@ public function run(): void $zone_comment = htmlspecialchars($raw_zone_comment); } - $zone_name_to_display = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $zone_name_to_display = $dnsRecord->get_domain_name_by_id($zone_id); if (str_starts_with($zone_name_to_display, "xn--")) { $idn_zone_name = idn_to_utf8($zone_name_to_display, IDNA_NONTRANSITIONAL_TO_ASCII); } else { $idn_zone_name = ""; } - $records = DnsRecord::get_records_from_domain_id($this->db, $this->config('db_type'), $zone_id, $row_start, $iface_rowamount, $record_sort_by); + $records = $dnsRecord->get_records_from_domain_id($this->config('db_type'), $zone_id, $row_start, $iface_rowamount, $record_sort_by); $owners = DnsRecord::get_users_from_domain_id($this->db, $zone_id); - $soa_record = DnsRecord::get_soa_record($this->db, $zone_id); + $soa_record = $dnsRecord->get_soa_record($zone_id); $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); @@ -206,7 +206,7 @@ public function run(): void 'record_sort_by' => $record_sort_by, 'pagination' => $this->createAndPresentPagination($record_count, $iface_rowamount, $zone_id), 'pdnssec_use' => $this->config('pdnssec_use'), - 'is_secured' => $dnssecProvider->isZoneSecured($zone_name), + 'is_secured' => $dnssecProvider->isZoneSecured($zone_name, $this->getConfig()), 'session_userid' => $_SESSION["userid"], 'dns_ttl' => $this->config('dns_ttl'), 'is_rev_zone' => preg_match('/i(p6|n-addr).arpa/i', $zone_name), @@ -250,15 +250,17 @@ public function saveRecords(int $zone_id, bool $iface_zone_comments, string $zon $one_record_changed = false; $serial_mismatch = false; + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + if (isset($_POST['record'])) { - $soa_record = DnsRecord::get_soa_record($this->db, $zone_id); + $soa_record = $dnsRecord->get_soa_record($zone_id); $current_serial = DnsRecord::get_soa_serial($soa_record); if (isset($_POST['serial']) && $_POST['serial'] != $current_serial) { $serial_mismatch = true; } else { foreach ($_POST['record'] as $record) { - $log = new RecordLog($this->db); + $log = new RecordLog($this->db, $this->getConfig()); if (isset($record['disabled']) && $record['disabled'] == 'on') { $record["disabled"] = 1; @@ -274,8 +276,6 @@ public function saveRecords(int $zone_id, bool $iface_zone_comments, string $zon $one_record_changed = true; } - $dnsRecord = new DnsRecord($this->db, $this->getConfig()); - $edit_record = $dnsRecord->edit_record($record); if (false === $edit_record) { $error = true; @@ -291,7 +291,7 @@ public function saveRecords(int $zone_id, bool $iface_zone_comments, string $zon $raw_zone_comment = DnsRecord::get_zone_comment($this->db, $zone_id); $zone_comment = $_POST['comment'] ?? ''; if ($raw_zone_comment != $zone_comment) { - DnsRecord::edit_zone_comment($this->db, $zone_id, $zone_comment); + $dnsRecord->edit_zone_comment($zone_id, $zone_comment); $one_record_changed = true; } } @@ -301,7 +301,6 @@ public function saveRecords(int $zone_id, bool $iface_zone_comments, string $zon if ($serial_mismatch && $experimental_edit_conflict_resolution == 'only_latest_version') { $this->setMessage('edit', 'warn', (_('Request has expired, please try again.'))); } else { - $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $dnsRecord->update_soa_serial($zone_id); if ($one_record_changed) { @@ -328,10 +327,13 @@ public function saveTemplateAs(string $zone_id): void } elseif ($template_name == '') { $this->showError(_('Template name can\'t be an empty string.')); } else { - DnsRecord::get_records_from_domain_id($this->db, $this->config('db_type'), $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $dnsRecord->get_records_from_domain_id($this->config('db_type'), $zone_id); $description = htmlspecialchars($_POST['templ_descr']) ?? ''; - ZoneTemplate::add_zone_templ_save_as($this->db, $template_name, $description, $_SESSION['userid'], $records, DnsRecord::get_domain_name_by_id($this->db, $zone_id)); + + // FIXME: $records is undefined + ZoneTemplate::add_zone_templ_save_as($this->db, $template_name, $description, $_SESSION['userid'], $records, $dnsRecord->get_domain_name_by_id($zone_id)); $this->setMessage('edit', 'success', _('Zone template has been added successfully.')); } } diff --git a/lib/Application/Controller/EditRecordController.php b/lib/Application/Controller/EditRecordController.php index 85afde43b..d594687db 100644 --- a/lib/Application/Controller/EditRecordController.php +++ b/lib/Application/Controller/EditRecordController.php @@ -59,10 +59,13 @@ public function run(): void $perm_edit = Permission::getEditPermission($this->db); $record_id = $_GET['id']; - $zid = DnsRecord::get_zone_id_from_record_id($this->db, $record_id); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zid = $dnsRecord->get_zone_id_from_record_id($record_id); $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zid); - $zone_type = DnsRecord::get_domain_type($this->db, $zid); + + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_type = $dnsRecord->get_domain_type($zid); if ($perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0") { $this->showError(_("You do not have the permission to view this record.")); @@ -83,10 +86,11 @@ public function run(): void public function showRecordEditForm($record_id, string $zone_type, $zid, string $perm_edit, $user_is_zone_owner): void { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zid); + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $zone_name = $dnsRecord->get_domain_name_by_id($zid); $recordTypes = RecordType::getTypes(); - $record = DnsRecord::get_record_from_id($this->db, $record_id); + $record = $dnsRecord->get_record_from_id($record_id); $record['record_name'] = trim(str_replace(htmlspecialchars($zone_name), '', htmlspecialchars($record["name"])), '.'); if (str_starts_with($zone_name, "xn--")) { @@ -110,8 +114,8 @@ public function showRecordEditForm($record_id, string $zone_type, $zid, string $ public function saveRecord($zid): void { - $old_record_info = DnsRecord::get_record_from_id($this->db, $_POST["rid"]); $dnsRecord = new DnsRecord($this->db, $this->getConfig()); + $old_record_info = $dnsRecord->get_record_from_id($_POST["rid"]); $postData = $_POST; if (isset($postData['disabled']) && $postData['disabled'] == "on") { @@ -125,7 +129,7 @@ public function saveRecord($zid): void $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $dnsRecord->update_soa_serial($zid); - $new_record_info = DnsRecord::get_record_from_id($this->db, $_POST["rid"]); + $new_record_info = $dnsRecord->get_record_from_id($_POST["rid"]); $this->logger->log_info(sprintf('client_ip:%s user:%s operation:edit_record' . ' old_record_type:%s old_record:%s old_content:%s old_ttl:%s old_priority:%s' . ' record_type:%s record:%s content:%s ttl:%s priority:%s', @@ -135,7 +139,7 @@ public function saveRecord($zid): void $zid); if ($this->config('pdnssec_use')) { - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zid); + $zone_name = $dnsRecord->get_domain_name_by_id($zid); $dnssecProvider = DnssecProviderFactory::create($this->db, $this->getConfig()); $dnssecProvider->rectifyZone($zone_name); } diff --git a/lib/Application/Controller/EditZoneTemplController.php b/lib/Application/Controller/EditZoneTemplController.php index 63fbdc8d6..0719d99ef 100644 --- a/lib/Application/Controller/EditZoneTemplController.php +++ b/lib/Application/Controller/EditZoneTemplController.php @@ -166,7 +166,8 @@ public function updateZoneTemplateDetails(string $zone_templ_id): void public function updateZoneRecords(string $zone_templ_id): void { - $zones = ZoneTemplate::get_list_zone_use_templ($this->db, $zone_templ_id, $_SESSION['userid']); + $zoneTemplate = new ZoneTemplate($this->db, $this->getConfig()); + $zones = $zoneTemplate->get_list_zone_use_templ($zone_templ_id, $_SESSION['userid']); $dnsRecord = new DnsRecord($this->db, $this->getConfig()); foreach ($zones as $zone_id) { $dnsRecord->update_zone_records($this->config('db_type'), $this->config('dns_ttl'), $zone_id, $zone_templ_id); diff --git a/lib/Application/Controller/ListSuperMastersController.php b/lib/Application/Controller/ListSuperMastersController.php index 229286ae3..9a1803596 100644 --- a/lib/Application/Controller/ListSuperMastersController.php +++ b/lib/Application/Controller/ListSuperMastersController.php @@ -47,10 +47,11 @@ public function run(): void private function showSuperMasters(): void { + $dnsRecord = new DnsRecord($this->db, $this->getConfig()); $this->render('list_supermasters.html', [ 'perm_sm_add' => LegacyUsers::verify_permission($this->db, 'supermaster_add'), 'perm_sm_edit' => LegacyUsers::verify_permission($this->db, 'supermaster_edit'), - 'supermasters' => DnsRecord::get_supermasters($this->db) + 'supermasters' => $dnsRecord->get_supermasters() ]); } } diff --git a/lib/Application/Controller/ListZonesController.php b/lib/Application/Controller/ListZonesController.php index 358b663c6..fe4a74fcf 100644 --- a/lib/Application/Controller/ListZonesController.php +++ b/lib/Application/Controller/ListZonesController.php @@ -73,9 +73,8 @@ private function listZones(): void $perm_view = Permission::getViewPermission($this->db); $perm_edit = Permission::getEditPermission($this->db); - - $count_zones_view = DnsRecord::zone_count_ng($this->db, $this->config('db_type'), $perm_view); - $count_zones_edit = DnsRecord::zone_count_ng($this->db, $this->config('db_type'), $perm_edit); + $count_zones_view = DnsRecord::zone_count_ng($this->db, $this->getConfig(), $perm_view); + $count_zones_edit = DnsRecord::zone_count_ng($this->db, $this->getConfig(), $perm_edit); $letter_start = 'all'; if ($count_zones_view > $iface_rowamount) { @@ -88,7 +87,7 @@ private function listZones(): void } } - $count_zones_all_letterstart = DnsRecord::zone_count_ng($this->db, $this->config('db_type'), $perm_view, $letter_start); + $count_zones_all_letterstart = DnsRecord::zone_count_ng($this->db, $this->getConfig(), $perm_view, $letter_start); $zone_sort_by = 'name'; if (isset($_GET["zone_sort_by"]) && preg_match("/^[a-z_]+$/", $_GET["zone_sort_by"])) { @@ -138,9 +137,7 @@ private function listZones(): void private function getAvailableStartingLetters(string $letterStart, int $userId): string { - $db_type = $this->config('db_type'); - - $zoneRepository = new DbZoneRepository($this->db, $db_type); + $zoneRepository = new DbZoneRepository($this->db, $this->getConfig()); $zoneService = new ZoneService($zoneRepository); $userRepository = new DbUserRepository($this->db); diff --git a/lib/Application/Controller/SearchController.php b/lib/Application/Controller/SearchController.php index 04a662c8c..50c843e07 100644 --- a/lib/Application/Controller/SearchController.php +++ b/lib/Application/Controller/SearchController.php @@ -79,7 +79,7 @@ public function run(): void $db_type = $this->config('db_type'); - $zoneSearch = new ZoneSearch($this->db, $db_type); + $zoneSearch = new ZoneSearch($this->db, $this->getConfig(), $db_type); $searchResultZones = $zoneSearch->searchZones( $parameters, $permission_view, @@ -93,7 +93,7 @@ public function run(): void $records_page = isset($_POST['records_page']) ? (int)$_POST['records_page'] : 1; $iface_search_group_records = $this->config('iface_search_group_records'); - $recordSearch = new RecordSearch($this->db, $db_type); + $recordSearch = new RecordSearch($this->db, $this->getConfig(), $db_type); $searchResultRecords = $recordSearch->searchRecords( $parameters, $permission_view, diff --git a/lib/Application/Query/BaseSearch.php b/lib/Application/Query/BaseSearch.php index 2966acc60..1ae438177 100644 --- a/lib/Application/Query/BaseSearch.php +++ b/lib/Application/Query/BaseSearch.php @@ -22,14 +22,18 @@ namespace Poweradmin\Application\Query; +use Poweradmin\LegacyConfiguration; + abstract class BaseSearch { protected object $db; protected string $db_type; + protected LegacyConfiguration $config; - public function __construct($db, string $db_type) + public function __construct($db, $config, string $db_type) { $this->db = $db; + $this->config = $config; $this->db_type = $db_type; } diff --git a/lib/Application/Query/RecordSearch.php b/lib/Application/Query/RecordSearch.php index da5656218..d4c5eb93a 100644 --- a/lib/Application/Query/RecordSearch.php +++ b/lib/Application/Query/RecordSearch.php @@ -69,28 +69,31 @@ public function fetchRecords(mixed $search_string, bool $reverse, mixed $reverse { $offset = ($page - 1) * $iface_rowamount; - $recordsQuery = ' + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $recordsQuery = " SELECT - records.id, - records.domain_id, - records.name, - records.type, - records.content, - records.ttl, - records.prio, + $records_table.id, + $records_table.domain_id, + $records_table.name, + $records_table.type, + $records_table.content, + $records_table.ttl, + $records_table.prio, z.id as zone_id, z.owner, u.id as user_id, u.fullname FROM - records - LEFT JOIN zones z on records.domain_id = z.domain_id + $records_table + LEFT JOIN zones z on $records_table.domain_id = z.domain_id LEFT JOIN users u on z.owner = u.id WHERE - (records.name LIKE ' . $this->db->quote($search_string, 'text') . ' OR records.content LIKE ' . $this->db->quote($search_string, 'text') . - ($reverse ? ' OR records.name LIKE ' . $this->db->quote($reverse_search_string, 'text') . ' OR records.content LIKE ' . $this->db->quote($reverse_search_string, 'text') : '') . ')' . + ($records_table.name LIKE " . $this->db->quote($search_string, 'text') . " OR $records_table.content LIKE " . $this->db->quote($search_string, 'text') . + ($reverse ? " OR $records_table.name LIKE " . $this->db->quote($reverse_search_string, 'text') . " OR $records_table.content LIKE " . $this->db->quote($reverse_search_string, 'text') : '') . ')' . ($permission_view == 'own' ? 'AND z.owner = ' . $this->db->quote($_SESSION['userid'], 'integer') : '') . - ($iface_search_group_records ? ' GROUP BY records.name, records.content ' : '') . + ($iface_search_group_records ? " GROUP BY $records_table.name, $records_table.content " : '') . ' ORDER BY ' . $sort_records_by . ' LIMIT ' . $iface_rowamount . ' OFFSET ' . $offset; @@ -137,18 +140,21 @@ public function getTotalRecords(array $parameters, string $permission_view, bool */ public function getFoundRecords(mixed $search_string, bool $reverse, mixed $reverse_search_string, string $permission_view, bool $iface_search_group_records): int { - $recordsQuery = ' + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $recordsQuery = " SELECT COUNT(*) FROM - records - LEFT JOIN zones z on records.domain_id = z.domain_id + $records_table + LEFT JOIN zones z on $records_table.domain_id = z.domain_id LEFT JOIN users u on z.owner = u.id WHERE - (records.name LIKE ' . $this->db->quote($search_string, 'text') . ' OR records.content LIKE ' . $this->db->quote($search_string, 'text') . - ($reverse ? ' OR records.name LIKE ' . $this->db->quote($reverse_search_string, 'text') . ' OR records.content LIKE ' . $this->db->quote($reverse_search_string, 'text') : '') . ')' . + ($records_table.name LIKE " . $this->db->quote($search_string, 'text') . " OR $records_table.content LIKE " . $this->db->quote($search_string, 'text') . + ($reverse ? " OR $records_table.name LIKE " . $this->db->quote($reverse_search_string, 'text') . " OR $records_table.content LIKE " . $this->db->quote($reverse_search_string, 'text') : '') . ')' . ($permission_view == 'own' ? 'AND z.owner = ' . $this->db->quote($_SESSION['userid'], 'integer') : '') . - ($iface_search_group_records ? ' GROUP BY records.name, records.content ' : ''); + ($iface_search_group_records ? " GROUP BY $records_table.name, $records_table.content " : ''); return (int)$this->db->queryOne($recordsQuery); } diff --git a/lib/Application/Query/ZoneSearch.php b/lib/Application/Query/ZoneSearch.php index c52733663..1dbbf236b 100644 --- a/lib/Application/Query/ZoneSearch.php +++ b/lib/Application/Query/ZoneSearch.php @@ -22,6 +22,9 @@ namespace Poweradmin\Application\Query; +use Poweradmin\LegacyConfiguration; +use Poweradmin\PDOLayer; + class ZoneSearch extends BaseSearch { /** @@ -91,11 +94,15 @@ public function fetchZones(mixed $search_string, bool $reverse, mixed $reverse_s { $offset = ($page - 1) * $iface_rowamount; - $zonesQuery = ' + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $zonesQuery = " SELECT - domains.id, - domains.name, - domains.type, + $domains_table.id, + $domains_table.name, + $domains_table.type, z.id as zone_id, z.domain_id, z.owner, @@ -104,13 +111,13 @@ public function fetchZones(mixed $search_string, bool $reverse, mixed $reverse_s u.username, record_count.count_records FROM - domains - LEFT JOIN zones z on domains.id = z.domain_id + $domains_table + LEFT JOIN zones z on $domains_table.id = z.domain_id LEFT JOIN users u on z.owner = u.id - LEFT JOIN (SELECT COUNT(domain_id) AS count_records, domain_id FROM records WHERE type IS NOT NULL GROUP BY domain_id) record_count ON record_count.domain_id=domains.id + LEFT JOIN (SELECT COUNT(domain_id) AS count_records, domain_id FROM $records_table WHERE type IS NOT NULL GROUP BY domain_id) record_count ON record_count.domain_id=$domains_table.id WHERE - (domains.name LIKE ' . $this->db->quote($search_string, 'text') . - ($reverse ? ' OR domains.name LIKE ' . $this->db->quote($reverse_search_string, 'text') : '') . ') ' . + ($domains_table.name LIKE " . $this->db->quote($search_string, 'text') . + ($reverse ? " OR $domains_table.name LIKE " . $this->db->quote($reverse_search_string, 'text') : '') . ') ' . ($permission_view == 'own' ? ' AND z.owner = ' . $this->db->quote($_SESSION['userid'], 'integer') : '') . ' ORDER BY ' . $sort_zones_by . ', z.owner' . ' LIMIT ' . $iface_rowamount . ' OFFSET ' . $offset; @@ -150,17 +157,21 @@ public function getTotalZones(array $parameters, string $permission_view): int */ public function getFoundZones(mixed $search_string, bool $reverse, mixed $reverse_search_string, string $permission_view): int { - $zonesQuery = ' + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $zonesQuery = " SELECT COUNT(*) FROM - domains - LEFT JOIN zones z on domains.id = z.domain_id + $domains_table + LEFT JOIN zones z on $domains_table.id = z.domain_id LEFT JOIN users u on z.owner = u.id - LEFT JOIN (SELECT COUNT(domain_id) AS count_records, domain_id FROM records WHERE type IS NOT NULL GROUP BY domain_id) record_count ON record_count.domain_id=domains.id + LEFT JOIN (SELECT COUNT(domain_id) AS count_records, domain_id FROM $records_table WHERE type IS NOT NULL GROUP BY domain_id) record_count ON record_count.domain_id=$domains_table.id WHERE - (domains.name LIKE ' . $this->db->quote($search_string, 'text') . - ($reverse ? ' OR domains.name LIKE ' . $this->db->quote($reverse_search_string, 'text') : '') . ') ' . + ($domains_table.name LIKE " . $this->db->quote($search_string, 'text') . + ($reverse ? " OR $domains_table.name LIKE " . $this->db->quote($reverse_search_string, 'text') : '') . ') ' . ($permission_view == 'own' ? ' AND z.owner = ' . $this->db->quote($_SESSION['userid'], 'integer') : ''); return (int)$this->db->queryOne($zonesQuery); diff --git a/lib/Application/Service/DnssecService.php b/lib/Application/Service/DnssecService.php index c22a5decd..c58b3e36b 100644 --- a/lib/Application/Service/DnssecService.php +++ b/lib/Application/Service/DnssecService.php @@ -40,8 +40,8 @@ public function secureZone(string $domainName): bool { public function unsecureZone(string $domainName): bool { return $this->provider->unsecureZone($domainName); } - public function isZoneSecured(string $domainName): bool { - return $this->provider->isZoneSecured($domainName); + public function isZoneSecured(string $domainName, $config): bool { + return $this->provider->isZoneSecured($domainName, $config); } public function getDsRecords(string $domainName): array { return $this->provider->getDsRecords($domainName); diff --git a/lib/DbZoneLogger.php b/lib/DbZoneLogger.php index 2e87c4a7e..7a79783ba 100644 --- a/lib/DbZoneLogger.php +++ b/lib/DbZoneLogger.php @@ -50,12 +50,15 @@ public function count_all_logs() public function count_logs_by_domain($domain) { + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? "$pdns_db_name.domains" : "domains"; + $stmt = $this->db->prepare(" - SELECT count(domains.id) as number_of_logs + SELECT count($domains_table.id) as number_of_logs FROM log_zones - INNER JOIN domains - ON domains.id = log_zones.zone_id - WHERE domains.name LIKE :search_by + INNER JOIN $domains_table + ON $domains_table.id = log_zones.zone_id + WHERE $domains_table.name LIKE :search_by "); $name = "%$domain%"; $stmt->execute(['search_by' => $name]); @@ -86,10 +89,13 @@ public function get_logs_for_domain($domain, $limit, $offset): array return array(); } + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? "$pdns_db_name.domains" : "domains"; + $stmt = $this->db->prepare(" - SELECT log_zones.id, log_zones.event, log_zones.created_at, domains.name FROM log_zones - INNER JOIN domains ON domains.id = log_zones.zone_id - WHERE domains.name LIKE :search_by + SELECT log_zones.id, log_zones.event, log_zones.created_at, $domains_table.name FROM log_zones + INNER JOIN $domains_table ON $domains_table.id = log_zones.zone_id + WHERE $domains_table.name LIKE :search_by LIMIT :limit OFFSET :offset" ); diff --git a/lib/Dns.php b/lib/Dns.php index cebcfd51e..75468a050 100644 --- a/lib/Dns.php +++ b/lib/Dns.php @@ -74,7 +74,8 @@ public static function endsWith(string $needle, string $haystack): bool */ public function validate_input(int $rid, int $zid, string $type, mixed &$content, mixed &$name, mixed &$prio, mixed &$ttl, $dns_hostmaster, $dns_ttl): bool { - $zone = DnsRecord::get_domain_name_by_id($this->db, $zid); // TODO check for return + $dnsRecord = new DnsRecord($this->db, $this->config); + $zone = $dnsRecord->get_domain_name_by_id($zid); // TODO check for return if (!self::endsWith(strtolower($zone), strtolower($name))) { if (isset($name) && $name != "") { @@ -85,7 +86,7 @@ public function validate_input(int $rid, int $zid, string $type, mixed &$content } if ($type != "CNAME") { - if (!self::is_valid_rr_cname_exists($this->db, $name, $rid)) { + if (!$this->is_valid_rr_cname_exists($name, $rid)) { return false; } } @@ -133,10 +134,10 @@ public function validate_input(int $rid, int $zid, string $type, mixed &$content break; case "CNAME": - if (!self::is_valid_rr_cname_name($this->db, $name)) { + if (!$this->is_valid_rr_cname_name($name)) { return false; } - if (!self::is_valid_rr_cname_unique($this->db, $name, $rid)) { + if (!$this->is_valid_rr_cname_unique($name, $rid)) { return false; } if (!$this->is_valid_hostname_fqdn($name, 1)) { @@ -209,7 +210,7 @@ public function validate_input(int $rid, int $zid, string $type, mixed &$content if (!$this->is_valid_hostname_fqdn($name, 1)) { return false; } - if (!self::is_valid_non_alias_target($this->db, $content)) { + if (!$this->is_valid_non_alias_target($content)) { return false; } break; @@ -596,13 +597,16 @@ public static function has_quotes_around(string $string): bool * * @return boolean true if valid, false otherwise */ - public static function is_valid_rr_cname_name($db, string $name): bool + public function is_valid_rr_cname_name(string $name): bool { - $query = "SELECT id FROM records - WHERE content = " . $db->quote($name, 'text') . " - AND (type = " . $db->quote('MX', 'text') . " OR type = " . $db->quote('NS', 'text') . ")"; + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; - $response = $db->queryOne($query); + $query = "SELECT id FROM $records_table + WHERE content = " . $this->db->quote($name, 'text') . " + AND (type = " . $this->db->quote('MX', 'text') . " OR type = " . $this->db->quote('NS', 'text') . ")"; + + $response = $this->db->queryOne($query); if (!empty($response)) { $error = new ErrorMessage(_('This is not a valid CNAME. Did you assign an MX or NS record to the record?')); @@ -622,14 +626,17 @@ public static function is_valid_rr_cname_name($db, string $name): bool * * @return boolean true if non-existant, false if exists */ - public static function is_valid_rr_cname_exists($db, string $name, int $rid): bool + public function is_valid_rr_cname_exists(string $name, int $rid): bool { - $where = ($rid > 0 ? " AND id != " . $db->quote($rid, 'integer') : ''); - $query = "SELECT id FROM records - WHERE name = " . $db->quote($name, 'text') . $where . " + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $where = ($rid > 0 ? " AND id != " . $this->db->quote($rid, 'integer') : ''); + $query = "SELECT id FROM $records_table + WHERE name = " . $this->db->quote($name, 'text') . $where . " AND TYPE = 'CNAME'"; - $response = $db->queryOne($query); + $response = $this->db->queryOne($query); if ($response) { $error = new ErrorMessage(_('This is not a valid record. There is already exists a CNAME with this name.')); $errorPresenter = new ErrorPresenter(); @@ -647,13 +654,16 @@ public static function is_valid_rr_cname_exists($db, string $name, int $rid): bo * * @return boolean true if unique, false if duplicate */ - public static function is_valid_rr_cname_unique($db, string $name, string $rid): bool + public function is_valid_rr_cname_unique(string $name, string $rid): bool { - $where = ($rid > 0 ? " AND id != " . $db->quote($rid, 'integer') : ''); - $query = "SELECT id FROM records - WHERE name = " . $db->quote($name, 'text') . $where; + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; - $response = $db->queryOne($query); + $where = ($rid > 0 ? " AND id != " . $this->db->quote($rid, 'integer') : ''); + $query = "SELECT id FROM $records_table + WHERE name = " . $this->db->quote($name, 'text') . $where; + + $response = $this->db->queryOne($query); if ($response) { $error = new ErrorMessage(_('This is not a valid CNAME. There already exists a record with this name.')); $errorPresenter = new ErrorPresenter(); @@ -690,13 +700,16 @@ public static function is_not_empty_cname_rr(string $name, string $zone): bool * * @return boolean true if not alias, false if CNAME exists */ - public static function is_valid_non_alias_target($db, string $target): bool + public function is_valid_non_alias_target(string $target): bool { - $query = "SELECT id FROM records - WHERE name = " . $db->quote($target, 'text') . " - AND TYPE = " . $db->quote('CNAME', 'text'); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT id FROM $records_table + WHERE name = " . $this->db->quote($target, 'text') . " + AND TYPE = " . $this->db->quote('CNAME', 'text'); - $response = $db->queryOne($query); + $response = $this->db->queryOne($query); if ($response) { $error = new ErrorMessage(_('You can not point a NS or MX record to a CNAME record. Remove or rename the CNAME record first, or take another name.')); $errorPresenter = new ErrorPresenter(); diff --git a/lib/DnsRecord.php b/lib/DnsRecord.php index ac87b6b14..d9b270435 100644 --- a/lib/DnsRecord.php +++ b/lib/DnsRecord.php @@ -48,54 +48,62 @@ public function __construct(PDOLayer $db, LegacyConfiguration $config) { /** Check if Zone ID exists * - * @param $db * @param int $zid Zone ID * * @return int Domain count or false on failure */ - public static function zone_id_exists($db, int $zid): int + public function zone_id_exists(int $zid): int { - $query = "SELECT COUNT(id) FROM domains WHERE id = " . $db->quote($zid, 'integer'); - return $db->queryOne($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $query = "SELECT COUNT(id) FROM $domains_table WHERE id = " . $this->db->quote($zid, 'integer'); + return $this->db->queryOne($query); } /** Get Zone ID from Record ID * - * @param $db * @param int $rid Record ID * * @return int Zone ID */ - public static function get_zone_id_from_record_id($db, int $rid): int + public function get_zone_id_from_record_id(int $rid): int { - $query = "SELECT domain_id FROM records WHERE id = " . $db->quote($rid, 'integer'); - return $db->queryOne($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT domain_id FROM $records_table WHERE id = " . $this->db->quote($rid, 'integer'); + return $this->db->queryOne($query); } /** Count Zone Records for Zone ID * - * @param $db * @param int $zone_id Zone ID * * @return int Record count */ - public static function count_zone_records($db, int $zone_id): int + public function count_zone_records(int $zone_id): int { - $sqlq = "SELECT COUNT(id) FROM records WHERE domain_id = " . $db->quote($zone_id, 'integer') . " AND type IS NOT NULL"; - return $db->queryOne($sqlq); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $sqlq = "SELECT COUNT(id) FROM $records_table WHERE domain_id = " . $this->db->quote($zone_id, 'integer') . " AND type IS NOT NULL"; + return $this->db->queryOne($sqlq); } /** Get SOA record content for Zone ID * - * @param $db * @param int $zone_id Zone ID * * @return string SOA content */ - public static function get_soa_record($db, int $zone_id): string + public function get_soa_record(int $zone_id): string { - $sqlq = "SELECT content FROM records WHERE type = " . $db->quote('SOA', 'text') . " AND domain_id = " . $db->quote($zone_id, 'integer'); - return $db->queryOne($sqlq); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $sqlq = "SELECT content FROM $records_table WHERE type = " . $this->db->quote('SOA', 'text') . " AND domain_id = " . $this->db->quote($zone_id, 'integer'); + return $this->db->queryOne($sqlq); } /** Get SOA Serial Number @@ -202,10 +210,14 @@ public function get_next_serial(int|string $curr_serial): int|string * * @return boolean true if success */ - public static function update_soa_record($db, int $domain_id, string $content): bool + public function update_soa_record(int $domain_id, string $content): bool { - $sqlq = "UPDATE records SET content = " . $db->quote($content, 'text') . " WHERE domain_id = " . $db->quote($domain_id, 'integer') . " AND type = " . $db->quote('SOA', 'text'); - $db->query($sqlq); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $sqlq = "UPDATE $records_table SET content = " . $this->db->quote($content, 'text') . " WHERE domain_id = " . $this->db->quote($domain_id, 'integer') . " AND type = " . $this->db->quote('SOA', 'text'); + $this->db->query($sqlq); + return true; } @@ -261,7 +273,7 @@ public function get_updated_soa_record(string $soa_rec): string */ public function update_soa_serial(int $domain_id): bool { - $soa_rec = self::get_soa_record($this->db, $domain_id); + $soa_rec = $this->get_soa_record($domain_id); if ($soa_rec == NULL) { return false; } @@ -271,7 +283,7 @@ public function update_soa_serial(int $domain_id): bool if ($curr_serial != $new_serial) { $soa_rec = self::set_soa_serial($soa_rec, $new_serial); - return self::update_soa_record($this->db, $domain_id, $soa_rec); + return $this->update_soa_record($domain_id, $soa_rec); } return true; @@ -300,12 +312,12 @@ public static function get_zone_comment($db, int $zone_id): string * * @return boolean true on success */ - public static function edit_zone_comment($db, int $zone_id, string $comment): bool + public function edit_zone_comment(int $zone_id, string $comment): bool { - $perm_edit = Permission::getEditPermission($db); + $perm_edit = Permission::getEditPermission($this->db); - $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($db, $zone_id); - $zone_type = self::get_domain_type($db, $zone_id); + $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zone_id); + $zone_type = $this->get_domain_type($zone_id); if ($zone_type == "SLAVE" || $perm_edit == "none" || (($perm_edit == "own" || $perm_edit == "own_as_client") && $user_is_zone_owner == "0")) { $error = new ErrorMessage(_("You do not have the permission to edit this comment.")); @@ -314,19 +326,19 @@ public static function edit_zone_comment($db, int $zone_id, string $comment): bo return false; } else { - $query = "SELECT COUNT(*) FROM zones WHERE domain_id=" . $db->quote($zone_id, 'integer'); + $query = "SELECT COUNT(*) FROM zones WHERE domain_id=" . $this->db->quote($zone_id, 'integer'); - $count = $db->queryOne($query); + $count = $this->db->queryOne($query); if ($count > 0) { $query = "UPDATE zones - SET comment=" . $db->quote($comment, 'text') . " - WHERE domain_id=" . $db->quote($zone_id, 'integer'); + SET comment=" . $this->db->quote($comment, 'text') . " + WHERE domain_id=" . $this->db->quote($zone_id, 'integer'); } else { $query = "INSERT INTO zones (domain_id, owner, comment, zone_templ_id) - VALUES(" . $db->quote($zone_id, 'integer') . ",1," . $db->quote($comment, 'text') . ",0)"; + VALUES(" . $this->db->quote($zone_id, 'integer') . ",1," . $this->db->quote($comment, 'text') . ",0)"; } - $db->query($query); + $this->db->query($query); } return true; } @@ -345,7 +357,7 @@ public function edit_record(array $record): bool $perm_edit = Permission::getEditPermission($this->db); $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $record['zid']); - $zone_type = self::get_domain_type($this->db, $record['zid']); + $zone_type = $this->get_domain_type($record['zid']); if ($record['type'] == 'SOA' && $perm_edit == "own_as_client") { $error = new ErrorMessage(_("You do not have the permission to edit this SOA record.")); @@ -371,7 +383,11 @@ public function edit_record(array $record): bool $errorPresenter->present($error); } elseif ($dns->validate_input($record['rid'], $record['zid'], $record['type'], $record['content'], $record['name'], $record['prio'], $record['ttl'], $dns_hostmaster, $dns_ttl)) { $name = strtolower($record['name']); // powerdns only searches for lower case records - $query = "UPDATE records + + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "UPDATE $records_table SET name=" . $this->db->quote($name, 'text') . ", type=" . $this->db->quote($record['type'], 'text') . ", content=" . $this->db->quote($record['content'], 'text') . ", @@ -403,7 +419,7 @@ public function add_record(int $zone_id, string $name, string $type, string $con $perm_edit = Permission::getEditPermission($this->db); $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $zone_id); - $zone_type = self::get_domain_type($this->db, $zone_id); + $zone_type = $this->get_domain_type($zone_id); if ($type == 'SOA' && $perm_edit == "own_as_client") { $error = new ErrorMessage(_("You do not have the permission to add SOA record.")); @@ -438,7 +454,11 @@ public function add_record(int $zone_id, string $name, string $type, string $con $this->db->beginTransaction(); $name = strtolower($name); // powerdns only searches for lower case records - $query = "INSERT INTO records (domain_id, name, type, content, ttl, prio) VALUES (" + + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "INSERT INTO $records_table (domain_id, name, type, content, ttl, prio) VALUES (" . $this->db->quote($zone_id, 'integer') . "," . $this->db->quote($name, 'text') . "," . $this->db->quote($type, 'text') . "," @@ -461,7 +481,8 @@ public function add_record(int $zone_id, string $name, string $type, string $con $this->db, new FakeConfiguration($pdns_api_url, $pdns_api_key) ); - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $zone_id); + $dnsRecord = new DnsRecord($this->db, $this->config); + $zone_name = $dnsRecord->get_domain_name_by_id($zone_id); $dnssecProvider->rectifyZone($zone_name); } @@ -511,7 +532,10 @@ public function add_supermaster(string $master_ip, string $ns_name, string $acco return false; } else { - $this->db->query("INSERT INTO supermasters VALUES (" . $this->db->quote($master_ip, 'text') . ", " . $this->db->quote($ns_name, 'text') . ", " . $this->db->quote($account, 'text') . ")"); + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $this->db->query("INSERT INTO $supermasters_table VALUES (" . $this->db->quote($master_ip, 'text') . ", " . $this->db->quote($ns_name, 'text') . ", " . $this->db->quote($account, 'text') . ")"); return true; } } @@ -529,7 +553,10 @@ public function delete_supermaster(string $master_ip, string $ns_name): bool { $dns = new Dns($this->db, $this->config); if (Dns::is_valid_ipv4($master_ip) || Dns::is_valid_ipv6($master_ip) || $dns->is_valid_hostname_fqdn($ns_name, 0)) { - $this->db->query("DELETE FROM supermasters WHERE ip = " . $this->db->quote($master_ip, 'text') . + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $this->db->query("DELETE FROM $supermasters_table WHERE ip = " . $this->db->quote($master_ip, 'text') . " AND nameserver = " . $this->db->quote($ns_name, 'text')); return true; } else { @@ -548,10 +575,13 @@ public function delete_supermaster(string $master_ip, string $ns_name): bool * * @return array array of supermaster details */ - public static function get_supermaster_info_from_ip($db, string $master_ip): array + public function get_supermaster_info_from_ip(string $master_ip): array { if (Dns::is_valid_ipv4($master_ip) || Dns::is_valid_ipv6($master_ip)) { - $result = $db->queryRow("SELECT ip,nameserver,account FROM supermasters WHERE ip = " . $db->quote($master_ip, 'text')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $result = $this->db->queryRow("SELECT ip,nameserver,account FROM $supermasters_table WHERE ip = " . $this->db->quote($master_ip, 'text')); return array( "master_ip" => $result["ip"], @@ -567,16 +597,18 @@ public static function get_supermaster_info_from_ip($db, string $master_ip): arr /** Get record details from Record ID * - * @param $db * @param int $rid Record ID * * @return array array of record details [rid,zid,name,type,content,ttl,prio] */ - public static function get_record_details_from_record_id($db, int $rid): array + public function get_record_details_from_record_id(int $rid): array { - $query = "SELECT id AS rid, domain_id AS zid, name, type, content, ttl, prio FROM records WHERE id = " . $db->quote($rid, 'integer'); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT id AS rid, domain_id AS zid, name, type, content, ttl, prio FROM $records_table WHERE id = " . $this->db->quote($rid, 'integer'); - $response = $db->query($query); + $response = $this->db->query($query); return $response->fetch(); } @@ -586,12 +618,12 @@ public static function get_record_details_from_record_id($db, int $rid): array * * @return boolean true on success */ - public static function delete_record($db, int $rid): bool + public function delete_record(int $rid): bool { - $perm_edit = Permission::getEditPermission($db); + $perm_edit = Permission::getEditPermission($this->db); - $record = self::get_record_details_from_record_id($db, $rid); - $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($db, $record['zid']); + $record = $this->get_record_details_from_record_id($rid); + $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $record['zid']); if ($perm_edit == "all" || (($perm_edit == "own" || $perm_edit == "own_as_client") && $user_is_zone_owner == "1")) { if ($record['type'] == "SOA") { @@ -599,8 +631,11 @@ public static function delete_record($db, int $rid): bool $errorPresenter = new ErrorPresenter(); $errorPresenter->present($error); } else { - $query = "DELETE FROM records WHERE id = " . $db->quote($rid, 'integer'); - $db->query($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "DELETE FROM $records_table WHERE id = " . $this->db->quote($rid, 'integer'); + $this->db->query($query); return true; } } else { @@ -660,18 +695,22 @@ public function add_domain($db, string $domain, int $owner, string $type, string $dns_ttl = $this->config->get('dns_ttl'); $db_type = $this->config->get('db_type'); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + if (($domain && $owner && $zone_template) || (preg_match('/in-addr.arpa/i', $domain) && $owner && $zone_template) || $type == "SLAVE" && $domain && $owner && $slave_master) { - $db->query("INSERT INTO domains (name, type) VALUES (" . $db->quote($domain, 'text') . ", " . $db->quote($type, 'text') . ")"); + $db->query("INSERT INTO $domains_table (name, type) VALUES (" . $db->quote($domain, 'text') . ", " . $db->quote($type, 'text') . ")"); $domain_id = $db->lastInsertId(); $db->query("INSERT INTO zones (domain_id, owner, zone_templ_id) VALUES (" . $db->quote($domain_id, 'integer') . ", " . $db->quote($owner, 'integer') . ", " . $db->quote(($zone_template == "none") ? 0 : $zone_template, 'integer') . ")"); if ($type == "SLAVE") { - $db->query("UPDATE domains SET master = " . $db->quote($slave_master, 'text') . " WHERE id = " . $db->quote($domain_id, 'integer')); + $db->query("UPDATE $domains_table SET master = " . $db->quote($slave_master, 'text') . " WHERE id = " . $db->quote($domain_id, 'integer')); return true; } else { if ($zone_template == "none" && $domain_id) { @@ -685,7 +724,8 @@ public function add_domain($db, string $domain, int $owner, string $type, string $serial .= "00"; $dns_soa = $this->config->get('dns_soa'); - $query = "INSERT INTO records (domain_id, name, content, type, ttl, prio) VALUES (" + + $query = "INSERT INTO $records_table (domain_id, name, content, type, ttl, prio) VALUES (" . $db->quote($domain_id, 'integer') . "," . $db->quote($domain, 'text') . "," . $db->quote($ns1 . ' ' . $hm . ' ' . $serial . ' ' . $dns_soa, 'text') . "," @@ -701,7 +741,7 @@ public function add_domain($db, string $domain, int $owner, string $type, string if ($templ_records != -1) { foreach ($templ_records as $r) { if ((preg_match('/in-addr.arpa/i', $domain) && ($r["type"] == "NS" || $r["type"] == "SOA")) || (!preg_match('/in-addr.arpa/i', $domain))) { - $zoneTemplate = new ZoneTemplate(); + $zoneTemplate = new ZoneTemplate($this->db, $this->config); $name = $zoneTemplate->parse_template_value($r["name"], $domain); $type = $r["type"]; $content = $zoneTemplate->parse_template_value($r["content"], $domain); @@ -712,7 +752,7 @@ public function add_domain($db, string $domain, int $owner, string $type, string $ttl = $dns_ttl; } - $query = "INSERT INTO records (domain_id, name, type, content, ttl, prio) VALUES (" + $query = "INSERT INTO $records_table (domain_id, name, type, content, ttl, prio) VALUES (" . $db->quote($domain_id, 'integer') . "," . $db->quote($name, 'text') . "," . $db->quote($type, 'text') . "," @@ -760,16 +800,20 @@ public function add_domain($db, string $domain, int $owner, string $type, string * * @return boolean true on success */ - public static function delete_domain($db, int $id): bool + public function delete_domain(int $id): bool { - $perm_edit = Permission::getEditPermission($db); - $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($db, $id); + $perm_edit = Permission::getEditPermission($this->db); + $user_is_zone_owner = LegacyUsers::verify_user_is_owner_zoneid($this->db, $id); + + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; if ($perm_edit == "all" || ($perm_edit == "own" && $user_is_zone_owner == "1")) { - $db->query("DELETE FROM zones WHERE domain_id=" . $db->quote($id, 'integer')); - $db->query("DELETE FROM records WHERE domain_id=" . $db->quote($id, 'integer')); - $db->query("DELETE FROM records_zone_templ WHERE domain_id=" . $db->quote($id, 'integer')); - $db->query("DELETE FROM domains WHERE id=" . $db->quote($id, 'integer')); + $this->db->query("DELETE FROM zones WHERE domain_id=" . $this->db->quote($id, 'integer')); + $this->db->query("DELETE FROM $records_table WHERE domain_id=" . $this->db->quote($id, 'integer')); + $this->db->query("DELETE FROM records_zone_templ WHERE domain_id=" . $this->db->quote($id, 'integer')); + $this->db->query("DELETE FROM $domains_table WHERE id=" . $this->db->quote($id, 'integer')); return true; } else { $error = new ErrorMessage(_("You do not have the permission to delete a zone.")); @@ -785,9 +829,12 @@ public static function delete_domain($db, int $id): bool * @param int $id Record ID * @return int Domain ID of record */ - public static function recid_to_domid($db, int $id): int + public function recid_to_domid(int $id): int { - $result = $db->query("SELECT domain_id FROM records WHERE id=" . $db->quote($id, 'integer')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $result = $this->db->query("SELECT domain_id FROM $records_table WHERE id=" . $this->db->quote($id, 'integer')); $r = $result->fetch(); return $r["domain_id"]; } @@ -862,14 +909,16 @@ public static function delete_owner_from_zone($db, int $zone_id, int $user_id): /** Get Domain Name by domain ID * - * @param $db * @param int $id Domain ID * * @return bool|string Domain name */ - public static function get_domain_name_by_id($db, int $id): bool|string + public function get_domain_name_by_id(int $id): bool|string { - $result = $db->queryRow("SELECT name FROM domains WHERE id=" . $db->quote($id, 'integer')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $result = $this->db->queryRow("SELECT name FROM $domains_table WHERE id=" . $this->db->quote($id, 'integer')); if ($result) { return $result["name"]; } else { @@ -883,14 +932,16 @@ public static function get_domain_name_by_id($db, int $id): bool|string /** Get zone id from name * - * @param $db * @param string $zname Zone name * @return bool|int Zone ID */ - public static function get_zone_id_from_name($db, string $zname): bool|int + public function get_zone_id_from_name(string $zname): bool|int { if (!empty($zname)) { - $result = $db->queryRow("SELECT id FROM domains WHERE name=" . $db->quote($zname, 'text')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $result = $this->db->queryRow("SELECT id FROM $domains_table WHERE name=" . $this->db->quote($zname, 'text')); if ($result) { return $result["id"]; } else { @@ -912,23 +963,27 @@ public static function get_zone_id_from_name($db, string $zname): bool|int * @param int $zid Zone ID * @return array array of zone details [type,name,master_ip,record_count] */ - public static function get_zone_info_from_id($db, int $zid): array + public function get_zone_info_from_id(int $zid): array { - $perm_view = Permission::getViewPermission($db); + $perm_view = Permission::getViewPermission($this->db); if ($perm_view == "none") { $error = new ErrorMessage(_("You do not have the permission to view this zone.")); $errorPresenter = new ErrorPresenter(); $errorPresenter->present($error); } else { - $query = "SELECT domains.type AS type, - domains.name AS name, - domains.master AS master_ip, - count(records.domain_id) AS record_count - FROM domains LEFT OUTER JOIN records ON domains.id = records.domain_id - WHERE domains.id = " . $db->quote($zid, 'integer') . " - GROUP BY domains.id, domains.type, domains.name, domains.master"; - $result = $db->queryRow($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT $domains_table.type AS type, + $domains_table.name AS name, + $domains_table.master AS master_ip, + count($records_table.domain_id) AS record_count + FROM $domains_table LEFT OUTER JOIN $records_table ON $domains_table.id = $records_table.domain_id + WHERE $domains_table.id = " . $this->db->quote($zid, 'integer') . " + GROUP BY $domains_table.id, $domains_table.type, $domains_table.name, $domains_table.master"; + $result = $this->db->queryRow($query); return array( "id" => $zid, "name" => $result['name'], @@ -941,15 +996,15 @@ public static function get_zone_info_from_id($db, int $zid): array /** Get Zone(s) details from Zone IDs * - * @param $db * @param array $zones Zone IDs * @return array */ - public static function get_zone_info_from_ids($db, array $zones): array + public function get_zone_info_from_ids(array $zones): array { + $dnsRecord = new DnsRecord($this->db, $this->config); $zone_infos = array(); foreach ($zones as $zone) { - $zone_info = DnsRecord::get_zone_info_from_id($db, $zone); + $zone_info = $dnsRecord->get_zone_info_from_id($zone); $zone_infos[] = $zone_info; } return $zone_infos; @@ -979,21 +1034,24 @@ public static function convert_ipv6addr_to_ptrrec(string $ip): string * * @return int Zone ID */ - public static function get_best_matching_zone_id_from_name($db, string $domain): int + public function get_best_matching_zone_id_from_name(string $domain): int { -// rev-patch -// tring to find the correct zone -// %ip6.arpa and %in-addr.arpa is looked for + // rev-patch + // string to find the correct zone + // %ip6.arpa and %in-addr.arpa is looked for $match = 72; // the longest ip6.arpa has a length of 72 $found_domain_id = -1; + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + // get all reverse-zones - $query = "SELECT name, id FROM domains - WHERE name like " . $db->quote('%.arpa', 'text') . " + $query = "SELECT name, id FROM $domains_table + WHERE name like " . $this->db->quote('%.arpa', 'text') . " ORDER BY length(name) DESC"; - $response = $db->query($query); + $response = $this->db->query($query); if ($response) { while ($r = $response->fetch()) { $pos = stripos($domain, $r["name"]); @@ -1021,8 +1079,12 @@ public static function get_best_matching_zone_id_from_name($db, string $domain): public function domain_exists(string $domain): bool { $dns = new Dns($this->db, $this->config); + + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + if ($dns->is_valid_hostname_fqdn($domain, 0)) { - $result = $this->db->queryRow("SELECT id FROM domains WHERE name=" . $this->db->quote($domain, 'text')); + $result = $this->db->queryRow("SELECT id FROM $domains_table WHERE name=" . $this->db->quote($domain, 'text')); return (bool)$result; } else { $error = new ErrorMessage(_('This is an invalid zone name.')); @@ -1037,9 +1099,12 @@ public function domain_exists(string $domain): bool * * @return array[] supermasters detail [master_ip,ns_name,account]s */ - public static function get_supermasters($db): array + public function get_supermasters(): array { - $result = $db->query("SELECT ip, nameserver, account FROM supermasters"); + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $result = $this->db->query("SELECT ip, nameserver, account FROM $supermasters_table"); $supermasters = array(); @@ -1059,10 +1124,13 @@ public static function get_supermasters($db): array * * @return boolean true if exists, otherwise false */ - public static function supermaster_exists($db, string $master_ip): bool + public function supermaster_exists(string $master_ip): bool { if (Dns::is_valid_ipv4($master_ip, false) || Dns::is_valid_ipv6($master_ip)) { - $result = $db->queryOne("SELECT ip FROM supermasters WHERE ip = " . $db->quote($master_ip, 'text')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $result = $this->db->queryOne("SELECT ip FROM $supermasters_table WHERE ip = " . $this->db->quote($master_ip, 'text')); return (bool)$result; } else { $error = new ErrorMessage(sprintf(_('Invalid argument(s) given to function %s %s'), "supermaster_exists", "No or no valid IPv4 or IPv6 address given.")); @@ -1081,8 +1149,12 @@ public static function supermaster_exists($db, string $master_ip): bool public function supermaster_ip_name_exists(string $master_ip, string $ns_name): bool { $dns = new Dns($this->db, $this->config); + if ((Dns::is_valid_ipv4($master_ip) || Dns::is_valid_ipv6($master_ip)) && $dns->is_valid_hostname_fqdn($ns_name, 0)) { - $result = $this->db->queryOne("SELECT ip FROM supermasters WHERE ip = " . $this->db->quote($master_ip, 'text') . + $pdns_db_name = $this->config->get('pdns_db_name'); + $supermasters_table = $pdns_db_name ? $pdns_db_name . ".supermasters" : "supermasters"; + + $result = $this->db->queryOne("SELECT ip FROM $supermasters_table WHERE ip = " . $this->db->quote($master_ip, 'text') . " AND nameserver = " . $this->db->quote($ns_name, 'text')); return (bool)$result; } else { @@ -1111,6 +1183,12 @@ public function get_zones(string $perm, int $userid = 0, string $letterstart = ' $iface_zonelist_serial = $this->config->get('iface_zonelist_serial'); $iface_zonelist_template = $this->config->get('iface_zonelist_template'); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + $cryptokeys_table = $pdns_db_name ? $pdns_db_name . '.cryptokeys' : 'cryptokeys'; + $domainmetadata_table = $pdns_db_name ? $pdns_db_name . '.domainmetadata' : 'domainmetadata'; + if ($letterstart == '_') { $letterstart = '\_'; } @@ -1124,49 +1202,49 @@ public function get_zones(string $perm, int $userid = 0, string $letterstart = ' return false; } else { if ($perm == "own") { - $sql_add = " AND zones.domain_id = domains.id AND zones.owner = " . $this->db->quote($userid, 'integer'); + $sql_add = " AND zones.domain_id = $domains_table.id AND zones.owner = " . $this->db->quote($userid, 'integer'); } if ($letterstart != 'all' && $letterstart != 1) { - $sql_add .= " AND " . DbCompat::substr($db_type) . "(domains.name,1,1) = " . $this->db->quote($letterstart, 'text') . " "; + $sql_add .= " AND " . DbCompat::substr($db_type) . "($domains_table.name,1,1) = " . $this->db->quote($letterstart, 'text') . " "; } elseif ($letterstart == 1) { - $sql_add .= " AND " . DbCompat::substr($db_type) . "(domains.name,1,1) " . DbCompat::regexp($db_type) . " '[0-9]'"; + $sql_add .= " AND " . DbCompat::substr($db_type) . "($domains_table.name,1,1) " . DbCompat::regexp($db_type) . " '[0-9]'"; } } if ($sortby == 'owner') { $sortby = 'users.username'; } elseif ($sortby != 'count_records') { - $sortby = 'domains.' . $sortby; + $sortby = "$domains_table." . $sortby; } - $natural_sort = 'domains.name'; + $natural_sort = "$domains_table.name"; if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'sqlite' || $db_type == 'sqlite3') { - $natural_sort = 'domains.name+0<>0 DESC, domains.name+0, domains.name'; + $natural_sort = "$domains_table.name+0<>0 DESC, $domains_table.name+0, $domains_table.name"; } elseif ($db_type == 'pgsql') { - $natural_sort = "SUBSTRING(domains.name FROM '\.arpa$'), LENGTH(SUBSTRING(domains.name FROM '^[0-9]+')), domains.name"; + $natural_sort = "SUBSTRING($domains_table.name FROM '\.arpa$'), LENGTH(SUBSTRING($domains_table.name FROM '^[0-9]+')), $domains_table.name"; } - $sql_sortby = ($sortby == 'domains.name' ? $natural_sort : $sortby . ', ' . $natural_sort); + $sql_sortby = ($sortby == "$domains_table.name" ? $natural_sort : $sortby . ', ' . $natural_sort); - $query = "SELECT domains.id, - domains.name, - domains.type, - COUNT(records.id) AS count_records, + $query = "SELECT $domains_table.id, + $domains_table.name, + $domains_table.type, + COUNT($records_table.id) AS count_records, users.username, users.fullname - " . ($pdnssec_use ? ", COUNT(cryptokeys.id) > 0 OR COUNT(domainmetadata.id) > 0 AS secured" : "") . " + " . ($pdnssec_use ? ", COUNT($cryptokeys_table.id) > 0 OR COUNT($domainmetadata_table.id) > 0 AS secured" : "") . " " . ($iface_zone_comments ? ", zones.comment" : "") . " - FROM domains - LEFT JOIN zones ON domains.id=zones.domain_id - LEFT JOIN records ON records.domain_id=domains.id AND records.type IS NOT NULL + FROM $domains_table + LEFT JOIN zones ON $domains_table.id=zones.domain_id + LEFT JOIN $records_table ON $records_table.domain_id=$domains_table.id AND $records_table.type IS NOT NULL LEFT JOIN users ON users.id=zones.owner"; if ($pdnssec_use) { - $query .= " LEFT JOIN cryptokeys ON domains.id = cryptokeys.domain_id AND cryptokeys.active - LEFT JOIN domainmetadata ON domains.id = domainmetadata.domain_id AND domainmetadata.kind = 'PRESIGNED'"; + $query .= " LEFT JOIN $cryptokeys_table ON $domains_table.id = $cryptokeys_table.domain_id AND $cryptokeys_table.active + LEFT JOIN $domainmetadata_table ON $domains_table.id = $domainmetadata_table.domain_id AND $domainmetadata_table.kind = 'PRESIGNED'"; } $query .= " WHERE 1=1" . $sql_add . " - GROUP BY domains.name, domains.id, domains.type, users.username, users.fullname + GROUP BY $domains_table.name, $domains_table.id, $domains_table.type, users.username, users.fullname " . ($iface_zone_comments ? ", zones.comment" : "") . " ORDER BY " . $sql_sortby; @@ -1194,7 +1272,7 @@ public function get_zones(string $perm, int $userid = 0, string $letterstart = ' } if ($iface_zonelist_serial) { - $ret[$r["name"]]["serial"] = self::get_serial_by_zid($this->db, $r["id"]); + $ret[$r["name"]]["serial"] = $this->get_serial_by_zid($r["id"]); } if ($iface_zonelist_template) { @@ -1214,9 +1292,12 @@ public function get_zones(string $perm, int $userid = 0, string $letterstart = ' * * @return int Count of zones matched */ - public static function zone_count_ng($db, $db_type, string $perm, string $letterstart = 'all'): int + public static function zone_count_ng($db, $config, string $perm, string $letterstart = 'all'): int { - $tables = 'domains'; + $pdns_db_name = $config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $tables = $domains_table; $query_addon = ''; if ($perm != "own" && $perm != "all") { @@ -1224,18 +1305,19 @@ public static function zone_count_ng($db, $db_type, string $perm, string $letter } if ($perm == "own") { - $query_addon = " AND zones.domain_id = domains.id + $query_addon = " AND zones.domain_id = $domains_table.id AND zones.owner = " . $db->quote($_SESSION['userid'], 'integer'); $tables .= ', zones'; } if ($letterstart != 'all' && $letterstart != 1) { - $query_addon .= " AND domains.name LIKE " . $db->quote($letterstart . "%", 'text') . " "; + $query_addon .= " AND $domains_table.name LIKE " . $db->quote($letterstart . "%", 'text') . " "; } elseif ($letterstart == 1) { - $query_addon .= " AND " . DbCompat::substr($db_type) . "(domains.name,1,1) " . DbCompat::regexp($db_type) . " '[0-9]'"; + $query_addon .= " AND " . DbCompat::substr($config->get('db_type')) . "($domains_table.name,1,1) " . DbCompat::regexp($config->get('db_type')) . " '[0-9]'"; } - $query = "SELECT COUNT(domains.id) AS count_zones FROM $tables WHERE 1=1 $query_addon"; + + $query = "SELECT COUNT($domains_table.id) AS count_zones FROM $tables WHERE 1=1 $query_addon"; return $db->queryOne($query); } @@ -1247,9 +1329,12 @@ public static function zone_count_ng($db, $db_type, string $perm, string $letter * @param int $id Record ID * @return int|array array of record detail, or -1 if nothing found */ - public static function get_record_from_id($db, int $id): int|array + public function get_record_from_id(int $id): int|array { - $result = $db->queryRow("SELECT * FROM records WHERE id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL"); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $result = $this->db->queryRow("SELECT * FROM $records_table WHERE id=" . $this->db->quote($id, 'integer') . " AND type IS NOT NULL"); if ($result) { if ($result["type"] == "" || $result["content"] == "") { return -1; @@ -1283,7 +1368,7 @@ public static function get_record_from_id($db, int $id): int|array * * @return int|array array of record detail, or -1 if nothing found */ - public static function get_records_from_domain_id($db, $db_type, int $id, int $rowstart = 0, int $rowamount = 999999, string $sortby = 'name'): array|int + public function get_records_from_domain_id($db_type, int $id, int $rowstart = 0, int $rowamount = 999999, string $sortby = 'name'): array|int { if (!is_numeric($id)) { $error = new ErrorMessage(sprintf(_('Invalid argument(s) given to function %s'), "get_records_from_domain_id")); @@ -1293,18 +1378,21 @@ public static function get_records_from_domain_id($db, $db_type, int $id, int $r return -1; } - $db->setLimit($rowamount, $rowstart); - $natural_sort = 'records.name'; + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $this->db->setLimit($rowamount, $rowstart); + $natural_sort = "$records_table.name"; if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'sqlite' || $db_type == 'sqlite3') { - $natural_sort = 'records.name+0<>0 DESC, records.name+0, records.name'; + $natural_sort = "$records_table.name+0<>0 DESC, $records_table.name+0, $records_table.name"; } $sql_sortby = ($sortby == 'name' ? $natural_sort : $sortby . ', ' . $natural_sort); - $records = $db->query("SELECT * - FROM records - WHERE domain_id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL + $records = $this->db->query("SELECT * + FROM $records_table + WHERE domain_id=" . $this->db->quote($id, 'integer') . " AND type IS NOT NULL ORDER BY type = 'SOA' DESC, type = 'NS' DESC," . $sql_sortby); - $db->setLimit(0); + $this->db->setLimit(0); if ($records) { $result = $records->fetchAll(); @@ -1487,9 +1575,12 @@ public static function get_users_from_domain_id($db, int $id): array * * @return string Domain Type [NATIVE,MASTER,SLAVE] */ - public static function get_domain_type($db, int $id): string + public function get_domain_type(int $id): string { - $type = $db->queryOne("SELECT type FROM domains WHERE id = " . $db->quote($id, 'integer')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $type = $this->db->queryOne("SELECT type FROM $domains_table WHERE id = " . $this->db->quote($id, 'integer')); if ($type == "") { $type = "NATIVE"; } @@ -1502,9 +1593,11 @@ public static function get_domain_type($db, int $id): string * * @return array|bool|void Master server */ - public static function get_domain_slave_master($db, int $id) + public function get_domain_slave_master(int $id) { - return $db->queryOne("SELECT master FROM domains WHERE type = 'SLAVE' and id = " . $db->quote($id, 'integer')); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + return $this->db->queryOne("SELECT master FROM $domains_table WHERE type = 'SLAVE' and id = " . $this->db->quote($id, 'integer')); } /** Change Zone Type @@ -1515,8 +1608,11 @@ public static function get_domain_slave_master($db, int $id) * * @return void */ - public static function change_zone_type($db, string $type, int $id): void + public function change_zone_type(string $type, int $id): void { + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $add = ''; $params = array(':type' => $type, ':id' => $id); @@ -1528,8 +1624,8 @@ public static function change_zone_type($db, string $type, int $id): void $add = ", master = :master"; $params[':master'] = ''; } - $query = "UPDATE domains SET type = :type" . $add . " WHERE id = :id"; - $stmt = $db->prepare($query); + $query = "UPDATE $domains_table SET type = :type" . $add . " WHERE id = :id"; + $stmt = $this->db->prepare($query); $stmt->execute($params); } @@ -1541,10 +1637,13 @@ public static function change_zone_type($db, string $type, int $id): void * * @return null */ - public static function change_zone_slave_master($db, int $zone_id, string $ip_slave_master) + public function change_zone_slave_master(int $zone_id, string $ip_slave_master) { if (Dns::are_multiple_valid_ips($ip_slave_master)) { - $stmt = $db->prepare("UPDATE domains SET master = ? WHERE id = ?"); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + + $stmt = $this->db->prepare("UPDATE $domains_table SET master = ? WHERE id = ?"); $stmt->execute(array($ip_slave_master, $zone_id)); } else { $error = new ErrorMessage(sprintf(_('Invalid argument(s) given to function %s %s'), "change_zone_slave_master", "This is not a valid IPv4 or IPv6 address: $ip_slave_master")); @@ -1555,15 +1654,17 @@ public static function change_zone_slave_master($db, int $zone_id, string $ip_sl /** Get Serial for Zone ID * - * @param $db * @param int $zid Zone ID * * @return string Serial Number or false if not found */ - public static function get_serial_by_zid($db, int $zid): string + public function get_serial_by_zid(int $zid): string { - $query = "SELECT content FROM records where TYPE = " . $db->quote('SOA', 'text') . " and domain_id = " . $db->quote($zid, 'integer'); - $rr_soa = $db->queryOne($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT content FROM $records_table where TYPE = " . $this->db->quote('SOA', 'text') . " and domain_id = " . $this->db->quote($zid, 'integer'); + $rr_soa = $this->db->queryOne($query); $rr_soa_fields = explode(" ", $rr_soa); return $rr_soa_fields[2] ?? ''; } @@ -1616,17 +1717,20 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_ $zone_slave_add = "1"; } - $soa_rec = self::get_soa_record($this->db, $zone_id); + $soa_rec = $this->get_soa_record($zone_id); $this->db->beginTransaction(); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + if ($zone_template_id != 0) { if ($perm_edit == "all" || ($perm_edit == "own" && $user_is_zone_owner == "1")) { if ($db_type == 'pgsql') { - $query = "DELETE FROM records r USING records_zone_templ rzt WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id AND r.id = rzt.record_id"; + $query = "DELETE FROM $records_table r USING records_zone_templ rzt WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id AND r.id = rzt.record_id"; } else if ($db_type == 'sqlite' || $db_type == 'sqlite3') { - $query = "DELETE FROM records WHERE id IN (SELECT r.id FROM records r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id)"; + $query = "DELETE FROM $records_table WHERE id IN (SELECT r.id FROM $records_table r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id)"; } else { - $query = "DELETE r, rzt FROM records r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id"; + $query = "DELETE r, rzt FROM $records_table r LEFT JOIN records_zone_templ rzt ON r.id = rzt.record_id WHERE rzt.domain_id = :zone_id AND rzt.zone_templ_id = :zone_template_id"; } $stmt = $this->db->prepare($query); $stmt->execute(array(':zone_id' => $zone_id, ':zone_template_id' => $zone_template_id)); @@ -1636,17 +1740,17 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_ $errorPresenter->present($error); } if ($zone_master_add == "1" || $zone_slave_add == "1") { - $domain = self::get_domain_name_by_id($this->db, $zone_id); + $domain = $this->get_domain_name_by_id($zone_id); $templ_records = ZoneTemplate::get_zone_templ_records($this->db, $zone_template_id); foreach ($templ_records as $r) { //fixme: appears to be a bug and regex match should occur against $domain if ((preg_match('/in-addr.arpa/i', $zone_id) && ($r["type"] == "NS" || $r["type"] == "SOA")) || (!preg_match('/in-addr.arpa/i', $zone_id))) { - $zoneTemplate = new ZoneTemplate(); + $zoneTemplate = new ZoneTemplate($this->db, $this->config); $name = $zoneTemplate->parse_template_value($r["name"], $domain); $type = $r["type"]; if ($type == "SOA") { - $this->db->exec("DELETE FROM records WHERE domain_id = " . $this->db->quote($zone_id, 'integer') . " AND type = 'SOA'"); + $this->db->exec("DELETE FROM $records_table WHERE domain_id = " . $this->db->quote($zone_id, 'integer') . " AND type = 'SOA'"); $content = $this->get_updated_soa_record($soa_rec); if ($content == "") { $content = $zoneTemplate->parse_template_value($r["content"], $domain); @@ -1662,7 +1766,7 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_ $ttl = $dns_ttl; } - $query = "INSERT INTO records (domain_id, name, type, content, ttl, prio) VALUES (" + $query = "INSERT INTO $records_table (domain_id, name, type, content, ttl, prio) VALUES (" . $this->db->quote($zone_id, 'integer') . "," . $this->db->quote($name, 'text') . "," . $this->db->quote($type, 'text') . "," @@ -1706,6 +1810,9 @@ public function update_zone_records($db_type, $dns_ttl, int $zone_id, int $zone_ public function delete_domains(array $domains): bool { $pdnssec_use = $this->config->get('pdnssec_use'); + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? "$pdns_db_name.domains" : "domains"; + $records_table = $pdns_db_name ? "$pdns_db_name.records" : "records"; $this->db->beginTransaction(); @@ -1715,7 +1822,7 @@ public function delete_domains(array $domains): bool if ($perm_edit == "all" || ($perm_edit == "own" && $user_is_zone_owner == "1")) { if (is_numeric($id)) { - $zone_type = self::get_domain_type($this->db, $id); + $zone_type = $this->get_domain_type($id); if ($pdnssec_use && $zone_type == 'MASTER') { $pdns_api_url = $this->config->get('pdns_api_url'); $pdns_api_key = $this->config->get('pdns_api_key'); @@ -1725,16 +1832,17 @@ public function delete_domains(array $domains): bool new FakeConfiguration($pdns_api_url, $pdns_api_key) ); - $zone_name = DnsRecord::get_domain_name_by_id($this->db, $id); - if ($dnssecProvider->isZoneSecured($zone_name)) { + $dnsRecord = new DnsRecord($this->db, $this->config); + $zone_name = $dnsRecord->get_domain_name_by_id($id); + if ($dnssecProvider->isZoneSecured($zone_name, $this->config)) { $dnssecProvider->unsecureZone($zone_name); } } $this->db->exec("DELETE FROM zones WHERE domain_id=" . $this->db->quote($id, 'integer')); - $this->db->exec("DELETE FROM records WHERE domain_id=" . $this->db->quote($id, 'integer')); + $this->db->exec("DELETE FROM $records_table WHERE domain_id=" . $this->db->quote($id, 'integer')); $this->db->query("DELETE FROM records_zone_templ WHERE domain_id=" . $this->db->quote($id, 'integer')); - $this->db->exec("DELETE FROM domains WHERE id=" . $this->db->quote($id, 'integer')); + $this->db->exec("DELETE FROM $domains_table WHERE id=" . $this->db->quote($id, 'integer')); } else { $error = new ErrorMessage(sprintf(_('Invalid argument(s) given to function %s %s'), "delete_domains", "id must be a number")); $errorPresenter = new ErrorPresenter(); @@ -1758,10 +1866,13 @@ public function delete_domains(array $domains): bool * * @return boolean true on success, false on failure */ - public static function record_name_exists($db, string $name): bool + public function record_name_exists(string $name): bool { - $query = "SELECT COUNT(id) FROM records WHERE name = " . $db->quote($name, 'text'); - $count = $db->queryOne($query); + $pdns_db_name = $this->config->get('pdns_db_name'); + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + + $query = "SELECT COUNT(id) FROM $records_table WHERE name = " . $this->db->quote($name, 'text'); + $count = $this->db->queryOne($query); return $count > 0; } diff --git a/lib/Domain/Dnssec/DnssecProvider.php b/lib/Domain/Dnssec/DnssecProvider.php index 6079a0d96..39ad7549b 100644 --- a/lib/Domain/Dnssec/DnssecProvider.php +++ b/lib/Domain/Dnssec/DnssecProvider.php @@ -26,7 +26,7 @@ interface DnssecProvider { public function rectifyZone(string $zoneName): bool; public function secureZone(string $zoneName): bool; public function unsecureZone(string $zoneName): bool; - public function isZoneSecured(string $zoneName): bool; + public function isZoneSecured(string $zoneName, $config): bool; public function getDsRecords(string $zoneName): array; public function getDnsKeyRecords(string $zoneName): array; public function activateZoneKey(string $zoneName, int $keyId): bool; diff --git a/lib/Infrastructure/Dnssec/DnsSecApiProvider.php b/lib/Infrastructure/Dnssec/DnsSecApiProvider.php index c00552e87..3d4d1fe19 100644 --- a/lib/Infrastructure/Dnssec/DnsSecApiProvider.php +++ b/lib/Infrastructure/Dnssec/DnsSecApiProvider.php @@ -83,7 +83,7 @@ public function unsecureZone(string $zoneName): bool return $result; } - public function isZoneSecured(string $zoneName): bool + public function isZoneSecured(string $zoneName, $config): bool { $zone = new Zone($zoneName); return $this->client->isZoneSecured($zone); diff --git a/lib/Infrastructure/Dnssec/PdnsUtilProvider.php b/lib/Infrastructure/Dnssec/PdnsUtilProvider.php index eaf5b3acd..e0bcc131f 100644 --- a/lib/Infrastructure/Dnssec/PdnsUtilProvider.php +++ b/lib/Infrastructure/Dnssec/PdnsUtilProvider.php @@ -184,16 +184,21 @@ public function unsecureZone(string $zoneName): bool return true; } - public function isZoneSecured(string $zoneName): bool + public function isZoneSecured(string $zoneName, $config): bool { + $pdns_db_name = $config->get('pdns_db_name'); + $cryptokeys_table = $pdns_db_name ? $pdns_db_name . '.cryptokeys' : 'cryptokeys'; + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $domainmetadata_table = $pdns_db_name ? $pdns_db_name . '.domainmetadata' : 'domainmetadata'; + $query = $this->db->prepare("SELECT - COUNT(cryptokeys.id) AS active_keys, - COUNT(domainmetadata.id) > 0 AS presigned - FROM domains - LEFT JOIN cryptokeys ON domains.id = cryptokeys.domain_id - LEFT JOIN domainmetadata ON domains.id = domainmetadata.domain_id AND domainmetadata.kind = 'PRESIGNED' - WHERE domains.name = ? - GROUP BY domains.id + COUNT($cryptokeys_table.id) AS active_keys, + COUNT($domainmetadata_table.id) > 0 AS presigned + FROM $domains_table + LEFT JOIN $cryptokeys_table ON $domains_table.id = $cryptokeys_table.domain_id + LEFT JOIN $domainmetadata_table ON $domains_table.id = $domainmetadata_table.domain_id AND $domainmetadata_table.kind = 'PRESIGNED' + WHERE $domains_table.name = ? + GROUP BY $domains_table.id "); $query->execute(array($zoneName)); $row = $query->fetch(); diff --git a/lib/Infrastructure/Repository/DbZoneRepository.php b/lib/Infrastructure/Repository/DbZoneRepository.php index afda73c42..c6472fd80 100644 --- a/lib/Infrastructure/Repository/DbZoneRepository.php +++ b/lib/Infrastructure/Repository/DbZoneRepository.php @@ -29,17 +29,21 @@ class DbZoneRepository implements ZoneRepositoryInterface { private object $db; private string $db_type; + private string $pdns_db_name; - public function __construct($db, $db_type) { + public function __construct($db, $config) { $this->db = $db; - $this->db_type = $db_type; + $this->db_type = $config->get('db_type'); + $this->pdns_db_name = $config->get('pdns_db_name'); } public function getDistinctStartingLetters(int $userId, bool $viewOthers): array { - $query = "SELECT DISTINCT " . DbCompat::substr($this->db_type) . "(domains.name, 1, 1) AS letter FROM domains"; + $domains_table = $this->pdns_db_name ? $this->pdns_db_name . '.domains' : 'domains'; + + $query = "SELECT DISTINCT " . DbCompat::substr($this->db_type) . "($domains_table.name, 1, 1) AS letter FROM $domains_table"; if (!$viewOthers) { - $query .= " LEFT JOIN zones ON domains.id = zones.domain_id"; + $query .= " LEFT JOIN zones ON $domains_table.id = zones.domain_id"; $query .= " WHERE zones.owner = :userId"; } diff --git a/lib/LegacyUsers.php b/lib/LegacyUsers.php index c39680bc7..e8ce74019 100644 --- a/lib/LegacyUsers.php +++ b/lib/LegacyUsers.php @@ -201,31 +201,31 @@ public static function user_exists($db, string $user): bool * * @return boolean true on success, false otherwise */ - public static function delete_user($db, int $uid, array $zones): bool + public function delete_user(int $uid, array $zones): bool { - if (($uid != $_SESSION ['userid'] && !self::verify_permission($db, 'user_edit_others')) || ($uid == $_SESSION ['userid'] && !self::verify_permission($db, 'user_edit_own'))) { + if (($uid != $_SESSION ['userid'] && !self::verify_permission($this->db, 'user_edit_others')) || ($uid == $_SESSION ['userid'] && !self::verify_permission($this->db, 'user_edit_own'))) { $error = new ErrorMessage(_("You do not have the permission to delete this user.")); $errorPresenter = new ErrorPresenter(); $errorPresenter->present($error); return false; } else { - + $dnsRecord = new DnsRecord($this->db, $this->config); foreach ($zones as $zone) { if ($zone ['target'] == "delete") { - DnsRecord::delete_domain($db, $zone ['zid']); + $dnsRecord->delete_domain($zone ['zid']); } elseif ($zone ['target'] == "new_owner") { - DnsRecord::add_owner_to_zone($db, $zone ['zid'], $zone ['newowner']); + DnsRecord::add_owner_to_zone($this->db, $zone ['zid'], $zone ['newowner']); } } - $query = "DELETE FROM zones WHERE owner = " . $db->quote($uid, 'integer'); - $db->query($query); + $query = "DELETE FROM zones WHERE owner = " . $this->db->quote($uid, 'integer'); + $this->db->query($query); - $query = "DELETE FROM users WHERE id = " . $db->quote($uid, 'integer'); - $db->query($query); + $query = "DELETE FROM users WHERE id = " . $this->db->quote($uid, 'integer'); + $this->db->query($query); - ZoneTemplate::delete_zone_templ_userid($db, $uid); + ZoneTemplate::delete_zone_templ_userid($this->db, $uid); } return true; } diff --git a/lib/RecordLog.php b/lib/RecordLog.php index 850b8ac11..76c6e1d10 100644 --- a/lib/RecordLog.php +++ b/lib/RecordLog.php @@ -32,9 +32,12 @@ class RecordLog private LegacyLogger $logger; private PDOLayer $db; - public function __construct($db) + private LegacyConfiguration $config; + + public function __construct($db, $config) { $this->db = $db; + $this->config = $config; $this->logger = new LegacyLogger($db); } @@ -51,7 +54,8 @@ public function log_after($rid): void private function getRecord($rid): array|int { - return DnsRecord::get_record_from_id($this->db, $rid); + $dnsRecord = new DnsRecord($this->db, $this->config); + return $dnsRecord->get_record_from_id($rid); } public function has_changed(array $record): bool diff --git a/lib/ZoneTemplate.php b/lib/ZoneTemplate.php index db7586592..cdd1bc984 100644 --- a/lib/ZoneTemplate.php +++ b/lib/ZoneTemplate.php @@ -36,10 +36,12 @@ class ZoneTemplate { private LegacyConfiguration $config; + private PDOLayer $db; - public function __construct() + public function __construct(PDOLayer $db, LegacyConfiguration $config) { - $this->config = new LegacyConfiguration(); + $this->db = $db; + $this->config = $config; } /** Get a list of all available zone templates @@ -467,30 +469,35 @@ public static function add_zone_templ_save_as($db, string $template_name, string * * @return array array of zones ids */ - public static function get_list_zone_use_templ($db, int $zone_templ_id, int $userid): array + public function get_list_zone_use_templ(int $zone_templ_id, int $userid): array { - $perm_edit = Permission::getEditPermission($db); + $perm_edit = Permission::getEditPermission($this->db); $sql_add = ''; + + $pdns_db_name = $this->config->get('pdns_db_name'); + $domains_table = $pdns_db_name ? $pdns_db_name . '.domains' : 'domains'; + $records_table = $pdns_db_name ? $pdns_db_name . '.records' : 'records'; + if ($perm_edit != "all") { - $sql_add = " AND zones.domain_id = domains.id - AND zones.owner = " . $db->quote($userid, 'integer'); + $sql_add = " AND zones.domain_id = $domains_table.id + AND zones.owner = " . $this->db->quote($userid, 'integer'); } - $query = "SELECT domains.id, - domains.name, - domains.type, + $query = "SELECT $domains_table.id, + $domains_table.name, + $domains_table.type, Record_Count.count_records - FROM domains - LEFT JOIN zones ON domains.id=zones.domain_id + FROM $domains_table + LEFT JOIN zones ON $domains_table.id=zones.domain_id LEFT JOIN ( - SELECT COUNT(domain_id) AS count_records, domain_id FROM records GROUP BY domain_id - ) Record_Count ON Record_Count.domain_id=domains.id + SELECT COUNT(domain_id) AS count_records, domain_id FROM $records_table GROUP BY domain_id + ) Record_Count ON Record_Count.domain_id=$domains_table.id WHERE 1=1" . $sql_add . " - AND zone_templ_id = " . $db->quote($zone_templ_id, 'integer') . " - GROUP BY domains.name, domains.id, domains.type, Record_Count.count_records"; + AND zone_templ_id = " . $this->db->quote($zone_templ_id, 'integer') . " + GROUP BY $domains_table.name, $domains_table.id, $domains_table.type, Record_Count.count_records"; - $result = $db->query($query); + $result = $this->db->query($query); $zone_list = array(); while ($zone = $result->fetch()) { diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index e2750bd63..cbd36fd50 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -114,6 +114,7 @@ 'Poweradmin\\Infrastructure\\Logger\\EchoLogger' => $baseDir . '/lib/Infrastructure/Logger/EchoLogger.php', 'Poweradmin\\Infrastructure\\Logger\\LoggerInterface' => $baseDir . '/lib/Infrastructure/Logger/LoggerInterface.php', 'Poweradmin\\Infrastructure\\Logger\\SyslogLogger' => $baseDir . '/lib/Infrastructure/Logger/SyslogLogger.php', + 'Poweradmin\\Infrastructure\\Repository\\DbPermissionTemplateRepository' => $baseDir . '/lib/Infrastructure/Repository/DbPermissionTemplateRepository.php', 'Poweradmin\\Infrastructure\\Repository\\DbUserRepository' => $baseDir . '/lib/Infrastructure/Repository/DbUserRepository.php', 'Poweradmin\\Infrastructure\\Repository\\DbZoneRepository' => $baseDir . '/lib/Infrastructure/Repository/DbZoneRepository.php', 'Poweradmin\\Infrastructure\\Repository\\LocaleRepository' => $baseDir . '/lib/Infrastructure/Repository/LocaleRepository.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 41dbc02ad..4867d0d1e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -191,6 +191,7 @@ class ComposerStaticInit02fd231869a48df50cb631d6580008da 'Poweradmin\\Infrastructure\\Logger\\EchoLogger' => __DIR__ . '/../..' . '/lib/Infrastructure/Logger/EchoLogger.php', 'Poweradmin\\Infrastructure\\Logger\\LoggerInterface' => __DIR__ . '/../..' . '/lib/Infrastructure/Logger/LoggerInterface.php', 'Poweradmin\\Infrastructure\\Logger\\SyslogLogger' => __DIR__ . '/../..' . '/lib/Infrastructure/Logger/SyslogLogger.php', + 'Poweradmin\\Infrastructure\\Repository\\DbPermissionTemplateRepository' => __DIR__ . '/../..' . '/lib/Infrastructure/Repository/DbPermissionTemplateRepository.php', 'Poweradmin\\Infrastructure\\Repository\\DbUserRepository' => __DIR__ . '/../..' . '/lib/Infrastructure/Repository/DbUserRepository.php', 'Poweradmin\\Infrastructure\\Repository\\DbZoneRepository' => __DIR__ . '/../..' . '/lib/Infrastructure/Repository/DbZoneRepository.php', 'Poweradmin\\Infrastructure\\Repository\\LocaleRepository' => __DIR__ . '/../..' . '/lib/Infrastructure/Repository/LocaleRepository.php', diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 60a0de838..9de6352b3 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'poweradmin/poweradmin', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '647ee9675f7849a1410b340801fe3dbdd000e03c', + 'reference' => '0e42297b510fa6337ae5ed7c52f85ab652fba303', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'poweradmin/poweradmin' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '647ee9675f7849a1410b340801fe3dbdd000e03c', + 'reference' => '0e42297b510fa6337ae5ed7c52f85ab652fba303', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),