summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-01-13 16:52:37 +0545
committerRenato Botelho <renato@netgate.com>2017-01-13 18:58:51 -0200
commit2392e8768a592cb7c00b49a610ed739fe156a0a7 (patch)
treee485832ff7f82fa2c49e62f7d9885d1366065557
parentd88f26df4d7c31393df082c6397e65e096e63a75 (diff)
downloadpfsense-2392e8768a592cb7c00b49a610ed739fe156a0a7.zip
pfsense-2392e8768a592cb7c00b49a610ed739fe156a0a7.tar.gz
Add filter to WoL widget
(cherry picked from commit d82c5cbf4f693d70e55b5a484a34ea84f88fa250)
-rw-r--r--src/usr/local/www/widgets/widgets/wake_on_lan.widget.php87
1 files changed, 87 insertions, 0 deletions
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");
+}
+
?>
<div class="table-responsive">
<table class="table table-hover table-striped table-condensed">
@@ -76,8 +99,14 @@ if (is_array($config['wol']['wolentry'])) {
</thead>
<tbody>
<?php
+$skipwols = explode(",", $user_settings['widgets']['wol']['filter']);
+
if (count($wolcomputers) > 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;
</table>
<p class="text-center"><a href="status_dhcp_leases.php" class="navlink"><?=gettext('DHCP Leases Status')?></a></p>
</div>
+<!-- close the body we're wrapped in and add a configuration-panel -->
+</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+
+<form action="/widgets/widgets/wake_on_lan.widget.php" method="post" class="form-horizontal">
+ <div class="panel panel-default col-sm-10">
+ <div class="panel-body">
+ <div class="table responsive">
+ <table class="table table-striped table-hover table-condensed">
+ <thead>
+ <tr>
+ <th><?=gettext("Description")?></th>
+ <th><?=gettext("Interface")?></th>
+ <th><?=gettext("MAC")?></th>
+ <th><?=gettext("Show")?></th>
+ </tr>
+ </thead>
+ <tbody>
+<?php
+ $skipwols = explode(",", $user_settings['widgets']['wol']['filter']);
+ $idx = 0;
+
+ foreach ($wolcomputers as $wolent):
+?>
+ <tr>
+ <td><?=$wolent['descr']?></td>
+ <td><?=convert_friendly_interface_to_friendly_descr($wolent['interface'])?></td>
+ <td><?=$wolent['mac']?></td>
+ <td class="col-sm-2"><input id="show[]" name ="show[]" value="<?=get_wolent_key($wolent)?>" type="checkbox" <?=(!in_array(get_wolent_key($wolent), $skipwols) ? 'checked':'')?>></td>
+ </tr>
+<?php
+ endforeach;
+?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-sm-offset-3 col-sm-6">
+ <button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
+ <button id="showallwols" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ </div>
+ </div>
+</form>
+
+<script>
+//<![CDATA[
+ events.push(function(){
+ $("#showallwols").click(function() {
+ $("[id^=show]").each(function() {
+ $(this).prop("checked", true);
+ });
+ });
+
+ });
+//]]>
+</script>
OpenPOWER on IntegriCloud