1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
<?php
/* $Id$ */
/*
firewall_aliases_edit.php
Copyright (C) 2004 Scott Ullrich
Copyright (C) 2009 Ermal Luçi
Copyright (C) 2010 Jim Pingle
All rights reserved.
originially part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_BUILDER_BINARIES: /bin/rm /bin/mkdir /usr/bin/fetch
pfSense_MODULE: aliases
*/
##|+PRIV
##|*IDENT=page-firewall-alias-edit
##|*NAME=Firewall: Alias: Edit page
##|*DESCR=Allow access to the 'Firewall: Alias: Edit' page.
##|*MATCH=firewall_aliases_edit.php*
##|-PRIV
$pgtitle = array("Firewall","Aliases","Edit");
// Keywords not allowed in names
$reserved_keywords = array("pass", "out", "queue", "max", "min", "pptp", "pppoe", "l2tp", "openvpn");
require("guiconfig.inc");
require_once("functions.inc");
require_once("filter.inc");
require_once("shaper.inc");
$reserved_ifs = get_configured_interface_list(false, true);
$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs);
if (!is_array($config['aliases']['alias']))
$config['aliases']['alias'] = array();
$a_aliases = &$config['aliases']['alias'];
if($_POST)
$origname = $_POST['origname'];
// Debugging
if($debug)
exec("rm -f {$g['tmp_path']}/alias_rename_log.txt");
function alias_same_type($name, $type) {
global $config;
foreach ($config['aliases']['alias'] as $alias) {
if ($name == $alias['name']) {
if (in_array($type, array("host", "network")) &&
in_array($alias['type'], array("host", "network")))
return true;
if ($type == $alias['type'])
return true;
else
return false;
}
}
return true;
}
$id = $_GET['id'];
if (isset($_POST['id']))
$id = $_POST['id'];
if (isset($id) && $a_aliases[$id]) {
$original_alias_name = $a_aliases[$id]['name'];
$pconfig['name'] = $a_aliases[$id]['name'];
$pconfig['detail'] = $a_aliases[$id]['detail'];
$pconfig['address'] = $a_aliases[$id]['address'];
$pconfig['type'] = $a_aliases[$id]['type'];
$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
/* optional if list */
$iflist = get_configured_interface_with_descr(true, true);
foreach ($iflist as $if => $ifdesc)
if($ifdesc == $pconfig['descr'])
$input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}.";
if($a_aliases[$id]['type'] == "urltable") {
$pconfig['address'] = $a_aliases[$id]['url'];
$pconfig['updatefreq'] = $a_aliases[$id]['updatefreq'];
}
if($a_aliases[$id]['aliasurl'] <> "") {
$pconfig['type'] = "url";
if(is_array($a_aliases[$id]['aliasurl'])) {
$isfirst = 0;
$pconfig['address'] = "";
foreach($a_aliases[$id]['aliasurl'] as $aa) {
if($isfirst == 1)
$pconfig['address'] .= " ";
$isfirst = 1;
$pconfig['address'] .= $aa;
}
} else {
$pconfig['address'] = $a_aliases[$id]['aliasurl'];
}
}
}
if ($_POST) {
unset($input_errors);
/* input validation */
$reqdfields = explode(" ", "name");
$reqdfieldsn = explode(",", "Name");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
$x = is_validaliasname($_POST['name']);
if (!isset($x)) {
$input_errors[] = "Reserved word used for alias name.";
} else if ($_POST['type'] == "port" && (getservbyname($_POST['name'], "tcp") || getservbyname($_POST['name'], "udp"))) {
$input_errors[] = "Reserved word used for alias name.";
} else {
if (is_validaliasname($_POST['name']) == false)
$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, _.";
}
/* check for name conflicts */
if (empty($a_aliases[$id])) {
foreach ($a_aliases as $alias) {
if ($alias['name'] == $_POST['name']) {
$input_errors[] = "An alias with this name already exists.";
break;
}
}
}
/* Check for reserved keyword names */
foreach($reserved_keywords as $rk)
if($rk == $_POST['name'])
$input_errors[] = "Cannot use a reserved keyword as alias name $rk";
/* check for name interface description conflicts */
foreach($config['interfaces'] as $interface) {
if($interface['descr'] == $_POST['name']) {
$input_errors[] = "An interface description with this name already exists.";
break;
}
}
$alias = array();
$address = array();
$final_address_details = array();
$alias['name'] = $_POST['name'];
if ($_POST['type'] == "urltable") {
$address = "";
$isfirst = 0;
/* item is a url type */
if ($_POST['address0']) {
/* fetch down and add in */
$isfirst = 0;
$address = "";
$alias['url'] = $_POST['address0'];
$alias['updatefreq'] = $_POST['address_subnet0'] ? $_POST['address_subnet0'] : 7;
if (!is_URL($alias['url']) || empty($alias['url'])) {
$input_errors[] = "You must provide a valid URL.";
$dont_update = true;
} elseif (! process_alias_urltable($alias['name'], $alias['url'], 0, true)) {
$input_errors[] = "Unable to fetch usable data.";
$dont_update = true;
}
}
} elseif($_POST['type'] == "url") {
$isfirst = 0;
$address_count = 2;
/* item is a url type */
for($x=0; isset($_POST['address'. $x]); $x++) {
if($_POST['address' . $x]) {
/* fetch down and add in */
$isfirst = 0;
$temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
unlink($temp_filename);
$fda = fopen("{$g['tmp_path']}/tmpfetch","w");
fwrite($fda, "/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
fclose($fda);
mwexec("/bin/mkdir -p {$temp_filename}");
mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
/* if the item is tar gzipped then extract */
if(stristr($_POST['address' . $x], ".tgz"))
process_alias_tgz($temp_filename);
if(file_exists("{$temp_filename}/aliases")) {
$file_contents = file_get_contents("{$temp_filename}/aliases");
$file_contents = str_replace("#", "\n#", $file_contents);
$file_contents_split = split("\n", $file_contents);
foreach($file_contents_split as $fc) {
// Stop at 3000 items, aliases larger than that tend to break both pf and the WebGUI.
if ($address_count >= 3000)
break;
$tmp = trim($fc);
if(stristr($fc, "#")) {
$tmp_split = split("#", $tmp);
$tmp = trim($tmp_split[0]);
}
$tmp = trim($tmp);
if(!empty($tmp) && (is_ipaddr($tmp) || is_subnet($tmp))) {
$address[] = $tmp;
$isfirst = 1;
$address_count++;
}
}
if($isfirst == 0) {
/* nothing was found */
$input_errors[] = "You must provide a valid URL. Could not fetch usable data.";
$dont_update = true;
break;
}
$alias['aliasurl'][] = $_POST['address' . $x];
mwexec("/bin/rm -rf {$temp_filename}");
} else {
$input_errors[] = "You must provide a valid URL.";
$dont_update = true;
break;
}
}
}
} else {
/* item is a normal alias type */
$wrongaliases = "";
for($x=0; $x<4999; $x++) {
if($_POST["address{$x}"] <> "") {
if (is_alias($_POST["address{$x}"])) {
if (!alias_same_type($_POST["address{$x}"], $_POST['type']))
$wrongaliases .= " " . $_POST["address{$x}"];
} else if ($_POST['type'] == "port") {
if (!is_port($_POST["address{$x}"]))
$input_errors[] = $_POST["address{$x}"] . " is not a valid port or alias.";
} else if ($_POST['type'] == "host" || $_POST['type'] == "network") {
if (!is_ipaddr($_POST["address{$x}"])
&& !is_hostname($_POST["address{$x}"])
&& !is_iprange($_POST["address{$x}"]))
$input_errors[] = $_POST["address{$x}"] . " is not a valid {$_POST['type']} alias.";
}
if (is_iprange($_POST["address{$x}"])) {
list($startip, $endip) = explode('-', $_POST["address{$x}"]);
$rangesubnets = ip_range_to_subnet_array($startip, $endip);
$address = array_merge($address, $rangesubnets);
} else {
$tmpaddress = $_POST["address{$x}"];
if(is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] <> "")
$tmpaddress .= "/" . $_POST["address_subnet{$x}"];
$address[] = $tmpaddress;
}
if ($_POST["detail{$x}"] <> "")
$final_address_details[] = $_POST["detail{$x}"];
else
$final_address_details[] = "Entry added " . date('r');
}
}
if ($wrongaliases <> "")
$input_errors[] = "The alias(es): {$wrongaliases} \ncannot be nested cause they are not of the same type.";
}
if (!$input_errors) {
$alias['address'] = is_array($address) ? implode(" ", $address) : $address;
$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
$alias['type'] = $_POST['type'];
$alias['detail'] = implode("||", $final_address_details);
/* Check to see if alias name needs to be
* renamed on referenced rules and such
*/
if ($_POST['name'] <> $_POST['origname']) {
// Firewall rules
update_alias_names_upon_change('filter', 'rule', 'source', 'address', $_POST['name'], $origname);
update_alias_names_upon_change('filter', 'rule', 'destination', 'address', $_POST['name'], $origname);
// NAT Rules
update_alias_names_upon_change('nat', 'rule', 'source', 'address', $_POST['name'], $origname);
update_alias_names_upon_change('nat', 'rule', 'source', 'port', $_POST['name'], $origname);
update_alias_names_upon_change('nat', 'rule', 'destination', 'address', $_POST['name'], $origname);
update_alias_names_upon_change('nat', 'rule', 'destination', 'port', $_POST['name'], $origname);
update_alias_names_upon_change('nat', 'rule', 'target', '', $_POST['name'], $origname);
update_alias_names_upon_change('nat', 'rule', 'local-port', '' , $_POST['name'], $origname);
// Alias in an alias
update_alias_names_upon_change('aliases', 'alias', 'address', '' , $_POST['name'], $origname);
}
if (isset($id) && $a_aliases[$id]) {
if ($a_aliases[$id]['name'] <> $alias['name']) {
foreach ($a_aliases as $aliasid => $aliasd) {
if ($aliasd['address'] <> "") {
$tmpdirty = false;
$tmpaddr = explode(" ", $aliasd['address']);
foreach ($tmpaddr as $tmpidx => $tmpalias) {
if ($tmpalias == $a_aliases[$id]['name']) {
$tmpaddr[$tmpidx] = $alias['name'];
$tmpdirty = true;
}
}
if ($tmpdirty == true)
$a_aliases[$aliasid]['address'] = implode(" ", $tmpaddr);
}
}
}
$a_aliases[$id] = $alias;
} else
$a_aliases[] = $alias;
mark_subsystem_dirty('aliases');
// Sort list
$a_aliases = msort($a_aliases, "name");
write_config();
filter_configure();
header("Location: firewall_aliases.php");
exit;
}
//we received input errors, copy data to prevent retype
else
{
$pconfig['name'] = $_POST['name'];
$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
$pconfig['address'] = implode(" ", $address);
$pconfig['type'] = $_POST['type'];
$pconfig['detail'] = implode("||", $final_address_details);
}
}
include("head.inc");
$jscriptstr = <<<EOD
<script type="text/javascript">
var objAlias = new Array(4999);
function typesel_change() {
switch (document.iform.type.selectedIndex) {
case 0: /* host */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
eval(comd);
comd = 'document.iform.address_subnet' + i + '.value = "";';
eval(comd);
}
break;
case 1: /* network */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
eval(comd);
}
break;
case 2: /* port */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
eval(comd);
comd = 'document.iform.address_subnet' + i + '.value = "32";';
eval(comd);
}
break;
case 3: /* OpenVPN Users */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
eval(comd);
comd = 'document.iform.address_subnet' + i + '.value = "";';
eval(comd);
}
break;
case 4: /* url */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
eval(comd);
}
break;
case 5: /* urltable */
var cmd;
newrows = totalrows;
for(i=0; i<newrows; i++) {
comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
eval(comd);
}
break;
}
}
function add_alias_control() {
var name = "address" + (totalrows - 1);
obj = document.getElementById(name);
obj.setAttribute('class', 'formfldalias');
obj.setAttribute('autocomplete', 'off');
objAlias[totalrows - 1] = new AutoSuggestControl(obj, new StateSuggestions(addressarray));
}
EOD;
$network_str = gettext("Network");
$networks_str = gettext("Network(s)");
$cidr_str = gettext("CIDR");
$description_str = gettext("Description");
$hosts_str = gettext("Host(s)");
$ip_str = gettext("IP");
$ports_str = gettext("Port(s)");
$port_str = gettext("Port");
$url_str = gettext("URL");
$urltable_str = gettext("URL Table");
$update_freq_str = gettext("Update Freq.");
$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. You may also enter an IP range such as 192.168.1.1-192.168.1.254 and a list of CIDR networks will be derived to fill the range.");
$hosts_help = gettext("Enter as many hosts as you would like. Hosts must be specified by their IP address.");
$ports_help = gettext("Enter as many ports as you wish. Port ranges can be expressed by seperating with a colon.");
$url_help = gettext("Enter as many URLs as you wish. After saving {$g['product_name']} will download the URL and import the items into the alias. Use only with small sets of IP addresses (less than 3000).");
$urltable_help = gettext("Enter a single URL containing a large number of IPs and/or Subnets. After saving {$g['product_name']} will download the URL and create a table file containing these addresses. This will work with large numbers of addresses (30,000+) or small numbers.");
$openvpn_str = gettext("Username");
$openvpn_user_str = gettext("OpenVPN Users");
$openvpn_help = gettext("Enter as many usernames as you wish.");
$openvpn_freq = gettext("");
$jscriptstr .= <<<EOD
function update_box_type() {
var indexNum = document.forms[0].type.selectedIndex;
var selected = document.forms[0].type.options[indexNum].text;
if(selected == '{$networks_str}') {
document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
document.getElementById ("addrowbutton").style.display = 'block';
} else if(selected == '{$hosts_str}') {
document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
document.getElementById ("twocolumn").firstChild.data = "";
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
document.getElementById ("addrowbutton").style.display = 'block';
} else if(selected == '{$ports_str}') {
document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
document.getElementById ("twocolumn").firstChild.data = "";
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
document.getElementById ("addrowbutton").style.display = 'block';
} else if(selected == '{$url_str}') {
document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
document.getElementById ("twocolumn").firstChild.data = "";
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
document.getElementById ("addrowbutton").style.display = 'block';
} else if(selected == '{$openvpn_user_str}') {
document.getElementById ("addressnetworkport").firstChild.data = "{$openvpn_user_str}";
document.getElementById ("onecolumn").firstChild.data = "{$openvpn_str}";
document.getElementById ("twocolumn").firstChild.data = "{$openvpn_freq}";
document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
document.getElementById ("itemhelp").firstChild.data = "{$openvpn_help}";
document.getElementById ("addrowbutton").style.display = 'block';
} else if(selected == '{$urltable_str}') {
if ((typeof(totalrows) == "undefined") || (totalrows < 1)) {
addRowTo('maintable', 'formfldalias');
typesel_change();
add_alias_control(this);
}
document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
document.getElementById ("threecolumn").firstChild.data = "";
document.getElementById ("threecolumn").style.display = 'none';
document.getElementById ("itemhelp").firstChild.data = "{$urltable_help}";
document.getElementById ("addrowbutton").style.display = 'none';
}
}
</script>
EOD;
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
<?php
include("fbegin.inc");
echo $jscriptstr;
?>
<script type="text/javascript" src="/javascript/row_helper.js">
</script>
<script type="text/javascript" src="/javascript/autosuggest.js">
</script>
<script type="text/javascript" src="/javascript/suggestions.js">
</script>
<input type='hidden' name='address_type' value='textbox' />
<input type='hidden' name='address_subnet_type' value='select' />
<script type="text/javascript">
rowname[0] = "address";
rowtype[0] = "textbox";
rowsize[0] = "30";
rowname[1] = "address_subnet";
rowtype[1] = "select";
rowsize[1] = "1";
rowname[2] = "detail";
rowtype[2] = "textbox";
rowsize[2] = "50";
</script>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<div id="inputerrors"></div>
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic">Alias Edit</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Name</td>
<td class="vtable">
<input name="origname" type="hidden" id="origname" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
<input name="name" type="text" id="name" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
<?php if (isset($id) && $a_aliases[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>" />
<?php endif; ?>
<br />
<span class="vexpl">
The name of the alias may only consist of the characters a-z, A-Z and 0-9.
</span>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
<td width="78%" class="vtable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
<br />
<span class="vexpl">
You may enter a description here for your reference (not parsed).
</span>
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Type</td>
<td class="vtable">
<select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
<option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
<option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
<option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
<option value="openvpn" <?php if ($pconfig['type'] == "openvpn") echo "selected"; ?>>OpenVPN Users</option>
<option value="url" <?php if ($pconfig['type'] == "url") echo "selected"; ?>>URL</option>
<option value="urltable" <?php if ($pconfig['type'] == "urltable") echo "selected"; ?>>URL Table</option>
</select>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
<td width="78%" class="vtable">
<table id="maintable">
<tbody>
<tr>
<td colspan="4">
<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>
</td>
</tr>
<tr>
<td><div id="onecolumn">Network</div></td>
<td><div id="twocolumn">CIDR</div></td>
<td><div id="threecolumn">Description</div></td>
</tr>
<?php
$counter = 0;
$address = $pconfig['address'];
if ($address <> "") {
$item = explode(" ", $address);
$item3 = explode("||", $pconfig['detail']);
foreach($item as $ww) {
$address = $item[$counter];
$address_subnet = "";
$item2 = explode("/", $address);
foreach($item2 as $current) {
if($item2[1] <> "") {
$address = $item2[0];
$address_subnet = $item2[1];
}
}
$item4 = $item3[$counter];
$tracker = $counter;
?>
<tr>
<td>
<input autocomplete="off" name="address<?php echo $tracker; ?>" type="text" class="formfldalias" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
</td>
<td>
<select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
<option></option>
<?php for ($i = 32; $i >= 1; $i--): ?>
<option value="<?=$i;?>" <?php if (($i == $address_subnet) || ($i == $pconfig['updatefreq'])) echo "selected"; ?>><?=$i;?></option>
<?php endfor; ?>
</select>
</td>
<td>
<input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
</td>
<td>
<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
</td>
</tr>
<?php
$counter++;
} // end foreach
} // end if
?>
</tbody>
<tfoot>
</tfoot>
</table>
<div id="addrowbutton"><a onclick="javascript:addRowTo('maintable', 'formfldalias'); typesel_change(); add_alias_control(this); return false;" href="#">
<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" /></div>
</a>
</td>
</tr>
<tr>
<td width="22%" valign="top"> </td>
<td width="78%">
<input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
<a href="firewall_aliases.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
field_counter_js = 3;
rows = 1;
totalrows = <?php echo $counter; ?>;
loaded = <?php echo $counter; ?>;
typesel_change();
update_box_type();
<?php
$isfirst = 0;
$aliases = "";
$addrisfirst = 0;
$aliasesaddr = "";
if(isset($config['aliases']['alias']) && is_array($config['aliases']['alias']))
foreach($config['aliases']['alias'] as $alias_name) {
if ($pconfig['name'] <> "" && $pconfig['name'] == $alias_name['name'])
continue;
if($addrisfirst == 1) $aliasesaddr .= ",";
$aliasesaddr .= "'" . $alias_name['name'] . "'";
$addrisfirst = 1;
}
?>
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
function createAutoSuggest() {
<?php
for ($jv = 0; $jv < $counter; $jv++)
echo "objAlias[{$jv}] = new AutoSuggestControl(document.getElementById(\"address{$jv}\"), new StateSuggestions(addressarray));\n";
?>
}
setTimeOut("createAutoSuggest();", 500);
</script>
<?php include("fend.inc"); ?>
</body>
</html>
|