Commit c7edcbf8 authored by Franco Fichtner's avatar Franco Fichtner

services: align the code some more, fix bugs #996

parent 9f8e2d67
...@@ -127,7 +127,7 @@ function dyndns_cache_file($conf, $ipver = 4) ...@@ -127,7 +127,7 @@ function dyndns_cache_file($conf, $ipver = 4)
{ {
$ipver = $ipver == 6 ? '_v6' : ''; $ipver = $ipver == 6 ? '_v6' : '';
return "/var/cache/dyndns_{$conf['interface']}_{$conf['host']}_{$dyndns['id']}{$ipver}.cache"; return "/var/cache/dyndns_{$conf['interface']}_{$conf['host']}_{$conf['id']}{$ipver}.cache";
} }
function dyndns_configure_client($conf) function dyndns_configure_client($conf)
......
...@@ -1252,7 +1252,7 @@ ...@@ -1252,7 +1252,7 @@
$currentTime = time(); $currentTime = time();
notify_all_remote(sprintf(gettext("Dynamic DNS updated IP Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip)); notify_all_remote(sprintf(gettext("Dynamic DNS updated IP Address on %s (%s) to %s"), convert_real_interface_to_friendly_descr($this->_if), $this->_if, $wan_ip));
log_error("Dynamic DNS: updating cache file {$this->_cacheFile}: {$wan_ip}"); log_error("Dynamic DNS: updating cache file {$this->_cacheFile}: {$wan_ip}");
@file_put_contents($this->_cacheFile, "{$wan_ip}:{$currentTime}"); @file_put_contents($this->_cacheFile, "{$wan_ip}|{$currentTime}");
} else } else
@unlink($this->_cacheFile); @unlink($this->_cacheFile);
if ($this->_useIPv6 == true && $wan_ip > 0) { if ($this->_useIPv6 == true && $wan_ip > 0) {
...@@ -1345,13 +1345,13 @@ ...@@ -1345,13 +1345,13 @@
} else { } else {
if (file_exists($this->_cacheFile)) { if (file_exists($this->_cacheFile)) {
$contents = file_get_contents($this->_cacheFile); $contents = file_get_contents($this->_cacheFile);
list($cacheIP,$cacheTime) = explode(':', $contents); list($cacheIP,$cacheTime) = explode('|', $contents);
$this->_debug($cacheIP.'/'.$cacheTime); $this->_debug($cacheIP.'/'.$cacheTime);
$initial = false; $initial = false;
$log_error .= "Cached IP: {$cacheIP} "; $log_error .= "Cached IP: {$cacheIP} ";
} else { } else {
$cacheIP = '0.0.0.0'; $cacheIP = '0.0.0.0';
@file_put_contents($this->_cacheFile, "0.0.0.0:{$currentTime}"); @file_put_contents($this->_cacheFile, "0.0.0.0|{$currentTime}");
$cacheTime = $currentTime; $cacheTime = $currentTime;
$initial = true; $initial = true;
$log_error .= "No Cached IP found."; $log_error .= "No Cached IP found.";
......
...@@ -84,7 +84,7 @@ function rfc2136_cron() ...@@ -84,7 +84,7 @@ function rfc2136_cron()
return $jobs; return $jobs;
} }
function rfc2136_cache_file($dnspdate, $ipver = 4) function rfc2136_cache_file($dnsupdate, $ipver = 4)
{ {
$ipver = $ipver == 6 ? '_v6' : ''; $ipver = $ipver == 6 ? '_v6' : '';
......
...@@ -162,7 +162,7 @@ $main_buttons = array( ...@@ -162,7 +162,7 @@ $main_buttons = array(
} }
if (!empty($fdata)) { if (!empty($fdata)) {
$cached_ip_s = explode(':', $fdata); $cached_ip_s = explode('|', $fdata);
$cached_ip = $cached_ip_s[0]; $cached_ip = $cached_ip_s[0];
echo sprintf( echo sprintf(
'<font color="%s">%s</font>', '<font color="%s">%s</font>',
......
...@@ -148,7 +148,7 @@ $main_buttons = array( ...@@ -148,7 +148,7 @@ $main_buttons = array(
<td> <td>
<?php <?php
$filename = rfc2136_cache_file($rfc2136, 4); $filename = rfc2136_cache_file($rfc2136, 4);
if (file_exists($filename) && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A')) { if (file_exists($filename) && !empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'A')) {
echo "IPv4: "; echo "IPv4: ";
if (isset($rfc2136['usepublicip'])) { if (isset($rfc2136['usepublicip'])) {
$ipaddr = get_dyndns_ip($rfc2136['interface'], 4); $ipaddr = get_dyndns_ip($rfc2136['interface'], 4);
...@@ -169,7 +169,7 @@ $main_buttons = array( ...@@ -169,7 +169,7 @@ $main_buttons = array(
} }
echo "<br />"; echo "<br />";
$filename6 = rfc2136_cache_file($rfc2136, 6); $filename6 = rfc2136_cache_file($rfc2136, 6);
if (file_exists($filename6) && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'AAAA')) { if (file_exists($filename6) && !empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'AAAA')) {
echo "IPv6: "; echo "IPv6: ";
if (isset($rfc2136['usepublicip'])) { if (isset($rfc2136['usepublicip'])) {
$ipaddr = get_dyndns_ip($rfc2136['interface'], 6); $ipaddr = get_dyndns_ip($rfc2136['interface'], 6);
......
...@@ -65,7 +65,7 @@ if (!empty($_REQUEST['getdyndnsstatus'])) { ...@@ -65,7 +65,7 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
} }
if (!empty($fdata)) { if (!empty($fdata)) {
$cached_ip_s = preg_split('/:/', $fdata); $cached_ip_s = explode('|', $fdata);
$cached_ip = $cached_ip_s[0]; $cached_ip = $cached_ip_s[0];
echo sprintf( echo sprintf(
'<font color="%s">%s</font>', '<font color="%s">%s</font>',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment