Projet

Général

Profil

Télécharger (3,35 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / widgets / widgets / wake_on_lan.widget.php @ ad57eacf

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
$nocsrf = true;
29

    
30
require_once("guiconfig.inc");
31
require_once("/usr/local/www/widgets/include/wake_on_lan.inc");
32

    
33
if (is_array($config['wol']['wolentry']))
34
	$wolcomputers = $config['wol']['wolentry'];
35
else
36
	$wolcomputers = array();
37

    
38
?>
39
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status">
40
	<tr>
41
		<?php
42
		echo '<td class="widgetsubheader" align="center"><b>' . gettext("Computer / Device") . '</b></td>';
43
		echo '<td class="widgetsubheader" align="center"><b>' . gettext("Interface") . '</b></td>';
44
		echo '<td class="widgetsubheader" align="center"><b>' . gettext("Status") . '</b></td>';
45
		?>
46
		<td class="widgetsubheader">&nbsp;</td>
47
	</tr>
48
<?php
49

    
50
if (count($wolcomputers) > 0) {
51
	foreach($wolcomputers as $wolent) {
52
		echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
53
		echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n";
54
		
55
		$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
56
		if($is_active == 1) {
57
			echo '<td class="listr" align="center">' . "\n";
58
			echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\" alt=\"pass\" /> " . gettext("Online") . "</td>\n";
59
		} else {
60
			echo '<td class="listbg" align="center">' . "\n";
61
			echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\" alt=\"block\" />&nbsp;<font color=\"white\">" . gettext("Offline") . "</font></td>\n";
62
		}
63
		echo '<td valign="middle" class="list nowrap">';
64
		/*if($is_active) { */
65
			/* Will always show wake-up button even if pfsense thinks it is awake */
66
		/* } else { */
67
			echo "<a href='services_wol.php?mac={$wolent['mac']}&amp;if={$wolent['interface']}'> ";
68
			echo "<img title='" . gettext("Wake Up") . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_wol_all.gif' alt='wol' /></a>\n";
69
		/* } */
70
		echo "</td></tr>\n";
71
	}
72
} else {
73
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No saved WoL addresses") . ".</td></tr>\n";
74
}
75
?>
76
</table>
77
<center><a href="status_dhcp_leases.php" class="navlink">DHCP Leases Status</a></center>
(20-20/20)