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