Commit 4e6d9e24 authored by Ad Schellevis's avatar Ad Schellevis

(dashboard) cleanup dyn_dns_status.widget.php

parent 6228e77d
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2008 Ermal Luci Copyright (C) 2008 Ermal Luci
Copyright (C) 2013 Stanley P. Miller \ stan-qaz Copyright (C) 2013 Stanley P. Miller \ stan-qaz
All rights reserved. All rights reserved.
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("widgets/include/dyn_dns_status.inc"); require_once("widgets/include/dyn_dns_status.inc");
...@@ -42,7 +40,7 @@ if (!isset($config['dyndnses']['dyndns'])) { ...@@ -42,7 +40,7 @@ if (!isset($config['dyndnses']['dyndns'])) {
$a_dyndns = &$config['dyndnses']['dyndns']; $a_dyndns = &$config['dyndnses']['dyndns'];
if ($_REQUEST['getdyndnsstatus']) { if (!empty($_REQUEST['getdyndnsstatus'])) {
$first_entry = true; $first_entry = true;
foreach ($a_dyndns as $dyndns) { foreach ($a_dyndns as $dyndns) {
if ($first_entry) { if ($first_entry) {
...@@ -85,18 +83,22 @@ if ($_REQUEST['getdyndnsstatus']) { ...@@ -85,18 +83,22 @@ if ($_REQUEST['getdyndnsstatus']) {
?> ?>
<table class="table table-triped" width="100%" border="0" cellpadding="0" cellspacing="0"> <table class="table table-striped table-condensed">
<tr> <thead>
<td width="5%" class="listhdrr"><b><?=gettext("Int.");?></b></td> <th><?=gettext("Int.");?></th>
<td width="15%" class="listhdrr"><b><?=gettext("Service");?></b></td> <th><?=gettext("Service");?></th>
<td width="20%" class="listhdrr"><b><?=gettext("Hostname");?></b></td> <th><?=gettext("Hostname");?></th>
<td width="20%" class="listhdrr"><b><?=gettext("Cached IP");?></b></td> <th><?=gettext("Cached IP");?></th>
</tr> </thead>
<?php $i = 0; foreach ($a_dyndns as $dyndns) : <tbody>
?> <?php
<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'"> $iflist = get_configured_interface_with_descr();
<td class="listlr"> $types = services_dyndns_list();
<?php $iflist = get_configured_interface_with_descr(); $groupslist = return_gateway_groups_array();
foreach ($a_dyndns as $i => $dyndns) :?>
<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
<td>
<?php
foreach ($iflist as $if => $ifdesc) { foreach ($iflist as $if => $ifdesc) {
if ($dyndns['interface'] == $if) { if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable'])) { if (!isset($dyndns['enable'])) {
...@@ -107,7 +109,6 @@ if ($_REQUEST['getdyndnsstatus']) { ...@@ -107,7 +109,6 @@ if ($_REQUEST['getdyndnsstatus']) {
break; break;
} }
} }
$groupslist = return_gateway_groups_array();
foreach ($groupslist as $if => $group) { foreach ($groupslist as $if => $group) {
if ($dyndns['interface'] == $if) { if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable'])) { if (!isset($dyndns['enable'])) {
...@@ -117,12 +118,10 @@ if ($_REQUEST['getdyndnsstatus']) { ...@@ -117,12 +118,10 @@ if ($_REQUEST['getdyndnsstatus']) {
} }
break; break;
} }
} }?>
?> </td>
</td> <td>
<td class="listr"> <?php
<?php
$types = services_dyndns_list();
if (isset($types[$dyndns['type']])) { if (isset($types[$dyndns['type']])) {
if (!isset($dyndns['enable'])) { if (!isset($dyndns['enable'])) {
echo '<span class="text-muted">' . htmlspecialchars($types[$dyndns['type']]) . '</span>'; echo '<span class="text-muted">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
...@@ -130,51 +129,46 @@ if ($_REQUEST['getdyndnsstatus']) { ...@@ -130,51 +129,46 @@ if ($_REQUEST['getdyndnsstatus']) {
echo htmlspecialchars($types[$dyndns['type']]); echo htmlspecialchars($types[$dyndns['type']]);
} }
} }
?> ?>
</td> </td>
<td class="listr"> <td>
<?php <?php
if (!isset($dyndns['enable'])) { if (!isset($dyndns['enable'])) {
echo "<span class=\"text-muted\">".htmlspecialchars($dyndns['host'])."</span>"; echo "<span class=\"text-muted\">".htmlspecialchars($dyndns['host'])."</span>";
} else { } else {
echo htmlspecialchars($dyndns['host']); echo htmlspecialchars($dyndns['host']);
} }
?> ?>
</td> </td>
<td class="listr"> <td>
<div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div> <div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div>
</td> </td>
</tr> </tr>
<?php $i++; <?php
endforeach;?>
endforeach; ?> </tbody>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ function dyndns_getstatus()
function dyndns_getstatus() { {
scroll(0,0); scroll(0,0);
var url = "/widgets/widgets/dyn_dns_status.widget.php"; var url = "/widgets/widgets/dyn_dns_status.widget.php";
var pars = 'getdyndnsstatus=yes'; var pars = 'getdyndnsstatus=yes';
jQuery.ajax( jQuery.ajax(url, {type: 'get', data: pars, complete: dyndnscallback});
url, // Refresh the status every 5 minutes
{ setTimeout('dyndns_getstatus()', 5*60*1000);
type: 'get', }
data: pars, function dyndnscallback(transport)
complete: dyndnscallback {
}); // The server returns a string of statuses separated by vertical bars
// Refresh the status every 5 minutes var responseStrings = transport.responseText.split("|");
setTimeout('dyndns_getstatus()', 5*60*1000); for (var count=0; count<responseStrings.length; count++) {
} var divlabel = '#dyndnsstatus' + count;
function dyndnscallback(transport) { jQuery(divlabel).prop('innerHTML',responseStrings[count]);
// The server returns a string of statuses separated by vertical bars }
var responseStrings = transport.responseText.split("|"); }
for (var count=0; count<responseStrings.length; count++) $( document ).ready(function() {
{ // Do the first status check 2 seconds after the dashboard opens
var divlabel = '#dyndnsstatus' + count; setTimeout('dyndns_getstatus()', 2000);
jQuery(divlabel).prop('innerHTML',responseStrings[count]); });
}
}
// Do the first status check 2 seconds after the dashboard opens
setTimeout('dyndns_getstatus()', 2000);
//]]>
</script> </script>
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