Private GIT

Skip to content
Snippets Groups Projects
Unverified Commit 91e22453 authored by GaryAllan's avatar GaryAllan Committed by GitHub
Browse files

Merge pull request #2509 from webmeisterei/fix_pdns_domain_for_hostname

Fixes pdns bug #1471 and #2374 by reverse compare the hostname with the domain.
parents af1e00b9 60e0cf5a
Branches
No related tags found
No related merge requests found
...@@ -50,15 +50,18 @@ else { ...@@ -50,15 +50,18 @@ else {
// fetch all domains // fetch all domains
$all_domains = $PowerDNS->fetch_all_domains (); $all_domains = $PowerDNS->fetch_all_domains ();
if ($all_domains!==false) { if ($all_domains!==false) {
// Reverse the hostname, this fixes #1471 and #2374
$r_hostname = implode(".", array_reverse(explode(".", $_POST['domain_id'])));
foreach($all_domains as $dk=>$domain_s) { foreach($all_domains as $dk=>$domain_s) {
// loop through and find all matches // Reverse the domain and compare it reversed, this fixes #1471 and #2374
if (strpos($_POST['domain_id'],$domain_s->name) !== false) { $r_domain = implode(".", array_reverse(explode(".", $domain_s->name)));
// check best match to avoid for example a.example.net.nz1 added to example.net.nz
if (substr($_POST['domain_id'], -strlen($domain_s->name)) === $domain_s->name) { if (substr($r_hostname, 0, strlen($r_domain)) == $r_domain) {
$matches[$dk] = $domain_s; $matches[$dk] = $domain_s;
} }
} }
}
// match found ? // match found ?
if (isset($matches)) { if (isset($matches)) {
foreach($matches as $k=>$m){ foreach($matches as $k=>$m){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment