From 8cb35f8b02071937ec40a1b7ee2ce1ad880a080f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 20 Mar 2017 10:16:42 +0100 Subject: [PATCH] rfc2136: le widget! closes #996 --- plist | 2 + src/www/services_rfc2136.php | 4 +- src/www/widgets/include/rfc2136.inc | 4 + .../widgets/widgets/dyn_dns_status.widget.php | 44 ++--- src/www/widgets/widgets/rfc2136.widget.php | 168 ++++++++++++++++++ 5 files changed, 191 insertions(+), 31 deletions(-) create mode 100644 src/www/widgets/include/rfc2136.inc create mode 100644 src/www/widgets/widgets/rfc2136.widget.php diff --git a/plist b/plist index ef97afa8b..41a1c8ec3 100644 --- a/plist +++ b/plist @@ -1114,6 +1114,7 @@ /usr/local/www/widgets/include/log.inc /usr/local/www/widgets/include/ntp_status.inc /usr/local/www/widgets/include/openvpn.inc +/usr/local/www/widgets/include/rfc2136.inc /usr/local/www/widgets/include/services_status.inc /usr/local/www/widgets/include/system_log.inc /usr/local/www/widgets/include/thermal_sensors.inc @@ -1128,6 +1129,7 @@ /usr/local/www/widgets/widgets/ntp_status.widget.php /usr/local/www/widgets/widgets/openvpn.widget.php /usr/local/www/widgets/widgets/picture.widget.php +/usr/local/www/widgets/widgets/rfc2136.widget.php /usr/local/www/widgets/widgets/rss.widget.php /usr/local/www/widgets/widgets/services_status.widget.php /usr/local/www/widgets/widgets/system_information.widget.php diff --git a/src/www/services_rfc2136.php b/src/www/services_rfc2136.php index f62059177..f0587da89 100644 --- a/src/www/services_rfc2136.php +++ b/src/www/services_rfc2136.php @@ -165,7 +165,7 @@ $main_buttons = array( echo htmlspecialchars($cached_ip); echo ""; } else { - echo "IPv4: N/A"; + echo 'IPv4: ' . gettext('N/A'); } echo "
"; $filename6 = rfc2136_cache_file($rfc2136, 6); @@ -186,7 +186,7 @@ $main_buttons = array( echo htmlspecialchars($cached_ip); echo ""; } else { - echo "IPv6: N/A"; + echo 'IPv6: ' . gettext('N/A'); }?> diff --git a/src/www/widgets/include/rfc2136.inc b/src/www/widgets/include/rfc2136.inc new file mode 100644 index 000000000..c143db6dd --- /dev/null +++ b/src/www/widgets/include/rfc2136.inc @@ -0,0 +1,4 @@ +%s', gettext('N/A')); + echo gettext('N/A'); } } exit; @@ -92,7 +92,7 @@ if (!empty($_REQUEST['getdyndnsstatus'])) { - + @@ -105,51 +105,37 @@ if (!empty($_REQUEST['getdyndnsstatus'])) { $groupslist = return_gateway_groups_array(); foreach ($a_dyndns as $i => $dyndns) :?> - - - - + + Copyright (C) 2014-2016 Deciso B.V. + Copyright (C) 2008 Ermal Luci + Copyright (C) 2013 Stanley P. Miller \ stan-qaz + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once("guiconfig.inc"); +require_once("widgets/include/rfc2136.inc"); +require_once("services.inc"); +require_once("interfaces.inc"); +require_once("plugins.inc.d/rfc2136.inc"); + +if (!isset($config['dnsupdates']['dnsupdate'])) { + $config['dnsupdates']['dnsupdate'] = array(); +} + +$a_rfc2136 = &$config['dnsupdates']['dnsupdate']; + +if (!empty($_REQUEST['getrfc2136status'])) { + $first_entry = true; + foreach ($a_rfc2136 as $rfc2136) { + if ($first_entry) { + $first_entry = false; + } else { + // Put a vertical bar delimiter between the echoed HTML for each entry processed. + echo '|'; + } + + $filename = rfc2136_cache_file($rfc2136, 4); + $fdata = ''; + if (!empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'A') && file_exists($filename)) { + $ipaddr = get_dyndns_ip($rfc2136['interface'], 4); + $fdata = @file_get_contents($filename); + } + + $filename_v6 = rfc2136_cache_file($rfc2136, 6); + $fdata6 = ''; + if (!empty($rfc2136['enable']) && (empty($rfc2136['recordtype']) || $rfc2136['recordtype'] == 'AAAA') && file_exists($filename_v6)) { + $ipv6addr = get_dyndns_ip($rfc2136['interface'], 6); + $fdata6 = @file_get_contents($filename_v6); + } + + if (!empty($fdata)) { + $cached_ip_s = explode('|', $fdata); + $cached_ip = $cached_ip_s[0]; + echo sprintf( + 'IPv4: %s', + $ipaddr != $cached_ip ? 'red' : 'green', + htmlspecialchars($cached_ip) + ); + } else { + echo 'IPv4: ' . gettext('N/A'); + } + + echo '
'; + + if (!empty($fdata6)) { + $cached_ipv6_s = explode('|', $fdata6); + $cached_ipv6 = $cached_ipv6_s[0]; + echo sprintf( + 'IPv6: %s', + $ipv6addr != $cached_ipv6 ? 'red' : 'green', + htmlspecialchars($cached_ipv6) + ); + } else { + echo 'IPv6: ' . gettext('N/A'); + } + } + exit; +} + +?> + +
+ > $ifdesc) { if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) { - echo "{$ifdesc}"; - } else { - echo "{$ifdesc}"; - } + echo "{$ifdesc}"; break; } } foreach ($groupslist as $if => $group) { if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) { - echo "{$if}"; - } else { - echo "{$if}"; - } + echo "{$if}"; break; } }?> + > ' . htmlspecialchars($types[$dyndns['type']]) . ''; - } else { - echo htmlspecialchars($types[$dyndns['type']]); - } - } -?> - -".htmlspecialchars($dyndns['host']).""; + echo htmlspecialchars($types[$dyndns['type']]); } else { - echo htmlspecialchars($dyndns['host']); + echo htmlspecialchars($dyndns['type']); } ?> -
+
> + + > +
+ +
+ + + + + + + + + + $rfc2136) :?> + + + + + + + + +
> + $ifdesc) { + if ($rfc2136['interface'] == $if) { + echo "{$ifdesc}"; + break; + } + } + foreach ($groupslist as $if => $group) { + if ($rfc2136['interface'] == $if) { + echo "{$if}"; + break; + } + }?> + > + + > + + > +
+ +
+
+