From 1ab8b765a5a97b5d67bbf678e0bcff053b8b4221 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 24 Feb 2013 11:47:16 +0000 Subject: [PATCH] fixed zone handling and client updates --- lam/lib/modules/ddns.inc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index e403817c..2f0427df 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -316,7 +316,12 @@ class ddns extends baseModule { // Zone inserted? if (!empty($zone)) { - $this->attributes['dhcpStatements'][] = "zone {$zone}. { primary {$ip}; key DHCP_UPDATER; }"; + if (!empty($ip)) { + $this->attributes['dhcpStatements'][] = "zone {$zone}. { primary {$ip}; key DHCP_UPDATER; }"; + } + else { + $this->attributes['dhcpStatements'][] = "zone {$zone}. { key DHCP_UPDATER; }"; + } } else { if (!empty($ip)) { @@ -326,7 +331,12 @@ class ddns extends baseModule { // Zone reverse inserted? if (!empty($zone_reverse)) { - $this->attributes['dhcpStatements'][] = "zone {$zone_reverse}. { primary {$ip}; key DHCP_UPDATER; }"; + if (!empty($ip)) { + $this->attributes['dhcpStatements'][] = "zone {$zone_reverse}. { primary {$ip}; key DHCP_UPDATER; }"; + } + else { + $this->attributes['dhcpStatements'][] = "zone {$zone_reverse}. { key DHCP_UPDATER; }"; + } } else { if (!empty($ip)) { @@ -424,9 +434,12 @@ class ddns extends baseModule { */ private function getDNSServer() { $return = null; - if (is_array($this->attributes['dhcpStatements'])) { + if (isset($this->attributes['dhcpStatements'][0])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { if (substr($this->attributes['dhcpStatements'][$i], 0, 5) == 'zone ') { + if (strpos($this->attributes['dhcpStatements'][$i], ' primary ') === false) { + continue; + } $parts = explode(". { primary ", $this->attributes['dhcpStatements'][$i]); $temp = array_pop($parts); $temp = explode(";", $temp); @@ -541,7 +554,7 @@ class ddns extends baseModule { $return = false; if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if ($this->attributes['dhcpStatements'][$i] == 'ignore client-updates') { + if (preg_replace('/[ ]+/', ' ', $this->attributes['dhcpStatements'][$i]) == 'ignore client-updates') { $return = true; break; } @@ -558,7 +571,10 @@ class ddns extends baseModule { private function setIgnoreClientUpdates($ignore) { if (is_array($this->attributes['dhcpStatements'])) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { - if ($this->attributes['dhcpStatements'][$i] == 'ignore client-updates') { + if (preg_replace('/[ ]+/', ' ', $this->attributes['dhcpStatements'][$i]) == 'ignore client-updates') { + if ($ignore) { + return; // option already set, no change + } unset($this->attributes['dhcpStatements'][$i]); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); }