1 |
d2cfb7a4
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
firewall_aliases_edit.php
|
5 |
2e9ab96b
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
6 |
|
|
All rights reserved.
|
7 |
|
|
|
8 |
|
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
9 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
All rights reserved.
|
11 |
d2cfb7a4
|
Scott Ullrich
|
|
12 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
13 |
|
|
modification, are permitted provided that the following conditions are met:
|
14 |
d2cfb7a4
|
Scott Ullrich
|
|
15 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
this list of conditions and the following disclaimer.
|
17 |
d2cfb7a4
|
Scott Ullrich
|
|
18 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
19 |
|
|
notice, this list of conditions and the following disclaimer in the
|
20 |
|
|
documentation and/or other materials provided with the distribution.
|
21 |
d2cfb7a4
|
Scott Ullrich
|
|
22 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
32 |
|
|
*/
|
33 |
|
|
|
34 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
35 |
|
|
##|*IDENT=page-firewall-alias-edit
|
36 |
|
|
##|*NAME=Firewall: Alias: Edit page
|
37 |
|
|
##|*DESCR=Allow access to the 'Firewall: Alias: Edit' page.
|
38 |
|
|
##|*MATCH=firewall_aliases_edit.php*
|
39 |
|
|
##|-PRIV
|
40 |
|
|
|
41 |
|
|
|
42 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("Firewall","Aliases","Edit");
|
43 |
5a1eebc7
|
Scott Ullrich
|
|
44 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
45 |
|
|
|
46 |
|
|
if (!is_array($config['aliases']['alias']))
|
47 |
|
|
$config['aliases']['alias'] = array();
|
48 |
|
|
|
49 |
|
|
aliases_sort();
|
50 |
|
|
$a_aliases = &$config['aliases']['alias'];
|
51 |
|
|
|
52 |
|
|
$id = $_GET['id'];
|
53 |
|
|
if (isset($_POST['id']))
|
54 |
|
|
$id = $_POST['id'];
|
55 |
|
|
|
56 |
|
|
if (isset($id) && $a_aliases[$id]) {
|
57 |
|
|
$pconfig['name'] = $a_aliases[$id]['name'];
|
58 |
ba393f6c
|
Scott Dale
|
$pconfig['detail'] = $a_aliases[$id]['detail'];
|
59 |
|
|
$pconfig['address'] = $a_aliases[$id]['address'];
|
60 |
|
|
$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
|
61 |
e47c266d
|
Scott Ullrich
|
|
62 |
cbe3ea96
|
Ermal Luçi
|
/* optional if list */
|
63 |
|
|
$iflist = get_configured_interface_with_descr(true, true);
|
64 |
|
|
foreach ($iflist as $if => $ifdesc)
|
65 |
|
|
if($ifdesc == $pconfig['descr'])
|
66 |
e47c266d
|
Scott Ullrich
|
$input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}.";
|
67 |
|
|
|
68 |
ba393f6c
|
Scott Dale
|
$addresses = explode(' ', $pconfig['address']);
|
69 |
|
|
$address = explode("/", $addresses[0]);
|
70 |
|
|
if ($address[1])
|
71 |
|
|
$addresssubnettest = true;
|
72 |
d89924da
|
Bill Marquette
|
else
|
73 |
ba393f6c
|
Scott Dale
|
$addresssubnettest = false;
|
74 |
|
|
|
75 |
|
|
if ($addresssubnettest)
|
76 |
5b237745
|
Scott Ullrich
|
$pconfig['type'] = "network";
|
77 |
|
|
else
|
78 |
ba393f6c
|
Scott Dale
|
if (is_ipaddr($address[0]))
|
79 |
d89924da
|
Bill Marquette
|
$pconfig['type'] = "host";
|
80 |
|
|
else
|
81 |
|
|
$pconfig['type'] = "port";
|
82 |
5a1eebc7
|
Scott Ullrich
|
|
83 |
|
|
if($a_aliases[$id]['aliasurl'] <> "") {
|
84 |
|
|
$pconfig['type'] = "url";
|
85 |
|
|
if(is_array($a_aliases[$id]['aliasurl'])) {
|
86 |
|
|
$isfirst = 0;
|
87 |
|
|
$pconfig['address'] = "";
|
88 |
|
|
foreach($a_aliases[$id]['aliasurl'] as $aa) {
|
89 |
|
|
if($isfirst == 1)
|
90 |
|
|
$pconfig['address'] .= " ";
|
91 |
|
|
$isfirst = 1;
|
92 |
|
|
$pconfig['address'] .= $aa;
|
93 |
|
|
}
|
94 |
|
|
} else {
|
95 |
|
|
$pconfig['address'] = $a_aliases[$id]['aliasurl'];
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
5b237745
|
Scott Ullrich
|
}
|
99 |
|
|
|
100 |
|
|
if ($_POST) {
|
101 |
|
|
|
102 |
|
|
unset($input_errors);
|
103 |
|
|
$pconfig = $_POST;
|
104 |
|
|
|
105 |
|
|
/* input validation */
|
106 |
d27d8cdc
|
Scott Ullrich
|
if(strtolower($_POST['name']) == "pptp")
|
107 |
4fdff4ae
|
Scott Ullrich
|
$input_errors[] = gettext("Aliases may not be named PPTP.");
|
108 |
0cd7ed19
|
Scott Ullrich
|
|
109 |
0df6adf8
|
Bill Marquette
|
$x = is_validaliasname($_POST['name']);
|
110 |
|
|
if (!isset($x)) {
|
111 |
|
|
$input_errors[] = "Reserved word used for alias name.";
|
112 |
|
|
} else {
|
113 |
|
|
if (is_validaliasname($_POST['name']) == false)
|
114 |
d87fc50b
|
Seth Mos
|
$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, _.";
|
115 |
beeef1f0
|
Bill Marquette
|
}
|
116 |
5b237745
|
Scott Ullrich
|
/* check for name conflicts */
|
117 |
|
|
foreach ($a_aliases as $alias) {
|
118 |
|
|
if (isset($id) && ($a_aliases[$id]) && ($a_aliases[$id] === $alias))
|
119 |
|
|
continue;
|
120 |
|
|
|
121 |
|
|
if ($alias['name'] == $_POST['name']) {
|
122 |
|
|
$input_errors[] = "An alias with this name already exists.";
|
123 |
|
|
break;
|
124 |
|
|
}
|
125 |
|
|
}
|
126 |
5a1eebc7
|
Scott Ullrich
|
|
127 |
cfa466bb
|
Scott Ullrich
|
/* check for name interface description conflicts */
|
128 |
|
|
foreach($config['interfaces'] as $interface) {
|
129 |
|
|
if($interface['descr'] == $_POST['name']) {
|
130 |
5a1eebc7
|
Scott Ullrich
|
$input_errors[] = "An interface description with this name already exists.";
|
131 |
|
|
break;
|
132 |
cfa466bb
|
Scott Ullrich
|
}
|
133 |
5a1eebc7
|
Scott Ullrich
|
}
|
134 |
ba393f6c
|
Scott Dale
|
|
135 |
|
|
$alias = array();
|
136 |
|
|
$alias['name'] = $_POST['name'];
|
137 |
|
|
if($_POST['type'] == "url") {
|
138 |
|
|
$address = "";
|
139 |
d2cfb7a4
|
Scott Ullrich
|
$isfirst = 0;
|
140 |
ba393f6c
|
Scott Dale
|
$address_count = 2;
|
141 |
|
|
|
142 |
|
|
/* item is a url type */
|
143 |
d8898df4
|
Scott Ullrich
|
for($x=0; isset($_POST['address'. $x]); $x++) {
|
144 |
ba393f6c
|
Scott Dale
|
if($_POST['address' . $x]) {
|
145 |
|
|
/* fetch down and add in */
|
146 |
|
|
$isfirst = 0;
|
147 |
|
|
$temp_filename = tempnam("/tmp/", "alias_import");
|
148 |
|
|
unlink($temp_filename);
|
149 |
|
|
$fda = fopen("/tmp/tmpfetch","w");
|
150 |
|
|
fwrite($fda, "/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
|
151 |
|
|
fclose($fda);
|
152 |
|
|
mwexec("mkdir -p {$temp_filename}");
|
153 |
|
|
mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
|
154 |
|
|
/* if the item is tar gzipped then extract */
|
155 |
|
|
if(stristr($_POST['address' . $x], ".tgz"))
|
156 |
|
|
process_alias_tgz($temp_filename);
|
157 |
|
|
if(file_exists("{$temp_filename}/aliases")) {
|
158 |
|
|
$file_contents = file_get_contents("{$temp_filename}/aliases");
|
159 |
|
|
$file_contents = str_replace("#", "\n#", $file_contents);
|
160 |
|
|
$file_contents_split = split("\n", $file_contents);
|
161 |
|
|
foreach($file_contents_split as $fc) {
|
162 |
|
|
$tmp = trim($fc);
|
163 |
|
|
if(stristr($fc, "#")) {
|
164 |
|
|
$tmp_split = split("#", $tmp);
|
165 |
|
|
$tmp = trim($tmp_split[0]);
|
166 |
5a1eebc7
|
Scott Ullrich
|
}
|
167 |
ba393f6c
|
Scott Dale
|
if(trim($tmp) <> "") {
|
168 |
|
|
if($isfirst == 1)
|
169 |
|
|
$address .= " ";
|
170 |
|
|
$address .= $tmp;
|
171 |
|
|
$isfirst = 1;
|
172 |
5a1eebc7
|
Scott Ullrich
|
}
|
173 |
ba393f6c
|
Scott Dale
|
}
|
174 |
|
|
if($isfirst == 0) {
|
175 |
|
|
/* nothing was found */
|
176 |
|
|
$input_errors[] = "You must provide a valid URL. Could not fetch usable data.";
|
177 |
5a1eebc7
|
Scott Ullrich
|
$dont_update = true;
|
178 |
|
|
break;
|
179 |
|
|
}
|
180 |
ba393f6c
|
Scott Dale
|
$alias['aliasurl'][] = $_POST['address' . $x];
|
181 |
|
|
mwexec("/bin/rm -rf {$temp_filename}");
|
182 |
|
|
} else {
|
183 |
|
|
$input_errors[] = "You must provide a valid URL.";
|
184 |
|
|
$dont_update = true;
|
185 |
|
|
break;
|
186 |
5a1eebc7
|
Scott Ullrich
|
}
|
187 |
|
|
}
|
188 |
ba393f6c
|
Scott Dale
|
}
|
189 |
|
|
} else {
|
190 |
b6f3005c
|
Ermal Luçi
|
$address = "";
|
191 |
|
|
$isfirst = 0;
|
192 |
ba393f6c
|
Scott Dale
|
/* item is a normal alias type */
|
193 |
a2d8d3dd
|
Ermal Luçi
|
for($x=0; $x<4999; $x++) {
|
194 |
b6f3005c
|
Ermal Luçi
|
if($_POST["address{$x}"] <> "") {
|
195 |
|
|
if ($isfirst > 0)
|
196 |
|
|
$address .= " ";
|
197 |
|
|
$address .= $_POST["address{$x}"];
|
198 |
92b9f237
|
Ermal Lu?i
|
if(is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] <> "")
|
199 |
b6f3005c
|
Ermal Luçi
|
$address .= "/" . $_POST["address_subnet{$x}"];
|
200 |
|
|
|
201 |
|
|
if($_POST["detail{$x}"] <> "") {
|
202 |
|
|
$final_address_details .= $_POST["detail{$x}"];
|
203 |
|
|
} else {
|
204 |
|
|
$final_address_details .= "Entry added" . " ";
|
205 |
|
|
$final_address_details .= date('r');
|
206 |
|
|
}
|
207 |
|
|
$final_address_details .= "||";
|
208 |
|
|
$isfirst++;
|
209 |
d2cfb7a4
|
Scott Ullrich
|
}
|
210 |
|
|
}
|
211 |
ba393f6c
|
Scott Dale
|
}
|
212 |
d2cfb7a4
|
Scott Ullrich
|
|
213 |
ba393f6c
|
Scott Dale
|
if (!$input_errors) {
|
214 |
|
|
$alias['address'] = $address;
|
215 |
ec3cedf7
|
Bill Marquette
|
$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
|
216 |
ba393f6c
|
Scott Dale
|
$alias['type'] = $_POST['type'];
|
217 |
|
|
$alias['detail'] = $final_address_details;
|
218 |
d2cfb7a4
|
Scott Ullrich
|
|
219 |
ba393f6c
|
Scott Dale
|
if (isset($id) && $a_aliases[$id])
|
220 |
|
|
$a_aliases[$id] = $alias;
|
221 |
|
|
else
|
222 |
|
|
$a_aliases[] = $alias;
|
223 |
a18b6b97
|
Scott Ullrich
|
|
224 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('aliases');
|
225 |
a18b6b97
|
Scott Ullrich
|
|
226 |
ba393f6c
|
Scott Dale
|
write_config();
|
227 |
|
|
filter_configure();
|
228 |
d2cfb7a4
|
Scott Ullrich
|
|
229 |
ba393f6c
|
Scott Dale
|
header("Location: firewall_aliases.php");
|
230 |
|
|
exit;
|
231 |
|
|
}
|
232 |
|
|
//we received input errors, copy data to prevent retype
|
233 |
|
|
else
|
234 |
|
|
{
|
235 |
ec3cedf7
|
Bill Marquette
|
$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
|
236 |
ba393f6c
|
Scott Dale
|
$pconfig['address'] = $address;
|
237 |
|
|
$pconfig['type'] = $_POST['type'];
|
238 |
ec3cedf7
|
Bill Marquette
|
$pconfig['detail'] = $final_address_details;
|
239 |
5b237745
|
Scott Ullrich
|
}
|
240 |
|
|
}
|
241 |
da7ae7ef
|
Bill Marquette
|
|
242 |
|
|
include("head.inc");
|
243 |
|
|
|
244 |
5a1eebc7
|
Scott Ullrich
|
$jscriptstr = <<<EOD
|
245 |
da7ae7ef
|
Bill Marquette
|
|
246 |
5a1eebc7
|
Scott Ullrich
|
<script type="text/javascript">
|
247 |
0cea9a23
|
Ermal Lu?i
|
|
248 |
|
|
var objAlias = new Array(4999);
|
249 |
5b237745
|
Scott Ullrich
|
function typesel_change() {
|
250 |
|
|
switch (document.iform.type.selectedIndex) {
|
251 |
|
|
case 0: /* host */
|
252 |
d2cfb7a4
|
Scott Ullrich
|
var cmd;
|
253 |
5a1eebc7
|
Scott Ullrich
|
|
254 |
b6f3005c
|
Ermal Luçi
|
newrows = totalrows;
|
255 |
|
|
for(i=0; i<newrows; i++) {
|
256 |
5a1eebc7
|
Scott Ullrich
|
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
|
257 |
|
|
eval(comd);
|
258 |
|
|
comd = 'document.iform.address_subnet' + i + '.value = "";';
|
259 |
|
|
eval(comd);
|
260 |
d2cfb7a4
|
Scott Ullrich
|
}
|
261 |
5b237745
|
Scott Ullrich
|
break;
|
262 |
|
|
case 1: /* network */
|
263 |
d2cfb7a4
|
Scott Ullrich
|
var cmd;
|
264 |
5a1eebc7
|
Scott Ullrich
|
|
265 |
b6f3005c
|
Ermal Luçi
|
newrows = totalrows;
|
266 |
|
|
for(i=0; i<newrows; i++) {
|
267 |
5a1eebc7
|
Scott Ullrich
|
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
|
268 |
|
|
eval(comd);
|
269 |
d2cfb7a4
|
Scott Ullrich
|
}
|
270 |
5b237745
|
Scott Ullrich
|
break;
|
271 |
4d6b6263
|
Scott Ullrich
|
case 2: /* port */
|
272 |
|
|
var cmd;
|
273 |
5a1eebc7
|
Scott Ullrich
|
|
274 |
b6f3005c
|
Ermal Luçi
|
newrows = totalrows;
|
275 |
|
|
for(i=0; i<newrows; i++) {
|
276 |
5a1eebc7
|
Scott Ullrich
|
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
|
277 |
|
|
eval(comd);
|
278 |
|
|
comd = 'document.iform.address_subnet' + i + '.value = "32";';
|
279 |
|
|
eval(comd);
|
280 |
|
|
}
|
281 |
|
|
break;
|
282 |
cd35a596
|
Scott Ullrich
|
case 3: /* OpenVPN Users */
|
283 |
5a1eebc7
|
Scott Ullrich
|
var cmd;
|
284 |
cd35a596
|
Scott Ullrich
|
|
285 |
b6f3005c
|
Ermal Luçi
|
newrows = totalrows;
|
286 |
|
|
for(i=0; i<newrows; i++) {
|
287 |
cd35a596
|
Scott Ullrich
|
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
|
288 |
|
|
eval(comd);
|
289 |
|
|
comd = 'document.iform.address_subnet' + i + '.value = "";';
|
290 |
5a1eebc7
|
Scott Ullrich
|
eval(comd);
|
291 |
4d6b6263
|
Scott Ullrich
|
}
|
292 |
|
|
break;
|
293 |
6e7e1814
|
Scott Ullrich
|
|
294 |
cd35a596
|
Scott Ullrich
|
case 4: /* url */
|
295 |
6e7e1814
|
Scott Ullrich
|
var cmd;
|
296 |
b6f3005c
|
Ermal Luçi
|
newrows = totalrows;
|
297 |
|
|
for(i=0; i<newrows; i++) {
|
298 |
6e7e1814
|
Scott Ullrich
|
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
|
299 |
|
|
eval(comd);
|
300 |
|
|
}
|
301 |
|
|
break;
|
302 |
5b237745
|
Scott Ullrich
|
}
|
303 |
|
|
}
|
304 |
d2cfb7a4
|
Scott Ullrich
|
|
305 |
0cea9a23
|
Ermal Lu?i
|
function add_alias_control() {
|
306 |
|
|
var name = "address" + (totalrows - 1);
|
307 |
|
|
obj = document.getElementById(name);
|
308 |
|
|
obj.setAttribute('class', 'formfldalias');
|
309 |
|
|
obj.setAttribute('autocomplete', 'off');
|
310 |
|
|
objAlias[totalrows - 1] = new AutoSuggestControl(obj, new StateSuggestions(addressarray));
|
311 |
|
|
}
|
312 |
5a1eebc7
|
Scott Ullrich
|
EOD;
|
313 |
|
|
|
314 |
|
|
$network_str = gettext("Network");
|
315 |
|
|
$networks_str = gettext("Network(s)");
|
316 |
|
|
$cidr_str = gettext("CIDR");
|
317 |
|
|
$description_str = gettext("Description");
|
318 |
|
|
$hosts_str = gettext("Host(s)");
|
319 |
|
|
$ip_str = gettext("IP");
|
320 |
|
|
$ports_str = gettext("Port(s)");
|
321 |
|
|
$port_str = gettext("Port");
|
322 |
|
|
$url_str = gettext("URL");
|
323 |
|
|
$update_freq_str = gettext("Update Freq.");
|
324 |
|
|
|
325 |
974ff781
|
Chris Buechler
|
$networks_help = gettext("Networks are specified in CIDR format. Select the CIDR mask that pertains to each entry. /32 specifies a single host, /24 specifies 255.255.255.0, etc. Hostnames (FQDNs) may also be specified, using a /32 mask.");
|
326 |
|
|
$hosts_help = gettext("Enter as many hosts as you would like. Hosts must be specified by their IP address.");
|
327 |
5a1eebc7
|
Scott Ullrich
|
$ports_help = gettext("Enter as many ports as you wish. Port ranges can be expressed by seperating with a colon.");
|
328 |
|
|
$url_help = gettext("Enter as many urls as you wish. Also set the time that you would like the url refreshed in days. After saving {$g['product_name']} will download the URL and import the items into the alias.");
|
329 |
|
|
|
330 |
3ebd97eb
|
Scott Ullrich
|
$openvpn_str = gettext("Username");
|
331 |
|
|
$openvpn_user_str = gettext("OpenVPN Users");
|
332 |
|
|
$openvpn_help = gettext("Enter as many usernames as you wish.");
|
333 |
4c743413
|
Scott Ullrich
|
$openvpn_freq = gettext("");
|
334 |
3ebd97eb
|
Scott Ullrich
|
|
335 |
5a1eebc7
|
Scott Ullrich
|
$jscriptstr .= <<<EOD
|
336 |
|
|
|
337 |
d2cfb7a4
|
Scott Ullrich
|
function update_box_type() {
|
338 |
|
|
var indexNum = document.forms[0].type.selectedIndex;
|
339 |
|
|
var selected = document.forms[0].type.options[indexNum].text;
|
340 |
5a1eebc7
|
Scott Ullrich
|
if(selected == '{$networks_str}') {
|
341 |
|
|
document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
|
342 |
|
|
document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
|
343 |
|
|
document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
|
344 |
|
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
345 |
|
|
document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
|
346 |
|
|
} else if(selected == '{$hosts_str}') {
|
347 |
|
|
document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
|
348 |
|
|
document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
|
349 |
|
|
document.getElementById ("twocolumn").firstChild.data = "";
|
350 |
|
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
351 |
|
|
document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
|
352 |
|
|
} else if(selected == '{$ports_str}') {
|
353 |
|
|
document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
|
354 |
|
|
document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
|
355 |
|
|
document.getElementById ("twocolumn").firstChild.data = "";
|
356 |
|
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
357 |
|
|
document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
|
358 |
|
|
} else if(selected == '{$url_str}') {
|
359 |
|
|
document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
|
360 |
|
|
document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
|
361 |
|
|
document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
|
362 |
|
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
363 |
|
|
document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
|
364 |
6e7e1814
|
Scott Ullrich
|
} else if(selected == '{$openvpn_user_str}') {
|
365 |
|
|
document.getElementById ("addressnetworkport").firstChild.data = "{$openvpn_user_str}";
|
366 |
3ebd97eb
|
Scott Ullrich
|
document.getElementById ("onecolumn").firstChild.data = "{$openvpn_str}";
|
367 |
4c743413
|
Scott Ullrich
|
document.getElementById ("twocolumn").firstChild.data = "{$openvpn_freq}";
|
368 |
6e7e1814
|
Scott Ullrich
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
369 |
3ebd97eb
|
Scott Ullrich
|
document.getElementById ("itemhelp").firstChild.data = "{$openvpn_help}";
|
370 |
d2cfb7a4
|
Scott Ullrich
|
}
|
371 |
|
|
}
|
372 |
5b237745
|
Scott Ullrich
|
</script>
|
373 |
|
|
|
374 |
66138bf6
|
Scott Dale
|
EOD;
|
375 |
d2cfb7a4
|
Scott Ullrich
|
|
376 |
5a1eebc7
|
Scott Ullrich
|
?>
|
377 |
d2cfb7a4
|
Scott Ullrich
|
|
378 |
5a1eebc7
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
|
379 |
|
|
<?php
|
380 |
|
|
include("fbegin.inc");
|
381 |
|
|
echo $jscriptstr;
|
382 |
|
|
?>
|
383 |
|
|
|
384 |
625dcc40
|
Bill Marquette
|
<script type="text/javascript" src="/javascript/row_helper.js">
|
385 |
5a1eebc7
|
Scott Ullrich
|
</script>
|
386 |
0cea9a23
|
Ermal Lu?i
|
<script type="text/javascript" src="/javascript/autosuggest.js">
|
387 |
|
|
</script>
|
388 |
|
|
<script type="text/javascript" src="/javascript/suggestions.js">
|
389 |
|
|
</script>
|
390 |
d2cfb7a4
|
Scott Ullrich
|
|
391 |
5a1eebc7
|
Scott Ullrich
|
<input type='hidden' name='address_type' value='textbox' />
|
392 |
|
|
<input type='hidden' name='address_subnet_type' value='select' />
|
393 |
d2cfb7a4
|
Scott Ullrich
|
|
394 |
5a1eebc7
|
Scott Ullrich
|
<script type="text/javascript">
|
395 |
|
|
rowname[0] = "address";
|
396 |
|
|
rowtype[0] = "textbox";
|
397 |
|
|
rowsize[0] = "30";
|
398 |
d2cfb7a4
|
Scott Ullrich
|
|
399 |
5a1eebc7
|
Scott Ullrich
|
rowname[1] = "address_subnet";
|
400 |
|
|
rowtype[1] = "select";
|
401 |
|
|
rowsize[1] = "1";
|
402 |
d2cfb7a4
|
Scott Ullrich
|
|
403 |
5a1eebc7
|
Scott Ullrich
|
rowname[2] = "detail";
|
404 |
|
|
rowtype[2] = "textbox";
|
405 |
b6f3005c
|
Ermal Luçi
|
rowsize[2] = "50";
|
406 |
d2cfb7a4
|
Scott Ullrich
|
</script>
|
407 |
|
|
|
408 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
409 |
5a1eebc7
|
Scott Ullrich
|
<div id="inputerrors"></div>
|
410 |
|
|
|
411 |
|
|
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
|
412 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
413 |
c823d56b
|
Scott Ullrich
|
<tr>
|
414 |
|
|
<td colspan="2" valign="top" class="listtopic">Alias Edit</td>
|
415 |
|
|
</tr>
|
416 |
a18b6b97
|
Scott Ullrich
|
<?php if(is_alias_inuse($pconfig['name']) == true): ?>
|
417 |
5a1eebc7
|
Scott Ullrich
|
<tr>
|
418 |
|
|
<td valign="top" class="vncellreq">Name</td>
|
419 |
|
|
<td class="vtable"> <input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
|
420 |
a18b6b97
|
Scott Ullrich
|
<?php echo $pconfig['name']; ?>
|
421 |
5a1eebc7
|
Scott Ullrich
|
<p>
|
422 |
|
|
<span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span>
|
423 |
|
|
</p>
|
424 |
|
|
</td>
|
425 |
|
|
</tr>
|
426 |
a18b6b97
|
Scott Ullrich
|
<?php else: ?>
|
427 |
5a1eebc7
|
Scott Ullrich
|
<tr>
|
428 |
|
|
<td valign="top" class="vncellreq">Name</td>
|
429 |
|
|
<td class="vtable">
|
430 |
b5c78501
|
Seth Mos
|
<input name="name" type="text" id="name" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
|
431 |
5a1eebc7
|
Scott Ullrich
|
<br />
|
432 |
|
|
<span class="vexpl">
|
433 |
|
|
The name of the alias may only consist of the characters a-z, A-Z and 0-9.
|
434 |
|
|
</span>
|
435 |
|
|
</td>
|
436 |
|
|
</tr>
|
437 |
a18b6b97
|
Scott Ullrich
|
<?php endif; ?>
|
438 |
5a1eebc7
|
Scott Ullrich
|
<tr>
|
439 |
|
|
<td width="22%" valign="top" class="vncell">Description</td>
|
440 |
|
|
<td width="78%" class="vtable">
|
441 |
b5c78501
|
Seth Mos
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
|
442 |
5a1eebc7
|
Scott Ullrich
|
<br />
|
443 |
|
|
<span class="vexpl">
|
444 |
|
|
You may enter a description here for your reference (not parsed).
|
445 |
|
|
</span>
|
446 |
|
|
</td>
|
447 |
|
|
</tr>
|
448 |
|
|
<tr>
|
449 |
|
|
<td valign="top" class="vncellreq">Type</td>
|
450 |
|
|
<td class="vtable">
|
451 |
|
|
<select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
|
452 |
|
|
<option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
|
453 |
|
|
<option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
|
454 |
|
|
<option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
|
455 |
b6f3005c
|
Ermal Luçi
|
<option value="openvpn" <?php if ($pconfig['type'] == "openvpn") echo "selected"; ?>>OpenVPN Users</option>
|
456 |
5a1eebc7
|
Scott Ullrich
|
</select>
|
457 |
|
|
</td>
|
458 |
|
|
</tr>
|
459 |
|
|
<tr>
|
460 |
|
|
<td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
|
461 |
|
|
<td width="78%" class="vtable">
|
462 |
|
|
<table id="maintable">
|
463 |
|
|
<tbody>
|
464 |
|
|
<tr>
|
465 |
|
|
<td colspan="4">
|
466 |
|
|
<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">Item information</div>
|
467 |
|
|
</td>
|
468 |
|
|
</tr>
|
469 |
|
|
<tr>
|
470 |
|
|
<td><div id="onecolumn">Network</div></td>
|
471 |
|
|
<td><div id="twocolumn">CIDR</div></td>
|
472 |
|
|
<td><div id="threecolumn">Description</div></td>
|
473 |
|
|
</tr>
|
474 |
d2cfb7a4
|
Scott Ullrich
|
|
475 |
0d3f3e90
|
Ermal Luçi
|
<?php
|
476 |
|
|
$counter = 0;
|
477 |
|
|
$address = $pconfig['address'];
|
478 |
|
|
if ($address <> "") {
|
479 |
|
|
$item = explode(" ", $address);
|
480 |
|
|
$item3 = explode("||", $pconfig['detail']);
|
481 |
|
|
foreach($item as $ww) {
|
482 |
|
|
$address = $item[$counter];
|
483 |
|
|
$address_subnet = "";
|
484 |
|
|
$item2 = explode("/", $address);
|
485 |
|
|
foreach($item2 as $current) {
|
486 |
|
|
if($item2[1] <> "") {
|
487 |
|
|
$address = $item2[0];
|
488 |
|
|
$address_subnet = $item2[1];
|
489 |
d2cfb7a4
|
Scott Ullrich
|
}
|
490 |
0d3f3e90
|
Ermal Luçi
|
}
|
491 |
|
|
$item4 = $item3[$counter];
|
492 |
|
|
$tracker = $counter;
|
493 |
|
|
?>
|
494 |
5a1eebc7
|
Scott Ullrich
|
<tr>
|
495 |
|
|
<td>
|
496 |
0cea9a23
|
Ermal Lu?i
|
<input autocomplete="off" name="address<?php echo $tracker; ?>" type="text" class="formfldalias" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
|
497 |
5a1eebc7
|
Scott Ullrich
|
</td>
|
498 |
|
|
<td>
|
499 |
|
|
<select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
|
500 |
|
|
<option></option>
|
501 |
|
|
<?php for ($i = 32; $i >= 1; $i--): ?>
|
502 |
|
|
<option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
|
503 |
|
|
<?php endfor; ?>
|
504 |
|
|
</select>
|
505 |
|
|
</td>
|
506 |
|
|
<td>
|
507 |
b5c78501
|
Seth Mos
|
<input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
|
508 |
5a1eebc7
|
Scott Ullrich
|
</td>
|
509 |
|
|
<td>
|
510 |
b6f3005c
|
Ermal Luçi
|
<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
|
511 |
|
|
</td>
|
512 |
5a1eebc7
|
Scott Ullrich
|
</tr>
|
513 |
0d3f3e90
|
Ermal Luçi
|
<?php
|
514 |
|
|
$counter++;
|
515 |
5a1eebc7
|
Scott Ullrich
|
|
516 |
0d3f3e90
|
Ermal Luçi
|
} // end foreach
|
517 |
|
|
} // end if
|
518 |
|
|
?>
|
519 |
5a1eebc7
|
Scott Ullrich
|
</tbody>
|
520 |
|
|
<tfoot>
|
521 |
|
|
|
522 |
|
|
</tfoot>
|
523 |
|
|
</table>
|
524 |
0cea9a23
|
Ermal Lu?i
|
<a onclick="javascript:addRowTo('maintable', 'formfldalias'); typesel_change(); add_alias_control(this); return false;" href="#">
|
525 |
5a1eebc7
|
Scott Ullrich
|
<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
|
526 |
|
|
</a>
|
527 |
|
|
</td>
|
528 |
|
|
</tr>
|
529 |
|
|
<tr>
|
530 |
|
|
<td width="22%" valign="top"> </td>
|
531 |
|
|
<td width="78%">
|
532 |
|
|
<input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
|
533 |
b6f3005c
|
Ermal Luçi
|
<a href="firewall_aliases.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
|
534 |
5a1eebc7
|
Scott Ullrich
|
<?php if (isset($id) && $a_aliases[$id]): ?>
|
535 |
|
|
<input name="id" type="hidden" value="<?=$id;?>" />
|
536 |
|
|
<?php endif; ?>
|
537 |
|
|
</td>
|
538 |
|
|
</tr>
|
539 |
|
|
</table>
|
540 |
5b237745
|
Scott Ullrich
|
</form>
|
541 |
5a1eebc7
|
Scott Ullrich
|
|
542 |
|
|
<script type="text/javascript">
|
543 |
|
|
field_counter_js = 3;
|
544 |
|
|
rows = 1;
|
545 |
|
|
totalrows = <?php echo $counter; ?>;
|
546 |
|
|
loaded = <?php echo $counter; ?>;
|
547 |
|
|
typesel_change();
|
548 |
|
|
update_box_type();
|
549 |
0cea9a23
|
Ermal Lu?i
|
|
550 |
|
|
<?php
|
551 |
|
|
$isfirst = 0;
|
552 |
|
|
$aliases = "";
|
553 |
|
|
$addrisfirst = 0;
|
554 |
|
|
$aliasesaddr = "";
|
555 |
|
|
if(isset($config['aliases']['alias']) && is_array($config['aliases']['alias']))
|
556 |
|
|
foreach($config['aliases']['alias'] as $alias_name) {
|
557 |
|
|
if($addrisfirst == 1) $aliasesaddr .= ",";
|
558 |
|
|
$aliasesaddr .= "'" . $alias_name['name'] . "'";
|
559 |
|
|
$addrisfirst = 1;
|
560 |
|
|
}
|
561 |
|
|
?>
|
562 |
|
|
|
563 |
|
|
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
|
564 |
|
|
var customarray=new Array(<?php echo $aliases; ?>);
|
565 |
|
|
|
566 |
|
|
<?php
|
567 |
|
|
for ($jv = 0; $jv < $counter; $jv++)
|
568 |
|
|
echo "objAlias[{$jv}] = new AutoSuggestControl(document.getElementById(\"address{$jv}\"), new StateSuggestions(addressarray));\n";
|
569 |
|
|
?>
|
570 |
|
|
|
571 |
|
|
|
572 |
5b237745
|
Scott Ullrich
|
</script>
|
573 |
5a1eebc7
|
Scott Ullrich
|
|
574 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
575 |
|
|
</body>
|
576 |
|
|
</html>
|
577 |
5a1eebc7
|
Scott Ullrich
|
|
578 |
|
|
<?php
|
579 |
|
|
function process_alias_tgz($temp_filename) {
|
580 |
|
|
mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
|
581 |
|
|
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
|
582 |
|
|
unlink("{$temp_filename}/aliases.tgz");
|
583 |
|
|
$files_to_process = return_dir_as_array("{$temp_filename}/");
|
584 |
|
|
/* foreach through all extracted files and build up aliases file */
|
585 |
|
|
$fd = fopen("{$temp_filename}/aliases", "a");
|
586 |
|
|
foreach($files_to_process as $f2p) {
|
587 |
|
|
$file_contents = file_get_contents($f2p);
|
588 |
|
|
fwrite($fd, $file_contents);
|
589 |
|
|
unlink($f2p);
|
590 |
|
|
}
|
591 |
|
|
fclose($fd);
|
592 |
|
|
}
|
593 |
|
|
?>
|