Commit 63a0231e authored by Franco Fichtner's avatar Franco Fichtner

dashboard: according to crash reoirts DynDNS widget can race

Fix a few style errors while there.
parent 4e83616c
...@@ -45,36 +45,38 @@ if (!empty($_REQUEST['getdyndnsstatus'])) { ...@@ -45,36 +45,38 @@ if (!empty($_REQUEST['getdyndnsstatus'])) {
if ($first_entry) { if ($first_entry) {
$first_entry = false; $first_entry = false;
} else { } else {
// Put a vertical bar delimiter between the echoed HTML for each entry processed. // Put a vertical bar delimiter between the echoed HTML for each entry processed.
echo "|"; echo '|';
} }
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache"; $filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
$filename_v6 = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache"; $filename_v6 = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
if (file_exists($filename) && !empty($dyndns['enable'])) { if (file_exists($filename) && !empty($dyndns['enable'])) {
$ipaddr = dyndnsCheckIP($dyndns['interface']); $ipaddr = dyndnsCheckIP($dyndns['interface']);
$cached_ip_s = preg_split('/:/', file_get_contents($filename)); $fdata = @file_get_contents($filename);
$cached_ip = $cached_ip_s[0]; if (!empty($fdata)) {
if ($ipaddr <> $cached_ip) { $cached_ip_s = preg_split('/:/', $fdata);
echo "<font color='red'>"; $cached_ip = $cached_ip_s[0];
} else { echo sprintf(
echo "<font color='green'>"; '<font color="%s">%s</font>',
$ipaddr != $cached_ip ? 'red' : 'green',
htmlspecialchars($cached_ip)
);
} }
echo htmlspecialchars($cached_ip);
echo "</font>";
} elseif (file_exists($filename_v6) && !empty($dyndns['enable'])) { } elseif (file_exists($filename_v6) && !empty($dyndns['enable'])) {
$ipv6addr = get_interface_ipv6($dyndns['interface']); $ipv6addr = get_interface_ipv6($dyndns['interface']);
$cached_ipv6_s = explode("|", file_get_contents($filename_v6)); $fdata6 = @file_get_contents($filename_v6);
$cached_ipv6 = $cached_ipv6_s[0]; if (!empty($fdata6)) {
if ($ipv6addr <> $cached_ipv6) { $cached_ipv6_s = explode('|', $fdata6);
echo "<font color='red'>"; $cached_ipv6 = $cached_ipv6_s[0];
} else { echo sprintf(
echo "<font color='green'>"; '<font color="%s">%s</font>',
$ipv6addr != $cached_ipv6 ? 'red' : 'green',
htmlspecialchars($cached_ipv6)
);
} }
echo htmlspecialchars($cached_ipv6);
echo "</font>";
} else { } else {
echo '<span class="text-muted">' . gettext('N/A') . '</span>'; echo sprintf('<span class="text-muted">%s</span>', gettext('N/A'));
} }
} }
exit; exit;
......
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