Commit 8a6f8559 authored by Ad Schellevis's avatar Ad Schellevis

(dashboard, widgets) refactor wake_on_lan.widget.php

parent 686378d9
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2010 Yehuda Katz Copyright (C) 2010 Yehuda Katz
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("widgets/include/wake_on_lan.inc"); require_once("widgets/include/wake_on_lan.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
...@@ -39,42 +37,44 @@ if (isset($config['wol']['wolentry'])) { ...@@ -39,42 +37,44 @@ if (isset($config['wol']['wolentry'])) {
} }
?> ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status"> <table class="table table-striped table-condensed">
<thead>
<tr> <tr>
<?php <th><?=gettext("Computer / Device");?></th>
echo '<td class="widgetsubheader" align="center">' . gettext("Computer / Device") . '</td>'; <th><?=gettext("Interface");?></th>
echo '<td class="widgetsubheader" align="center">' . gettext("Interface") . '</td>'; <th><?=gettext("Status");?></th>
echo '<td class="widgetsubheader" align="center">' . gettext("Status") . '</td>'; <th></th>
?>
<td class="widgetsubheader">&nbsp;</td>
</tr> </tr>
</thead>
<tbody>
<?php <?php
foreach ($wolcomputers as $wolent):
if (count($wolcomputers) > 0) { $is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");?>
foreach ($wolcomputers as $wolent) { <tr>
echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n"; <td><?=$wolent['descr'];?><br/><?=$wolent['mac'];?></td>
echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n"; <td><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($wolent['interface']));?></td>
<td>
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'"); <span class="glyphicon glyphicon-<?=$is_active == 1 ? "play" : "remove";?> text-<?=$is_active == 1 ? "success" : "danger";?>" ></span>
if ($is_active == 1) { <?=$is_active == 1 ? gettext("Online") : gettext("Offline");?>
echo '<td class="listr" align="center">' . "\n"; </td>
echo "<span class=\"glyphicon glyphicon-play text-success\" alt=\"pass\" ></span> " . gettext("Online") . "</td>\n"; <td>
} else { <a href="services_wol.php?mac=<?=$wolent['mac'];?>&if=<?=$wolent['interface'];?>">
echo '<td class="listbg" align="center">' . "\n"; <span class="glyphicon glyphicon-flash" title="<?=gettext("Wake Up");?>"></span>
echo "<span class=\"glyphicon glyphicon-remove text-danger\" alt=\"block\" ></span> " . gettext("Offline") . "</td>\n"; </a>
} </td>
echo '<td valign="middle" class="list nowrap">'; </tr>
/*if($is_active) { */ <?php
/* Will always show wake-up button even if the code thinks it is awake */ endforeach;
/* } else { */ if (count($wolcomputers) == 0):?>
echo "<a href='services_wol.php?mac={$wolent['mac']}&amp;if={$wolent['interface']}'> "; <tr>
echo "<span class='glyphicon glyphicon-flash' title='" . gettext("Wake Up") . "' border='0' alt='wol' ></span></a>\n"; <td colspan="4" ><?=gettext("No saved WoL addresses");?></td>
/* } */ </tr>
echo "</td></tr>\n"; <?php
} endif;?>
} else { </tbody>
echo "<tr><td colspan=\"4\" align=\"center\">" . gettext("No saved WoL addresses") . ".</td></tr>\n"; <tfoot>
} <tr>
?> <td colspan="4"><a href="status_dhcp_leases.php" class="navlink"><?= gettext('DHCP Leases Status') ?></a></td>
</tr>
</tfoot>
</table> </table>
<center><a href="status_dhcp_leases.php" class="navlink"><?= gettext('DHCP Leases Status') ?></a></center>
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