Project

General

Profile

Download (22.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_aliases_edit.php
5
	Copyright (C) 2004 Scott Ullrich
6
	Copyright (C) 2009 Ermal Lu?i
7
	Copyright (C) 2010 Jim Pingle
8
	All rights reserved.
9

    
10
	originially part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
/*
36
	pfSense_BUILDER_BINARIES:	/bin/rm	/bin/mkdir	/usr/bin/fetch
37
	pfSense_MODULE:	aliases
38
*/
39

    
40
##|+PRIV
41
##|*IDENT=page-firewall-alias-edit
42
##|*NAME=Firewall: Alias: Edit page
43
##|*DESCR=Allow access to the 'Firewall: Alias: Edit' page.
44
##|*MATCH=firewall_aliases_edit.php*
45
##|-PRIV
46

    
47
$pgtitle = array("Firewall","Aliases","Edit");
48

    
49
// Keywords not allowed in names
50
$reserved_keywords = array("pass", "out", "queue", "max", "min", "pptp", "pppoe", "l2tp", "openvpn");
51

    
52
require("guiconfig.inc");
53
require_once("functions.inc");
54
require_once("filter.inc");
55
require_once("shaper.inc");
56

    
57
$reserved_ifs = get_configured_interface_list(false, true);
58
$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs);
59

    
60
if (!is_array($config['aliases']['alias']))
61
	$config['aliases']['alias'] = array();
62
$a_aliases = &$config['aliases']['alias'];
63
	
64
if($_POST)
65
	$origname = $_POST['origname'];
66

    
67
// Debugging
68
if($debug)
69
	exec("rm -f {$g['tmp_path']}/alias_rename_log.txt");
70

    
71
function alias_same_type($name, $type) {
72
	global $config;
73
	
74
	foreach ($config['aliases']['alias'] as $alias) {
75
		if ($name == $alias['name']) {
76
			if (in_array($type, array("host", "network")) &&
77
				in_array($alias['type'], array("host", "network")))
78
				return true;
79
			if ($type  == $alias['type'])
80
				return true;
81
			else
82
				return false;
83
		}
84
	}
85
	return true;
86
}
87

    
88
$id = $_GET['id'];
89
if (isset($_POST['id']))
90
	$id = $_POST['id'];
91

    
92
if (isset($id) && $a_aliases[$id]) {
93
	$original_alias_name = $a_aliases[$id]['name'];
94
	$pconfig['name'] = $a_aliases[$id]['name'];
95
	$pconfig['detail'] = $a_aliases[$id]['detail'];
96
	$pconfig['address'] = $a_aliases[$id]['address'];
97
	$pconfig['type'] = $a_aliases[$id]['type'];
98
	$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
99

    
100
	/* optional if list */
101
	$iflist = get_configured_interface_with_descr(true, true);
102
	foreach ($iflist as $if => $ifdesc)
103
		if($ifdesc == $pconfig['descr']) 
104
			$input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}.";
105

    
106

    
107
	if($a_aliases[$id]['aliasurl'] <> "") {
108
		$pconfig['type'] = "url";
109
		if(is_array($a_aliases[$id]['aliasurl'])) {
110
			$isfirst = 0;
111
			$pconfig['address'] = "";
112
			foreach($a_aliases[$id]['aliasurl'] as $aa) {
113
				if($isfirst == 1)
114
					$pconfig['address'] .= " ";
115
				$isfirst = 1;
116
				$pconfig['address'] .= $aa;
117
			}
118
		} else {
119
			$pconfig['address'] = $a_aliases[$id]['aliasurl'];
120
		}
121
	}
122
}
123

    
124
if ($_POST) {
125

    
126
	unset($input_errors);
127

    
128
	/* input validation */
129

    
130
	$reqdfields = explode(" ", "name");
131
	$reqdfieldsn = explode(",", "Name");
132

    
133
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
134

    
135
	$x = is_validaliasname($_POST['name']);
136
	if (!isset($x)) {
137
		$input_errors[] = "Reserved word used for alias name.";
138
	} else if ($_POST['type'] == "port" && (getservbyname($_POST['name'], "tcp") || getservbyname($_POST['name'], "udp"))) {
139
		$input_errors[] = "Reserved word used for alias name.";
140
	} else {
141
		if (is_validaliasname($_POST['name']) == false)
142
			$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, _.";
143
	}
144
	/* check for name conflicts */
145
	if (empty($a_aliases[$id])) {
146
		foreach ($a_aliases as $alias) {
147
			if ($alias['name'] == $_POST['name']) {
148
				$input_errors[] = "An alias with this name already exists.";
149
				break;
150
			}
151
		}
152
	}
153

    
154
	/* Check for reserved keyword names */
155
	foreach($reserved_keywords as $rk) 
156
		if($rk == $_POST['name'])
157
			$input_errors[] = "Cannot use a reserved keyword as alias name $rk";
158

    
159
	/* check for name interface description conflicts */
160
	foreach($config['interfaces'] as $interface) {
161
		if($interface['descr'] == $_POST['name']) {
162
			$input_errors[] = "An interface description with this name already exists.";
163
			break;
164
		}
165
	}
166
	
167
	$alias = array();
168
	$address = array();
169
	$final_address_details = array();
170
	$alias['name'] = $_POST['name'];
171
	if($_POST['type'] == "url") {
172
		$isfirst = 0;
173
		$address_count = 2;
174

    
175
		/* item is a url type */
176
		for($x=0; isset($_POST['address'. $x]); $x++) {
177
			if($_POST['address' . $x]) {
178
				/* fetch down and add in */
179
				$isfirst = 0;
180
				$temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
181
				unlink($temp_filename);
182
				$fda = fopen("{$g['tmp_path']}/tmpfetch","w");
183
				fwrite($fda, "/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
184
				fclose($fda);
185
				mwexec("/bin/mkdir -p {$temp_filename}");
186
				mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
187
				/* if the item is tar gzipped then extract */
188
				if(stristr($_POST['address' . $x], ".tgz"))
189
					process_alias_tgz($temp_filename);
190
				if(file_exists("{$temp_filename}/aliases")) {
191
					$file_contents = file_get_contents("{$temp_filename}/aliases");
192
					$file_contents = str_replace("#", "\n#", $file_contents);
193
					$file_contents_split = split("\n", $file_contents);
194
					foreach($file_contents_split as $fc) {
195
						$tmp = trim($fc);
196
						if(stristr($fc, "#")) {
197
							$tmp_split = split("#", $tmp);
198
							$tmp = trim($tmp_split[0]);
199
						}
200
						if(trim($tmp) <> "") {
201
							$address[] = $tmp;
202
							$isfirst = 1;
203
						}
204
					}
205
					if($isfirst == 0) {
206
						/* nothing was found */
207
						$input_errors[] = "You must provide a valid URL. Could not fetch usable data.";
208
						$dont_update = true;
209
						break;
210
					}
211
					$alias['aliasurl'][] = $_POST['address' . $x];
212
					mwexec("/bin/rm -rf {$temp_filename}");
213
				} else {
214
					$input_errors[] = "You must provide a valid URL.";
215
					$dont_update = true;
216
					break;
217
				}
218
			}
219
		}
220
	} else {
221
		/* item is a normal alias type */
222
		$wrongaliases = "";
223
		for($x=0; $x<4999; $x++) {
224
			if($_POST["address{$x}"] <> "") {
225
				if (is_alias($_POST["address{$x}"])) {
226
					if (!alias_same_type($_POST["address{$x}"], $_POST['type']))
227
						$wrongaliases .= " " . $_POST["address{$x}"];
228
				} else if ($_POST['type'] == "port") {
229
					if (!is_port($_POST["address{$x}"]))
230
						$input_errors[] = $_POST["address{$x}"] . " is not a valid port or alias.";
231
				} else if ($_POST['type'] == "host" || $_POST['type'] == "network") {
232
					if (!is_ipaddr($_POST["address{$x}"])
233
					 && !is_hostname($_POST["address{$x}"])
234
					 && !is_iprange($_POST["address{$x}"]))
235
						$input_errors[] = $_POST["address{$x}"] . " is not a valid {$_POST['type']} alias.";
236
				}
237
				if (is_iprange($_POST["address{$x}"])) {
238
					list($startip, $endip) = explode('-', $_POST["address{$x}"]);
239
					$rangesubnets = ip_range_to_subnet_array($startip, $endip);
240
					$address = array_merge($address, $rangesubnets);
241
				} else {
242
					$tmpaddress = $_POST["address{$x}"];
243
					if(($_POST['type'] == "network" || is_ipaddr($_POST["address{$x}"])) && $_POST["address_subnet{$x}"] <> "")
244
						$tmpaddress .= "/" . $_POST["address_subnet{$x}"];
245
					$address[] = $tmpaddress;
246
				}
247
				if ($_POST["detail{$x}"] <> "")
248
					$final_address_details[] = $_POST["detail{$x}"];
249
				else
250
					$final_address_details[] = "Entry added " . date('r');
251
			}
252
		}
253
		if ($wrongaliases <> "")
254
			$input_errors[] = "The alias(es): {$wrongaliases} \ncannot be nested cause they are not of the same type.";
255
	}
256

    
257
	if (!$input_errors) {
258
		$alias['address'] = implode(" ", $address);
259
		$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
260
		$alias['type'] = $_POST['type'];
261
		$alias['detail'] = implode("||", $final_address_details);
262

    
263
		/*   Check to see if alias name needs to be
264
		 *   renamed on referenced rules and such
265
		 */
266
		if ($_POST['name'] <> $_POST['origname']) {
267
			// Firewall rules
268
			update_alias_names_upon_change('filter', 'rule', 'source', 'address', $_POST['name'], $origname);
269
			update_alias_names_upon_change('filter', 'rule', 'destination', 'address', $_POST['name'], $origname);
270
			// NAT Rules
271
			update_alias_names_upon_change('nat', 'rule', 'target', '', $_POST['name'], $origname);
272
			update_alias_names_upon_change('nat', 'rule', 'external-port', '', $_POST['name'], $origname);
273
			update_alias_names_upon_change('nat', 'rule', 'local-port', ''	, $_POST['name'], $origname);
274
			// Alias in an alias
275
			update_alias_names_upon_change('aliases', 'alias', 'address', ''	, $_POST['name'], $origname);
276
		}
277

    
278
		if (isset($id) && $a_aliases[$id]) {
279
			if ($a_aliases[$id]['name'] <> $alias['name']) {
280
				foreach ($a_aliases as $aliasid => $aliasd) {
281
					if ($aliasd['address'] <> "") {
282
						$tmpdirty = false;
283
						$tmpaddr = explode(" ", $aliasd['address']);
284
						foreach ($tmpaddr as $tmpidx => $tmpalias) {
285
							if ($tmpalias == $a_aliases[$id]['name']) {
286
								$tmpaddr[$tmpidx] = $alias['name'];
287
								$tmpdirty = true;
288
							}
289
						}
290
						if ($tmpdirty == true)
291
							$a_aliases[$aliasid]['address'] = implode(" ", $tmpaddr);
292
					}
293
				}
294
			}
295
			$a_aliases[$id] = $alias;
296
		} else
297
			$a_aliases[] = $alias;
298

    
299
		mark_subsystem_dirty('aliases');
300

    
301
		// Sort list
302
		$a_aliases = msort($a_aliases, "name");
303

    
304
		write_config();
305
		filter_configure();
306

    
307
		header("Location: firewall_aliases.php");
308
		exit;		
309
	}
310
	//we received input errors, copy data to prevent retype
311
	else
312
	{
313
		$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
314
		$pconfig['address'] = implode(" ", $address);
315
		$pconfig['type'] = $_POST['type'];
316
		$pconfig['detail'] = implode("||", $final_address_details);
317
	}
318
}
319

    
320
include("head.inc");
321

    
322
$jscriptstr = <<<EOD
323

    
324
<script type="text/javascript">
325

    
326
var objAlias = new Array(4999);
327
function typesel_change() {
328
	switch (document.iform.type.selectedIndex) {
329
		case 0:	/* host */
330
			var cmd;
331

    
332
			newrows = totalrows;
333
			for(i=0; i<newrows; i++) {
334
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
335
				eval(comd);
336
				comd = 'document.iform.address_subnet' + i + '.value = "";';
337
				eval(comd);
338
			}
339
			break;
340
		case 1:	/* network */
341
			var cmd;
342

    
343
			newrows = totalrows;
344
			for(i=0; i<newrows; i++) {
345
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
346
				eval(comd);
347
			}
348
			break;
349
		case 2:	/* port */
350
			var cmd;
351

    
352
			newrows = totalrows;
353
			for(i=0; i<newrows; i++) {
354
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
355
				eval(comd);
356
				comd = 'document.iform.address_subnet' + i + '.value = "32";';
357
				eval(comd);
358
			}
359
			break;
360
		case 3:	/* OpenVPN Users */
361
			var cmd;
362

    
363
			newrows = totalrows;
364
			for(i=0; i<newrows; i++) {
365
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
366
				eval(comd);
367
				comd = 'document.iform.address_subnet' + i + '.value = "";';
368
				eval(comd);
369
			}
370
			break;
371

    
372
		case 4:	/* url */
373
			var cmd;
374
			newrows = totalrows;
375
			for(i=0; i<newrows; i++) {
376
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
377
				eval(comd);
378
			}
379
			break;
380
	}
381
}
382

    
383
function add_alias_control() {
384
	var name = "address" + (totalrows - 1);
385
	obj = document.getElementById(name);
386
	obj.setAttribute('class', 'formfldalias');
387
	obj.setAttribute('autocomplete', 'off');
388
	objAlias[totalrows - 1] = new AutoSuggestControl(obj, new StateSuggestions(addressarray));
389
}
390
EOD;
391

    
392
$network_str = gettext("Network");
393
$networks_str = gettext("Network(s)");
394
$cidr_str = gettext("CIDR");
395
$description_str = gettext("Description");
396
$hosts_str = gettext("Host(s)");
397
$ip_str = gettext("IP");
398
$ports_str = gettext("Port(s)");
399
$port_str = gettext("Port");
400
$url_str = gettext("URL");
401
$update_freq_str = gettext("Update Freq.");
402

    
403
$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.");
404
$hosts_help = gettext("Enter as many hosts as you would like.  Hosts must be specified by their IP address.");
405
$ports_help = gettext("Enter as many ports as you wish.  Port ranges can be expressed by seperating with a colon.");
406
$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.");
407

    
408
$openvpn_str = gettext("Username");
409
$openvpn_user_str = gettext("OpenVPN Users");
410
$openvpn_help = gettext("Enter as many usernames as you wish.");
411
$openvpn_freq = gettext("");
412

    
413
$jscriptstr .= <<<EOD
414

    
415
function update_box_type() {
416
	var indexNum = document.forms[0].type.selectedIndex;
417
	var selected = document.forms[0].type.options[indexNum].text;
418
	if(selected == '{$networks_str}') {
419
		document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
420
		document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
421
		document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
422
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
423
		document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
424
	} else if(selected == '{$hosts_str}') {
425
		document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
426
		document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
427
		document.getElementById ("twocolumn").firstChild.data = "";
428
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
429
		document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
430
	} else if(selected == '{$ports_str}') {
431
		document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
432
		document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
433
		document.getElementById ("twocolumn").firstChild.data = "";
434
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
435
		document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
436
	} else if(selected == '{$url_str}') {
437
		document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
438
		document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
439
		document.getElementById ("twocolumn").firstChild.data = "";
440
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
441
		document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
442
	} else if(selected == '{$openvpn_user_str}') {
443
		document.getElementById ("addressnetworkport").firstChild.data = "{$openvpn_user_str}";
444
		document.getElementById ("onecolumn").firstChild.data = "{$openvpn_str}";
445
		document.getElementById ("twocolumn").firstChild.data = "{$openvpn_freq}";
446
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
447
		document.getElementById ("itemhelp").firstChild.data = "{$openvpn_help}";
448
	}
449
}
450
</script>
451

    
452
EOD;
453

    
454
?>
455

    
456
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
457
<?php
458
	include("fbegin.inc");
459
	echo $jscriptstr;
460
?>
461

    
462
<script type="text/javascript" src="/javascript/row_helper.js">
463
</script>
464
<script type="text/javascript" src="/javascript/autosuggest.js">
465
</script>
466
<script type="text/javascript" src="/javascript/suggestions.js">
467
</script>
468

    
469
<input type='hidden' name='address_type' value='textbox' />
470
<input type='hidden' name='address_subnet_type' value='select' />
471

    
472
<script type="text/javascript">
473
	rowname[0] = "address";
474
	rowtype[0] = "textbox";
475
	rowsize[0] = "30";
476

    
477
	rowname[1] = "address_subnet";
478
	rowtype[1] = "select";
479
	rowsize[1] = "1";
480

    
481
	rowname[2] = "detail";
482
	rowtype[2] = "textbox";
483
	rowsize[2] = "50";
484
</script>
485

    
486
<?php if ($input_errors) print_input_errors($input_errors); ?>
487
<div id="inputerrors"></div>
488

    
489
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
490
<table width="100%" border="0" cellpadding="6" cellspacing="0">
491
  <tr>
492
	<td colspan="2" valign="top" class="listtopic">Alias Edit</td>
493
  </tr>
494
  <tr>
495
    <td valign="top" class="vncellreq">Name</td>
496
    <td class="vtable">
497
      <input name="origname" type="hidden" id="origname" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
498
      <input name="name" type="text" id="name" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
499
      <?php if (isset($id) && $a_aliases[$id]): ?>
500
      <input name="id" type="hidden" value="<?=$id;?>" />
501
      <?php endif; ?>
502
      <br />
503
      <span class="vexpl">
504
        The name of the alias may only consist of the characters a-z, A-Z and 0-9.
505
      </span>
506
    </td>
507
  </tr>
508
  <tr>
509
    <td width="22%" valign="top" class="vncell">Description</td>
510
    <td width="78%" class="vtable">
511
      <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
512
      <br />
513
      <span class="vexpl">
514
        You may enter a description here for your reference (not parsed).
515
      </span>
516
    </td>
517
  </tr>
518
  <tr>
519
    <td valign="top" class="vncellreq">Type</td>
520
    <td class="vtable">
521
      <select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
522
        <option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
523
        <option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
524
        <option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
525
        <option value="openvpn" <?php if ($pconfig['type'] == "openvpn") echo "selected"; ?>>OpenVPN Users</option>
526
        <option value="url" <?php if ($pconfig['type'] == "url") echo "selected"; ?>>URL</option>
527
      </select>
528
    </td>
529
  </tr>
530
  <tr>
531
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
532
    <td width="78%" class="vtable">
533
      <table id="maintable">
534
        <tbody>
535
          <tr>
536
            <td colspan="4">
537
      		    <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>
538
            </td>
539
          </tr>
540
          <tr>
541
            <td><div id="onecolumn">Network</div></td>
542
            <td><div id="twocolumn">CIDR</div></td>
543
           <td><div id="threecolumn">Description</div></td>
544
          </tr>
545

    
546
	<?php
547
	$counter = 0;
548
	$address = $pconfig['address'];
549
	if ($address <> "") {
550
		$item = explode(" ", $address);
551
		$item3 = explode("||", $pconfig['detail']);
552
		foreach($item as $ww) {
553
			$address = $item[$counter];
554
			$address_subnet = "";
555
			$item2 = explode("/", $address);
556
			foreach($item2 as $current) {
557
				if($item2[1] <> "") {
558
					$address = $item2[0];
559
					$address_subnet = $item2[1];
560
				}
561
				
562
			}
563
			$item4 = $item3[$counter];
564
			$tracker = $counter;
565
	?>
566
          <tr>
567
            <td>
568
              <input autocomplete="off" name="address<?php echo $tracker; ?>" type="text" class="formfldalias" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
569
            </td>
570
            <td>
571
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
572
				<option></option>
573
			          <?php for ($i = 32; $i >= 1; $i--): ?>
574
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
575
			          <?php endfor; ?>
576
			        </select>
577
			      </td>
578
            <td>
579
              <input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
580
            </td>
581
            <td>
582
    		<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
583
	      </td>
584
          </tr>
585
<?php
586
        	$counter++;
587

    
588
       		} // end foreach
589
	} // end if
590
?>
591
        </tbody>
592
        <tfoot>
593

    
594
        </tfoot>
595
		  </table>
596
			<a onclick="javascript:addRowTo('maintable', 'formfldalias'); typesel_change(); add_alias_control(this); return false;" href="#">
597
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
598
      </a>
599
		</td>
600
  </tr>
601
  <tr>
602
    <td width="22%" valign="top">&nbsp;</td>
603
    <td width="78%">
604
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
605
      <a href="firewall_aliases.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
606
    </td>
607
  </tr>
608
</table>
609
</form>
610

    
611
<script type="text/javascript">
612
	field_counter_js = 3;
613
	rows = 1;
614
	totalrows = <?php echo $counter; ?>;
615
	loaded = <?php echo $counter; ?>;
616
	typesel_change();
617
	update_box_type();
618

    
619
<?php
620
        $isfirst = 0;
621
        $aliases = "";
622
        $addrisfirst = 0;
623
        $aliasesaddr = "";
624
        if(isset($config['aliases']['alias']) && is_array($config['aliases']['alias']))
625
                foreach($config['aliases']['alias'] as $alias_name) {
626
			if ($pconfig['name'] <> "" && $pconfig['name'] == $alias_name['name'])
627
				continue;
628
			if($addrisfirst == 1) $aliasesaddr .= ",";
629
			$aliasesaddr .= "'" . $alias_name['name'] . "'";
630
			$addrisfirst = 1;
631
                }
632
?>
633

    
634
        var addressarray=new Array(<?php echo $aliasesaddr; ?>);
635

    
636
function createAutoSuggest() {
637
<?php  
638
	for ($jv = 0; $jv < $counter; $jv++)
639
		echo "objAlias[{$jv}] = new AutoSuggestControl(document.getElementById(\"address{$jv}\"), new StateSuggestions(addressarray));\n";
640
?>
641
}
642

    
643
setTimeOut("createAutoSuggest();", 500);
644

    
645
</script>
646

    
647
<?php include("fend.inc"); ?>
648
</body>
649
</html>
(49-49/218)