1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_aliases_edit.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
originially part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
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
|
|
22
|
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
|
$pgtitle = "Firewall: Aliases: Edit";
|
35
|
|
36
|
require("guiconfig.inc");
|
37
|
|
38
|
if (!is_array($config['aliases']['alias']))
|
39
|
$config['aliases']['alias'] = array();
|
40
|
|
41
|
aliases_sort();
|
42
|
$a_aliases = &$config['aliases']['alias'];
|
43
|
|
44
|
$id = $_GET['id'];
|
45
|
if (isset($_POST['id']))
|
46
|
$id = $_POST['id'];
|
47
|
|
48
|
if (isset($id) && $a_aliases[$id]) {
|
49
|
$pconfig['name'] = $a_aliases[$id]['name'];
|
50
|
$pconfig['detail'] = $a_aliases[$id]['detail'];
|
51
|
$pconfig['address'] = $a_aliases[$id]['address'];
|
52
|
$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
|
53
|
|
54
|
$addresses = explode(' ', $pconfig['address']);
|
55
|
$address = explode("/", $addresses[0]);
|
56
|
if ($address[1])
|
57
|
$addresssubnettest = true;
|
58
|
else
|
59
|
$addresssubnettest = false;
|
60
|
|
61
|
if ($addresssubnettest)
|
62
|
$pconfig['type'] = "network";
|
63
|
else
|
64
|
if (is_ipaddr($address[0]))
|
65
|
$pconfig['type'] = "host";
|
66
|
else
|
67
|
$pconfig['type'] = "port";
|
68
|
|
69
|
if($a_aliases[$id]['aliasurl'] <> "") {
|
70
|
$pconfig['type'] = "url";
|
71
|
if(is_array($a_aliases[$id]['aliasurl'])) {
|
72
|
$isfirst = 0;
|
73
|
$pconfig['address'] = "";
|
74
|
foreach($a_aliases[$id]['aliasurl'] as $aa) {
|
75
|
if($isfirst == 1)
|
76
|
$pconfig['address'] .= " ";
|
77
|
$isfirst = 1;
|
78
|
$pconfig['address'] .= $aa;
|
79
|
}
|
80
|
} else {
|
81
|
$pconfig['address'] = $a_aliases[$id]['aliasurl'];
|
82
|
}
|
83
|
}
|
84
|
}
|
85
|
|
86
|
if ($_POST) {
|
87
|
|
88
|
unset($input_errors);
|
89
|
$pconfig = $_POST;
|
90
|
|
91
|
/* input validation */
|
92
|
$reqdfields = explode(" ", "name address");
|
93
|
$reqdfieldsn = explode(",", "Name,Address");
|
94
|
|
95
|
if ($_POST['type'] == "network") {
|
96
|
$reqdfields[] = "address_subnet";
|
97
|
$reqdfieldsn[] = "Subnet bit count";
|
98
|
}
|
99
|
|
100
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
101
|
|
102
|
if(strtolower($_POST['name']) == "lan")
|
103
|
$input_errors[] = "Aliases may not be named LAN.";
|
104
|
if(strtolower($_POST['name']) == "wan")
|
105
|
$input_errors[] = "Aliases may not be named WAN.";
|
106
|
if(strtolower($_POST['name']) == "pptp")
|
107
|
$input_errors[] = gettext("Aliases may not be named PPTP.");
|
108
|
|
109
|
$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
|
$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, _.";
|
115
|
}
|
116
|
if ($_POST['type'] == "network") {
|
117
|
if (!is_ipaddr($_POST['address'])) {
|
118
|
$input_errors[] = "A valid address must be specified.";
|
119
|
}
|
120
|
if (!is_numeric($_POST['address_subnet'])) {
|
121
|
$input_errors[] = "A valid subnet bit count must be specified.";
|
122
|
}
|
123
|
}
|
124
|
|
125
|
if ($_POST['type'] == "url") {
|
126
|
if(stristr($_POST['address'], "http") == false)
|
127
|
$input_errors[] = "You must provide a valid URL to the resource.";
|
128
|
}
|
129
|
|
130
|
if ($_POST['type'] == "port")
|
131
|
if (! is_port($_POST['address']) && ! is_portrange($_POST['address']))
|
132
|
$input_errors[] = "Please specify a valid port or portrange.";
|
133
|
|
134
|
/* check for name conflicts */
|
135
|
foreach ($a_aliases as $alias) {
|
136
|
if (isset($id) && ($a_aliases[$id]) && ($a_aliases[$id] === $alias))
|
137
|
continue;
|
138
|
|
139
|
if ($alias['name'] == $_POST['name']) {
|
140
|
$input_errors[] = "An alias with this name already exists.";
|
141
|
break;
|
142
|
}
|
143
|
}
|
144
|
|
145
|
/* check for name interface description conflicts */
|
146
|
foreach($config['interfaces'] as $interface) {
|
147
|
if($interface['descr'] == $_POST['name']) {
|
148
|
$input_errors[] = "An interface description with this name already exists.";
|
149
|
break;
|
150
|
}
|
151
|
}
|
152
|
|
153
|
$alias = array();
|
154
|
$alias['name'] = $_POST['name'];
|
155
|
if ($_POST['type'] == "network")
|
156
|
$alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet'];
|
157
|
|
158
|
else
|
159
|
$alias['address'] = $_POST['address'];
|
160
|
|
161
|
$address = $alias['address'];
|
162
|
$final_address_detail = htmlentities($_POST['detail'], ENT_QUOTES, 'UTF-8');
|
163
|
if($final_address_detail <> "") {
|
164
|
$final_address_details .= $final_address_detail;
|
165
|
} else {
|
166
|
$final_address_details .= "Entry added" . " ";
|
167
|
$final_address_details .= date('r');
|
168
|
}
|
169
|
$final_address_details .= "||";
|
170
|
$isfirst = 0;
|
171
|
|
172
|
if($_POST['type'] == "url") {
|
173
|
$address = "";
|
174
|
$isfirst = 0;
|
175
|
$address_count = 2;
|
176
|
|
177
|
/* item is a url type */
|
178
|
if($_POST['address'])
|
179
|
$_POST['address0'] = $_POST['address'];
|
180
|
for($x=0; $x<99; $x++) {
|
181
|
if($_POST['address' . $x]) {
|
182
|
/* fetch down and add in */
|
183
|
$isfirst = 0;
|
184
|
$temp_filename = tempnam("/tmp/", "alias_import");
|
185
|
unlink($temp_filename);
|
186
|
$fda = fopen("/tmp/tmpfetch","w");
|
187
|
fwrite($fda, "/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
|
188
|
fclose($fda);
|
189
|
mwexec("mkdir -p {$temp_filename}");
|
190
|
mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
|
191
|
/* if the item is tar gzipped then extract */
|
192
|
if(stristr($_POST['address' . $x], ".tgz"))
|
193
|
process_alias_tgz($temp_filename);
|
194
|
if(file_exists("{$temp_filename}/aliases")) {
|
195
|
$file_contents = file_get_contents("{$temp_filename}/aliases");
|
196
|
$file_contents = str_replace("#", "\n#", $file_contents);
|
197
|
$file_contents_split = split("\n", $file_contents);
|
198
|
foreach($file_contents_split as $fc) {
|
199
|
$tmp = trim($fc);
|
200
|
if(stristr($fc, "#")) {
|
201
|
$tmp_split = split("#", $tmp);
|
202
|
$tmp = trim($tmp_split[0]);
|
203
|
}
|
204
|
if(trim($tmp) <> "") {
|
205
|
if($isfirst == 1)
|
206
|
$address .= " ";
|
207
|
$address .= $tmp;
|
208
|
$isfirst = 1;
|
209
|
}
|
210
|
}
|
211
|
if($isfirst == 0) {
|
212
|
/* nothing was found */
|
213
|
$input_errors[] = "You must provide a valid URL. Could not fetch usable data.";
|
214
|
$dont_update = true;
|
215
|
break;
|
216
|
}
|
217
|
$alias['aliasurl'][] = $_POST['address' . $x];
|
218
|
mwexec("/bin/rm -rf {$temp_filename}");
|
219
|
} else {
|
220
|
$input_errors[] = "You must provide a valid URL.";
|
221
|
$dont_update = true;
|
222
|
break;
|
223
|
}
|
224
|
}
|
225
|
}
|
226
|
} else {
|
227
|
/* item is a normal alias type */
|
228
|
for($x=0; $x<99; $x++) {
|
229
|
$comd = "\$subnet = \$_POST['address" . $x . "'];";
|
230
|
eval($comd);
|
231
|
$comd = "\$subnet_address = \$_POST['address_subnet" . $x . "'];";
|
232
|
eval($comd);
|
233
|
if($subnet <> "") {
|
234
|
$address .= " ";
|
235
|
$address .= $subnet;
|
236
|
if($subnet_address <> "") $address .= "/" . $subnet_address;
|
237
|
|
238
|
/* Compress in details to a single key, data separated by pipes.
|
239
|
Pulling details here lets us only pull in details for valid
|
240
|
address entries, saving us from having to track which ones to
|
241
|
process later. */
|
242
|
$comd = "\$final_address_detail = mb_convert_encoding(\$_POST['detail" . $x . "'],'HTML_ENTITIES','auto');";
|
243
|
eval($comd);
|
244
|
if($final_address_detail <> "") {
|
245
|
$final_address_details .= $final_address_detail;
|
246
|
} else {
|
247
|
$final_address_details .= "Entry added" . " ";
|
248
|
$final_address_details .= date('r');
|
249
|
}
|
250
|
$final_address_details .= "||";
|
251
|
}
|
252
|
}
|
253
|
}
|
254
|
|
255
|
if (!$input_errors) {
|
256
|
$alias['address'] = $address;
|
257
|
$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
|
258
|
$alias['type'] = $_POST['type'];
|
259
|
$alias['detail'] = $final_address_details;
|
260
|
|
261
|
if (isset($id) && $a_aliases[$id])
|
262
|
$a_aliases[$id] = $alias;
|
263
|
else
|
264
|
$a_aliases[] = $alias;
|
265
|
|
266
|
touch($d_aliasesdirty_path);
|
267
|
|
268
|
write_config();
|
269
|
filter_configure();
|
270
|
|
271
|
header("Location: firewall_aliases.php");
|
272
|
exit;
|
273
|
}
|
274
|
//we received input errors, copy data to prevent retype
|
275
|
else
|
276
|
{
|
277
|
$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
|
278
|
$pconfig['address'] = $address;
|
279
|
$pconfig['type'] = $_POST['type'];
|
280
|
$pconfig['detail'] = $final_address_details;
|
281
|
}
|
282
|
}
|
283
|
|
284
|
include("head.inc");
|
285
|
|
286
|
$jscriptstr = <<<EOD
|
287
|
|
288
|
<script type="text/javascript">
|
289
|
function typesel_change() {
|
290
|
switch (document.iform.type.selectedIndex) {
|
291
|
case 0: /* host */
|
292
|
var cmd;
|
293
|
|
294
|
document.iform.address_subnet.disabled = 1;
|
295
|
document.iform.address_subnet.value = "";
|
296
|
document.iform.address_subnet.selected = 0;
|
297
|
newrows = totalrows+1;
|
298
|
for(i=2; i<newrows; i++) {
|
299
|
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
|
300
|
eval(comd);
|
301
|
comd = 'document.iform.address_subnet' + i + '.value = "";';
|
302
|
eval(comd);
|
303
|
}
|
304
|
break;
|
305
|
case 1: /* network */
|
306
|
var cmd;
|
307
|
|
308
|
document.iform.address_subnet.disabled = 0;
|
309
|
newrows = totalrows+1;
|
310
|
for(i=2; i<newrows; i++) {
|
311
|
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
|
312
|
eval(comd);
|
313
|
}
|
314
|
break;
|
315
|
case 2: /* port */
|
316
|
var cmd;
|
317
|
|
318
|
document.iform.address_subnet.disabled = 1;
|
319
|
document.iform.address_subnet.value = "";
|
320
|
newrows = totalrows+1;
|
321
|
for(i=2; i<newrows; i++) {
|
322
|
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
|
323
|
eval(comd);
|
324
|
comd = 'document.iform.address_subnet' + i + '.value = "32";';
|
325
|
eval(comd);
|
326
|
}
|
327
|
break;
|
328
|
case 3: /* url */
|
329
|
var cmd;
|
330
|
document.iform.address_subnet.disabled = 0;
|
331
|
newrows = totalrows+1;
|
332
|
for(i=2; i<newrows; i++) {
|
333
|
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
|
334
|
eval(comd);
|
335
|
}
|
336
|
break;
|
337
|
}
|
338
|
}
|
339
|
|
340
|
EOD;
|
341
|
|
342
|
$network_str = gettext("Network");
|
343
|
$networks_str = gettext("Network(s)");
|
344
|
$cidr_str = gettext("CIDR");
|
345
|
$description_str = gettext("Description");
|
346
|
$hosts_str = gettext("Host(s)");
|
347
|
$ip_str = gettext("IP");
|
348
|
$ports_str = gettext("Port(s)");
|
349
|
$port_str = gettext("Port");
|
350
|
$url_str = gettext("URL");
|
351
|
$update_freq_str = gettext("Update Freq.");
|
352
|
|
353
|
$networks_help = gettext("Networks can be expressed like 10.0.0.0 format. Select the CIDR (network mask) that pertains to each entry.");
|
354
|
$hosts_help = gettext("Enter as many hosts as you would like. Hosts should be expressed in their ip address format.");
|
355
|
$ports_help = gettext("Enter as many ports as you wish. Port ranges can be expressed by seperating with a colon.");
|
356
|
$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.");
|
357
|
|
358
|
$jscriptstr .= <<<EOD
|
359
|
|
360
|
function update_box_type() {
|
361
|
var indexNum = document.forms[0].type.selectedIndex;
|
362
|
var selected = document.forms[0].type.options[indexNum].text;
|
363
|
if(selected == '{$networks_str}') {
|
364
|
document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
|
365
|
document.getElementById ("address_subnet").visible = true;
|
366
|
document.getElementById ("address_subnet").disabled = false;
|
367
|
document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
|
368
|
document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
|
369
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
370
|
document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
|
371
|
} else if(selected == '{$hosts_str}') {
|
372
|
document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
|
373
|
document.getElementById ("address_subnet").visible = false;
|
374
|
document.getElementById ("address_subnet").disabled = true;
|
375
|
document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
|
376
|
document.getElementById ("twocolumn").firstChild.data = "";
|
377
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
378
|
document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
|
379
|
} else if(selected == '{$ports_str}') {
|
380
|
document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
|
381
|
document.getElementById ("address_subnet").visible = false;
|
382
|
document.getElementById ("address_subnet").disabled = true;
|
383
|
document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
|
384
|
document.getElementById ("twocolumn").firstChild.data = "";
|
385
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
386
|
document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
|
387
|
} else if(selected == '{$url_str}') {
|
388
|
document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
|
389
|
document.getElementById ("address_subnet").visible = true;
|
390
|
document.getElementById ("address_subnet").disabled = false;
|
391
|
document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
|
392
|
document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
|
393
|
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
|
394
|
document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
|
395
|
}
|
396
|
}
|
397
|
</script>
|
398
|
|
399
|
EOD;
|
400
|
|
401
|
?>
|
402
|
|
403
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
|
404
|
<?php
|
405
|
include("fbegin.inc");
|
406
|
echo $jscriptstr;
|
407
|
?>
|
408
|
|
409
|
<script type="text/javascript" src="row_helper.js">
|
410
|
</script>
|
411
|
|
412
|
<input type='hidden' name='address_type' value='textbox' />
|
413
|
<input type='hidden' name='address_subnet_type' value='select' />
|
414
|
|
415
|
<script type="text/javascript">
|
416
|
rowname[0] = "address";
|
417
|
rowtype[0] = "textbox";
|
418
|
rowsize[0] = "30";
|
419
|
|
420
|
rowname[1] = "address_subnet";
|
421
|
rowtype[1] = "select";
|
422
|
rowsize[1] = "1";
|
423
|
|
424
|
rowname[2] = "detail";
|
425
|
rowtype[2] = "textbox";
|
426
|
rowsize[2] = "61";
|
427
|
</script>
|
428
|
|
429
|
<p class="pgtitle"><?=$pgtitle?></p>
|
430
|
|
431
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
432
|
<div id="inputerrors"></div>
|
433
|
|
434
|
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
|
435
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
436
|
<?php if(is_alias_inuse($pconfig['name']) == true): ?>
|
437
|
<tr>
|
438
|
<td valign="top" class="vncellreq">Name</td>
|
439
|
<td class="vtable"> <input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
|
440
|
<?php echo $pconfig['name']; ?>
|
441
|
<p>
|
442
|
<span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span>
|
443
|
</p>
|
444
|
</td>
|
445
|
</tr>
|
446
|
<?php else: ?>
|
447
|
<tr>
|
448
|
<td valign="top" class="vncellreq">Name</td>
|
449
|
<td class="vtable">
|
450
|
<input name="name" type="text" id="name" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
|
451
|
<br />
|
452
|
<span class="vexpl">
|
453
|
The name of the alias may only consist of the characters a-z, A-Z and 0-9.
|
454
|
</span>
|
455
|
</td>
|
456
|
</tr>
|
457
|
<?php endif; ?>
|
458
|
<tr>
|
459
|
<td width="22%" valign="top" class="vncell">Description</td>
|
460
|
<td width="78%" class="vtable">
|
461
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
|
462
|
<br />
|
463
|
<span class="vexpl">
|
464
|
You may enter a description here for your reference (not parsed).
|
465
|
</span>
|
466
|
</td>
|
467
|
</tr>
|
468
|
<tr>
|
469
|
<td valign="top" class="vncellreq">Type</td>
|
470
|
<td class="vtable">
|
471
|
<select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
|
472
|
<option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
|
473
|
<option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
|
474
|
<option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
|
475
|
</select>
|
476
|
</td>
|
477
|
</tr>
|
478
|
<tr>
|
479
|
<td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
|
480
|
<td width="78%" class="vtable">
|
481
|
<table id="maintable">
|
482
|
<tbody>
|
483
|
<tr>
|
484
|
<td colspan="4">
|
485
|
<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>
|
486
|
</td>
|
487
|
</tr>
|
488
|
<tr>
|
489
|
<td><div id="onecolumn">Network</div></td>
|
490
|
<td><div id="twocolumn">CIDR</div></td>
|
491
|
<td><div id="threecolumn">Description</div></td>
|
492
|
</tr>
|
493
|
|
494
|
<?php
|
495
|
$counter = 0;
|
496
|
$address = $pconfig['address'];
|
497
|
$item = explode(" ", $address);
|
498
|
$item3 = explode("||", $pconfig['detail']);
|
499
|
foreach($item as $ww) {
|
500
|
$address = $item[$counter];
|
501
|
$address_subnet = "";
|
502
|
$item2 = explode("/", $address);
|
503
|
foreach($item2 as $current) {
|
504
|
if($item2[1] <> "") {
|
505
|
$address = $item2[0];
|
506
|
$address_subnet = $item2[1];
|
507
|
}
|
508
|
}
|
509
|
$item4 = $item3[$counter];
|
510
|
if($counter > 0) $tracker = $counter + 1;
|
511
|
?>
|
512
|
<tr>
|
513
|
<td>
|
514
|
<input name="address<?php echo $tracker; ?>" type="text" class="formfld unknown" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
|
515
|
</td>
|
516
|
<td>
|
517
|
<select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
|
518
|
<option></option>
|
519
|
<?php for ($i = 32; $i >= 1; $i--): ?>
|
520
|
<option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
|
521
|
<?php endfor; ?>
|
522
|
</select>
|
523
|
</td>
|
524
|
<td>
|
525
|
<input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
|
526
|
</td>
|
527
|
<td>
|
528
|
<?php
|
529
|
if($counter > 0)
|
530
|
echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
|
531
|
?>
|
532
|
</td>
|
533
|
</tr>
|
534
|
<?php
|
535
|
$counter++;
|
536
|
|
537
|
} // end foreach
|
538
|
?>
|
539
|
</tbody>
|
540
|
<tfoot>
|
541
|
|
542
|
</tfoot>
|
543
|
</table>
|
544
|
<a onclick="javascript:addRowTo('maintable'); typesel_change(); return false;" href="#">
|
545
|
<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
|
546
|
</a>
|
547
|
</td>
|
548
|
</tr>
|
549
|
<tr>
|
550
|
<td width="22%" valign="top"> </td>
|
551
|
<td width="78%">
|
552
|
<input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
|
553
|
<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
|
554
|
<?php if (isset($id) && $a_aliases[$id]): ?>
|
555
|
<input name="id" type="hidden" value="<?=$id;?>" />
|
556
|
<?php endif; ?>
|
557
|
</td>
|
558
|
</tr>
|
559
|
</table>
|
560
|
</form>
|
561
|
|
562
|
<script type="text/javascript">
|
563
|
field_counter_js = 3;
|
564
|
rows = 1;
|
565
|
totalrows = <?php echo $counter; ?>;
|
566
|
loaded = <?php echo $counter; ?>;
|
567
|
typesel_change();
|
568
|
update_box_type();
|
569
|
</script>
|
570
|
|
571
|
<?php include("fend.inc"); ?>
|
572
|
</body>
|
573
|
</html>
|
574
|
|
575
|
<?php
|
576
|
function process_alias_tgz($temp_filename) {
|
577
|
mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
|
578
|
mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
|
579
|
unlink("{$temp_filename}/aliases.tgz");
|
580
|
$files_to_process = return_dir_as_array("{$temp_filename}/");
|
581
|
/* foreach through all extracted files and build up aliases file */
|
582
|
$fd = fopen("{$temp_filename}/aliases", "a");
|
583
|
foreach($files_to_process as $f2p) {
|
584
|
$file_contents = file_get_contents($f2p);
|
585
|
fwrite($fd, $file_contents);
|
586
|
unlink($f2p);
|
587
|
}
|
588
|
fclose($fd);
|
589
|
}
|
590
|
?>
|