1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
services_wol_edit.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
|
|
|
7 |
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: wol
|
33 |
|
|
*/
|
34 |
5b237745
|
Scott Ullrich
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-services-wakeonlan-edit
|
37 |
|
|
##|*NAME=Services: Wake on LAN: Edit page
|
38 |
|
|
##|*DESCR=Allow access to the 'Services: Wake on LAN: Edit' page.
|
39 |
|
|
##|*MATCH=services_wol_edit.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
4504a769
|
Ermal Lu?i
|
function wolcmp($a, $b) {
|
43 |
|
|
return strcmp($a['descr'], $b['descr']);
|
44 |
|
|
}
|
45 |
0d64af59
|
Ermal Lu?i
|
|
46 |
4504a769
|
Ermal Lu?i
|
function wol_sort() {
|
47 |
|
|
global $config;
|
48 |
0d64af59
|
Ermal Lu?i
|
|
49 |
|
|
usort($config['wol']['wolentry'], "wolcmp");
|
50 |
|
|
}
|
51 |
6b07c15a
|
Matthew Grooms
|
|
52 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
53 |
|
|
|
54 |
|
|
if (!is_array($config['wol']['wolentry'])) {
|
55 |
|
|
$config['wol']['wolentry'] = array();
|
56 |
|
|
}
|
57 |
|
|
$a_wol = &$config['wol']['wolentry'];
|
58 |
|
|
|
59 |
|
|
$id = $_GET['id'];
|
60 |
|
|
if (isset($_POST['id']))
|
61 |
|
|
$id = $_POST['id'];
|
62 |
|
|
|
63 |
|
|
if (isset($id) && $a_wol[$id]) {
|
64 |
|
|
$pconfig['interface'] = $a_wol[$id]['interface'];
|
65 |
|
|
$pconfig['mac'] = $a_wol[$id]['mac'];
|
66 |
|
|
$pconfig['descr'] = $a_wol[$id]['descr'];
|
67 |
|
|
}
|
68 |
7477df4f
|
Scott Ullrich
|
else
|
69 |
|
|
{
|
70 |
|
|
$pconfig['interface'] = $_GET['if'];
|
71 |
|
|
$pconfig['mac'] = $_GET['mac'];
|
72 |
|
|
$pconfig['descr'] = $_GET['descr'];
|
73 |
|
|
}
|
74 |
5b237745
|
Scott Ullrich
|
|
75 |
|
|
if ($_POST) {
|
76 |
|
|
|
77 |
|
|
unset($input_errors);
|
78 |
|
|
$pconfig = $_POST;
|
79 |
|
|
|
80 |
|
|
/* input validation */
|
81 |
|
|
$reqdfields = explode(" ", "interface mac");
|
82 |
593de5c8
|
Rafael Lucas
|
$reqdfieldsn = array(gettext("Interface"),gettext("MAC address"));
|
83 |
5b237745
|
Scott Ullrich
|
|
84 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
85 |
4f3401e0
|
Bill Marquette
|
|
86 |
|
|
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
|
87 |
|
|
$_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
|
88 |
5b237745
|
Scott Ullrich
|
|
89 |
|
|
if (($_POST['mac'] && !is_macaddr($_POST['mac']))) {
|
90 |
593de5c8
|
Rafael Lucas
|
$input_errors[] = gettext("A valid MAC address must be specified.");
|
91 |
5b237745
|
Scott Ullrich
|
}
|
92 |
|
|
|
93 |
|
|
if (!$input_errors) {
|
94 |
|
|
$wolent = array();
|
95 |
|
|
$wolent['interface'] = $_POST['interface'];
|
96 |
|
|
$wolent['mac'] = $_POST['mac'];
|
97 |
|
|
$wolent['descr'] = $_POST['descr'];
|
98 |
|
|
|
99 |
|
|
if (isset($id) && $a_wol[$id])
|
100 |
|
|
$a_wol[$id] = $wolent;
|
101 |
|
|
else
|
102 |
|
|
$a_wol[] = $wolent;
|
103 |
0e3aa71c
|
Erik Fonnesbeck
|
wol_sort();
|
104 |
5b237745
|
Scott Ullrich
|
|
105 |
|
|
write_config();
|
106 |
|
|
|
107 |
|
|
header("Location: services_wol.php");
|
108 |
|
|
exit;
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
4df96eff
|
Scott Ullrich
|
|
112 |
593de5c8
|
Rafael Lucas
|
$pgtitle = array(gettext("Services"),gettext("Wake on LAN"),gettext("Edit"));
|
113 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
114 |
|
|
|
115 |
5b237745
|
Scott Ullrich
|
?>
|
116 |
|
|
|
117 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
118 |
|
|
<?php include("fbegin.inc"); ?>
|
119 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
120 |
|
|
<form action="services_wol_edit.php" method="post" name="iform" id="iform">
|
121 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
122 |
56d4e7fb
|
Scott Ullrich
|
<tr>
|
123 |
593de5c8
|
Rafael Lucas
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit WOL entry");?></td>
|
124 |
56d4e7fb
|
Scott Ullrich
|
</tr>
|
125 |
5b237745
|
Scott Ullrich
|
<tr>
|
126 |
593de5c8
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
|
127 |
5b237745
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
128 |
|
|
<select name="interface" class="formfld">
|
129 |
e47499d5
|
Scott Ullrich
|
<?php
|
130 |
3e321df2
|
Ermal Luçi
|
$interfaces = get_configured_interface_with_descr();
|
131 |
5b237745
|
Scott Ullrich
|
foreach ($interfaces as $iface => $ifacename): ?>
|
132 |
7ec05d27
|
Ermal Luçi
|
<option value="<?=$iface;?>" <?php if (!link_interface_to_bridge($iface) && $iface == $pconfig['interface']) echo "selected"; ?>>
|
133 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars($ifacename);?>
|
134 |
|
|
</option>
|
135 |
|
|
<?php endforeach; ?>
|
136 |
|
|
</select> <br>
|
137 |
593de5c8
|
Rafael Lucas
|
<span class="vexpl"><?=gettext("Choose which interface this host is connected to.");?></span></td>
|
138 |
5b237745
|
Scott Ullrich
|
</tr>
|
139 |
|
|
<tr>
|
140 |
593de5c8
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("MAC address");?></td>
|
141 |
5b237745
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
142 |
|
|
<input name="mac" type="text" class="formfld" id="mac" size="20" value="<?=htmlspecialchars($pconfig['mac']);?>">
|
143 |
|
|
<br>
|
144 |
593de5c8
|
Rafael Lucas
|
<span class="vexpl"><?=gettext("Enter a MAC address in the following format: ".
|
145 |
|
|
"xx:xx:xx:xx:xx:xx");?><em></em></span></td>
|
146 |
5b237745
|
Scott Ullrich
|
</tr>
|
147 |
|
|
<tr>
|
148 |
593de5c8
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
149 |
5b237745
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
150 |
|
|
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
151 |
593de5c8
|
Rafael Lucas
|
<br> <span class="vexpl"><?=gettext("You may enter a description here".
|
152 |
|
|
" for your reference (not parsed).");?></span></td>
|
153 |
5b237745
|
Scott Ullrich
|
</tr>
|
154 |
|
|
<tr>
|
155 |
|
|
<td width="22%" valign="top"> </td>
|
156 |
|
|
<td width="78%">
|
157 |
593de5c8
|
Rafael Lucas
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>"> <input class="formbtn" type="button" value="<?=gettext("Cancel");?>" onclick="history.back()">
|
158 |
5b237745
|
Scott Ullrich
|
<?php if (isset($id) && $a_wol[$id]): ?>
|
159 |
225a2f0b
|
Scott Ullrich
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
|
160 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
161 |
|
|
</td>
|
162 |
|
|
</tr>
|
163 |
|
|
</table>
|
164 |
|
|
</form>
|
165 |
|
|
<?php include("fend.inc"); ?>
|
166 |
|
|
</body>
|
167 |
|
|
</html>
|