From 2392e8768a592cb7c00b49a610ed739fe156a0a7 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Jan 2017 16:52:37 +0545 Subject: Add filter to WoL widget (cherry picked from commit d82c5cbf4f693d70e55b5a484a34ea84f88fa250) --- .../www/widgets/widgets/wake_on_lan.widget.php | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php index c1b1ded..9ed1de7 100644 --- a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php +++ b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php @@ -63,6 +63,29 @@ if (is_array($config['wol']['wolentry'])) { $wolcomputers = array(); } +// Constructs a unique key that will identify a WoL entry in the filter list. +function get_wolent_key($wolent) { + return ($wolent['interface'] . "|" . $wolent['mac']); +} + +if ($_POST) { + + $validNames = array(); + + foreach ($config['wol']['wolentry'] as $wolent) { + array_push($validNames, get_wolent_key($wolent)); + } + + if (is_array($_POST['show'])) { + $user_settings['widgets']['wol']['filter'] = implode(',', array_diff($validNames, $_POST['show'])); + } else { + $user_settings['widgets']['wol']['filter'] = ""; + } + + save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Wake on LAN Filter via Dashboard.")); + header("Location: /index.php"); +} + ?>
@@ -76,8 +99,14 @@ if (is_array($config['wol']['wolentry'])) { 0): foreach ($wolcomputers as $wolent): + if (in_array(get_wolent_key($wolent), $skipwols)) { + continue; + } + $is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'"); $status = exec("/usr/sbin/arp -an | /usr/bin/awk '$4 == \"{$wolent['mac']}\" { print $7 }'"); ?> @@ -114,3 +143,61 @@ endif;

+ +