summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2013-03-20 20:04:33 +0545
committerPhil Davis <phil.davis@world.inf.org>2013-03-20 20:04:33 +0545
commitc1dcb7abe7ed1bfb4ac1e00f16eb47e7887ccf8f (patch)
tree75d3a758416e7846c861428643b1309f46437f0c /usr/local/www
parentccc5f959ada7ff3a2432d85566bb775d600704a9 (diff)
downloadpfsense-c1dcb7abe7ed1bfb4ac1e00f16eb47e7887ccf8f.zip
pfsense-c1dcb7abe7ed1bfb4ac1e00f16eb47e7887ccf8f.tar.gz
DynDNS status widget async update
The Dynamic DNS status widget performs remote operations to the www to check the cached dynamic DNS IP against the actual current public-facing IP. When an external link is slow, or particularly when the cable is plugged in (it seems up) but actually the internet is down, it takes a long time for a response from http://checkip.dyndns.com/ to time out. The dashboard page hangs in a half-drawn state (up to drawing the DynDNS status table) for up to 30 seconds. This change puts the code that does these external operations into some ajax/Java script that runs after the dashboard has drawn up. Code concept unashamedly stolen from the system information widget.
Diffstat (limited to 'usr/local/www')
-rw-r--r--usr/local/www/widgets/widgets/dyn_dns_status.widget.php74
1 files changed, 56 insertions, 18 deletions
diff --git a/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
index e177b8d..0c35e4e 100644
--- a/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
+++ b/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
@@ -1,8 +1,8 @@
<?php
/*
Original status page code from: services_dyndns.php
- Copyright (C) 2008 Ermal Lu\xe7i
- Edits to convert it to a widget: dyn_dns_status.php
+ Copyright (C) 2008 Ermal Luci
+ Edits to convert it to a widget: dyn_dns_status.widget.php
Copyright (C) 2013 Stanley P. Miller \ stan-qaz
All rights reserved.
@@ -44,6 +44,33 @@ if (!is_array($config['dyndnses']['dyndns']))
$a_dyndns = &$config['dyndnses']['dyndns'];
+if($_REQUEST['getdyndnsstatus']) {
+ $first_entry = true;
+ foreach ($a_dyndns as $dyndns) {
+ if ($first_entry)
+ $first_entry = false;
+ else
+ // Put a vertical bar delimiter between the echoed HTML for each entry processed.
+ echo "|";
+
+ $filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
+ if (file_exists($filename)) {
+ $ipaddr = dyndnsCheckIP($dyndns['interface']);
+ $cached_ip_s = split(":", file_get_contents($filename));
+ $cached_ip = $cached_ip_s[0];
+ if ($ipaddr <> $cached_ip)
+ echo "<font color='red'>";
+ else
+ echo "<font color='green'>";
+ echo htmlspecialchars($cached_ip);
+ echo "</font>";
+ } else {
+ echo "N/A";
+ }
+ }
+ exit;
+}
+
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -101,23 +128,34 @@ $a_dyndns = &$config['dyndnses']['dyndns'];
?>
</td>
<td class="listlr">
- <?php
- $filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
- if (file_exists($filename)) {
- $ipaddr = dyndnsCheckIP($dyndns['interface']);
- $cached_ip_s = split(":", file_get_contents($filename));
- $cached_ip = $cached_ip_s[0];
- if ($ipaddr <> $cached_ip)
- echo "<font color='red'>";
- else
- echo "<font color='green'>";
- echo htmlspecialchars($cached_ip);
- echo "</font>";
- } else {
- echo "N/A";
- }
- ?>
+ <div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div>
</td>
</tr>
<?php $i++; endforeach; ?>
</table>
+<script type="text/javascript">
+//<![CDATA[
+ function dyndns_getstatus() {
+ scroll(0,0);
+ var url = "/widgets/widgets/dyn_dns_status.widget.php";
+ var pars = 'getdyndnsstatus=yes';
+ jQuery.ajax(
+ url,
+ {
+ type: 'get',
+ data: pars,
+ complete: dyndnscallback
+ });
+ }
+ function dyndnscallback(transport) {
+ // The server returns a string of statuses separated by vertical bars
+ var responseStrings = transport.responseText.split("|");
+ for (var count=0; count<responseStrings.length; count++)
+ {
+ var divlabel = '#dyndnsstatus' + count;
+ jQuery(divlabel).prop('innerHTML',responseStrings[count]);
+ }
+ }
+ setTimeout('dyndns_getstatus()', 2000);
+//]]>
+</script>
OpenPOWER on IntegriCloud