1
|
<?php
|
2
|
/*
|
3
|
wake_on_lan.widget.php
|
4
|
Copyright (C) 2010 Yehuda Katz
|
5
|
|
6
|
Redistribution and use in source and binary forms, with or without
|
7
|
modification, are permitted provided that the following conditions are met:
|
8
|
|
9
|
1. Redistributions of source code must retain the above copyright notice,
|
10
|
this list of conditions and the following disclaimer.
|
11
|
|
12
|
2. Redistributions in binary form must reproduce the above copyright
|
13
|
notice, this list of conditions and the following disclaimer in the
|
14
|
documentation and/or other materials provided with the distribution.
|
15
|
|
16
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
17
|
INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
18
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
19
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
20
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
POSSIBILITY OF SUCH DAMAGE.
|
26
|
*/
|
27
|
|
28
|
require_once("/usr/local/www/widgets/include/wake_on_lan.inc");
|
29
|
|
30
|
if (is_array($config['wol']['wolentry']))
|
31
|
$wolcomputers = $config['wol']['wolentry'];
|
32
|
else
|
33
|
$wolcomputers = array();
|
34
|
|
35
|
?>
|
36
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
37
|
<tr>
|
38
|
<?
|
39
|
echo '<td class="widgetsubheader"><b><center>' . gettext("Computer / Device") . '</center></b></td>';
|
40
|
echo '<td class="widgetsubheader"><b><center>' . gettext("Interface") . '</center></b></td>';
|
41
|
echo '<td class="widgetsubheader"><b><center>' . gettext("Status") . '</center></b></td>';
|
42
|
?>
|
43
|
<td class="widgetsubheader"> </td>
|
44
|
</tr>
|
45
|
<?php
|
46
|
|
47
|
if (count($wolcomputers) > 0) {
|
48
|
foreach($wolcomputers as $wolent) {
|
49
|
echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
|
50
|
$wolifname = $config['interfaces'][$wolent['interface']]['descr'];
|
51
|
if ( empty( $wolifname ) ){
|
52
|
$wolifname = ucase($wolent['interface']);
|
53
|
}
|
54
|
echo '<td class="listr">' . $wolifname . '</td>' . "\n";
|
55
|
|
56
|
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
|
57
|
if($is_active == 1) {
|
58
|
echo '<td class="listr"><center>' . "\n";
|
59
|
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\"> " . gettext("Online") . "</td>\n";
|
60
|
} else {
|
61
|
echo '<td class="listbg"><center>' . "\n";
|
62
|
echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> <font color=\"white\">" . gettext("Offline") . "</td>\n";
|
63
|
}
|
64
|
echo '<td valign="middle" class="list" nowrap>';
|
65
|
/*if($is_active) { */
|
66
|
/* Will always show wake-up button even if pfsense thinks it is awake */
|
67
|
/* } else { */
|
68
|
echo "<a href='services_wol.php?mac={$wolent['mac']}&if={$wolent['interface']}'> ";
|
69
|
echo "<img title='" . gettext("Wake Up") . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_wol_all.gif'></a>\n";
|
70
|
/* } */
|
71
|
echo "</td></tr>\n";
|
72
|
}
|
73
|
} else {
|
74
|
echo "<tr><td colspan=\"3\"><center>" . gettext("No saved WoL addresses") . ".</td></tr>\n";
|
75
|
}
|
76
|
?>
|
77
|
</table>
|