summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2013-03-21 01:21:49 -0700
committerErmal Luçi <eri@pfsense.org>2013-03-21 01:21:49 -0700
commit4c15d00660d6ed9a919676968d4b929068ed81c0 (patch)
tree5e45160b7c473ce5d918b7d6880c7533a179758c
parent8f38fd8de9d0d3d9d662fa3896490bbec04fe4bd (diff)
parentb23e1a70346f3d98815ec3bfa0636e9ac8c4f28f (diff)
downloadpfsense-4c15d00660d6ed9a919676968d4b929068ed81c0.zip
pfsense-4c15d00660d6ed9a919676968d4b929068ed81c0.tar.gz
Merge pull request #488 from phil-davis/master
DynDNS status widget async update
-rw-r--r--usr/local/www/widgets/widgets/dyn_dns_status.widget.php77
1 files changed, 59 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..2ae268b 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 " . date("H:i:s");
+ }
+ }
+ exit;
+}
+
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -101,23 +128,37 @@ $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
+ });
+ // Refresh the status every 5 minutes
+ setTimeout('dyndns_getstatus()', 5*60*1000);
+ }
+ 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]);
+ }
+ }
+ // Do the first status check 2 seconds after the dashboard opens
+ setTimeout('dyndns_getstatus()', 2000);
+//]]>
+</script>
OpenPOWER on IntegriCloud