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 |
|
|
|
32 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
33 |
|
|
##|*IDENT=page-services-wakeonlan-edit
|
34 |
|
|
##|*NAME=Services: Wake on LAN: Edit page
|
35 |
|
|
##|*DESCR=Allow access to the 'Services: Wake on LAN: Edit' page.
|
36 |
|
|
##|*MATCH=services_wol_edit.php*
|
37 |
|
|
##|-PRIV
|
38 |
|
|
|
39 |
|
|
|
40 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
41 |
|
|
|
42 |
|
|
if (!is_array($config['wol']['wolentry'])) {
|
43 |
|
|
$config['wol']['wolentry'] = array();
|
44 |
|
|
}
|
45 |
|
|
wol_sort();
|
46 |
|
|
$a_wol = &$config['wol']['wolentry'];
|
47 |
|
|
|
48 |
|
|
$id = $_GET['id'];
|
49 |
|
|
if (isset($_POST['id']))
|
50 |
|
|
$id = $_POST['id'];
|
51 |
|
|
|
52 |
|
|
if (isset($id) && $a_wol[$id]) {
|
53 |
|
|
$pconfig['interface'] = $a_wol[$id]['interface'];
|
54 |
|
|
$pconfig['mac'] = $a_wol[$id]['mac'];
|
55 |
|
|
$pconfig['descr'] = $a_wol[$id]['descr'];
|
56 |
|
|
}
|
57 |
7477df4f
|
Scott Ullrich
|
else
|
58 |
|
|
{
|
59 |
|
|
$pconfig['interface'] = $_GET['if'];
|
60 |
|
|
$pconfig['mac'] = $_GET['mac'];
|
61 |
|
|
$pconfig['descr'] = $_GET['descr'];
|
62 |
|
|
}
|
63 |
5b237745
|
Scott Ullrich
|
|
64 |
|
|
if ($_POST) {
|
65 |
|
|
|
66 |
|
|
unset($input_errors);
|
67 |
|
|
$pconfig = $_POST;
|
68 |
|
|
|
69 |
|
|
/* input validation */
|
70 |
|
|
$reqdfields = explode(" ", "interface mac");
|
71 |
|
|
$reqdfieldsn = explode(",", "Interface,MAC address");
|
72 |
|
|
|
73 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
74 |
4f3401e0
|
Bill Marquette
|
|
75 |
|
|
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
|
76 |
|
|
$_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
|
77 |
5b237745
|
Scott Ullrich
|
|
78 |
|
|
if (($_POST['mac'] && !is_macaddr($_POST['mac']))) {
|
79 |
|
|
$input_errors[] = "A valid MAC address must be specified.";
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
if (!$input_errors) {
|
83 |
|
|
$wolent = array();
|
84 |
|
|
$wolent['interface'] = $_POST['interface'];
|
85 |
|
|
$wolent['mac'] = $_POST['mac'];
|
86 |
|
|
$wolent['descr'] = $_POST['descr'];
|
87 |
|
|
|
88 |
|
|
if (isset($id) && $a_wol[$id])
|
89 |
|
|
$a_wol[$id] = $wolent;
|
90 |
|
|
else
|
91 |
|
|
$a_wol[] = $wolent;
|
92 |
|
|
|
93 |
|
|
write_config();
|
94 |
|
|
|
95 |
|
|
header("Location: services_wol.php");
|
96 |
|
|
exit;
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
4df96eff
|
Scott Ullrich
|
|
100 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("Services","Wake on LAN","Edit");
|
101 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
102 |
|
|
|
103 |
5b237745
|
Scott Ullrich
|
?>
|
104 |
|
|
|
105 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
106 |
|
|
<?php include("fbegin.inc"); ?>
|
107 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
108 |
|
|
<form action="services_wol_edit.php" method="post" name="iform" id="iform">
|
109 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
110 |
56d4e7fb
|
Scott Ullrich
|
<tr>
|
111 |
|
|
<td colspan="2" valign="top" class="listtopic">Edit WOL entry</td>
|
112 |
|
|
</tr>
|
113 |
5b237745
|
Scott Ullrich
|
<tr>
|
114 |
|
|
<td width="22%" valign="top" class="vncellreq">Interface</td>
|
115 |
|
|
<td width="78%" class="vtable">
|
116 |
|
|
<select name="interface" class="formfld">
|
117 |
e47499d5
|
Scott Ullrich
|
<?php
|
118 |
3e321df2
|
Ermal Luçi
|
$interfaces = get_configured_interface_with_descr();
|
119 |
5b237745
|
Scott Ullrich
|
foreach ($interfaces as $iface => $ifacename): ?>
|
120 |
74d65827
|
Ermal Luçi
|
<option value="<?=$iface;?>" <?php if (!link_int_to_bridge_interface($iface) && $iface == $pconfig['interface']) echo "selected"; ?>>
|
121 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars($ifacename);?>
|
122 |
|
|
</option>
|
123 |
|
|
<?php endforeach; ?>
|
124 |
|
|
</select> <br>
|
125 |
|
|
<span class="vexpl">Choose which interface this host is connected to.</span></td>
|
126 |
|
|
</tr>
|
127 |
|
|
<tr>
|
128 |
|
|
<td width="22%" valign="top" class="vncellreq">MAC address</td>
|
129 |
|
|
<td width="78%" class="vtable">
|
130 |
|
|
<input name="mac" type="text" class="formfld" id="mac" size="20" value="<?=htmlspecialchars($pconfig['mac']);?>">
|
131 |
|
|
<br>
|
132 |
|
|
<span class="vexpl">Enter a MAC address in the following format:
|
133 |
|
|
xx:xx:xx:xx:xx:xx<em></em></span></td>
|
134 |
|
|
</tr>
|
135 |
|
|
<tr>
|
136 |
|
|
<td width="22%" valign="top" class="vncell">Description</td>
|
137 |
|
|
<td width="78%" class="vtable">
|
138 |
|
|
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
139 |
|
|
<br> <span class="vexpl">You may enter a description here
|
140 |
|
|
for your reference (not parsed).</span></td>
|
141 |
|
|
</tr>
|
142 |
|
|
<tr>
|
143 |
|
|
<td width="22%" valign="top"> </td>
|
144 |
|
|
<td width="78%">
|
145 |
fc01e414
|
Scott Ullrich
|
<input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
|
146 |
5b237745
|
Scott Ullrich
|
<?php if (isset($id) && $a_wol[$id]): ?>
|
147 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
148 |
|
|
<?php endif; ?>
|
149 |
|
|
</td>
|
150 |
|
|
</tr>
|
151 |
|
|
</table>
|
152 |
|
|
</form>
|
153 |
|
|
<?php include("fend.inc"); ?>
|
154 |
|
|
</body>
|
155 |
|
|
</html>
|