fixed zone handling and client updates

This commit is contained in:
Roland Gruber 2013-02-24 11:47:16 +00:00
parent d98db5d4b2
commit 1ab8b765a5
1 changed files with 21 additions and 5 deletions

View File

@ -316,7 +316,12 @@ class ddns extends baseModule {
// Zone inserted? // Zone inserted?
if (!empty($zone)) { 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 { else {
if (!empty($ip)) { if (!empty($ip)) {
@ -326,7 +331,12 @@ class ddns extends baseModule {
// Zone reverse inserted? // Zone reverse inserted?
if (!empty($zone_reverse)) { 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 { else {
if (!empty($ip)) { if (!empty($ip)) {
@ -424,9 +434,12 @@ class ddns extends baseModule {
*/ */
private function getDNSServer() { private function getDNSServer() {
$return = null; $return = null;
if (is_array($this->attributes['dhcpStatements'])) { if (isset($this->attributes['dhcpStatements'][0])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) {
if (substr($this->attributes['dhcpStatements'][$i], 0, 5) == 'zone ') { 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]); $parts = explode(". { primary ", $this->attributes['dhcpStatements'][$i]);
$temp = array_pop($parts); $temp = array_pop($parts);
$temp = explode(";", $temp); $temp = explode(";", $temp);
@ -541,7 +554,7 @@ class ddns extends baseModule {
$return = false; $return = false;
if (is_array($this->attributes['dhcpStatements'])) { if (is_array($this->attributes['dhcpStatements'])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { 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; $return = true;
break; break;
} }
@ -558,7 +571,10 @@ class ddns extends baseModule {
private function setIgnoreClientUpdates($ignore) { private function setIgnoreClientUpdates($ignore) {
if (is_array($this->attributes['dhcpStatements'])) { if (is_array($this->attributes['dhcpStatements'])) {
for ($i = 0; $i < sizeof($this->attributes['dhcpStatements']); $i++) { 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]); unset($this->attributes['dhcpStatements'][$i]);
$this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']); $this->attributes['dhcpStatements'] = array_values($this->attributes['dhcpStatements']);
} }