Project

General

Profile

Download (60.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules_edit.php
5
	part of pfSense (http://www.pfsense.com)
6
        Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

    
8
	originally 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
	pfSense_MODULE:	filter
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-rules-edit
39
##|*NAME=Firewall: Rules: Edit page
40
##|*DESCR=Allow access to the 'Firewall: Rules: Edit' page.
41
##|*MATCH=firewall_rules_edit.php*
42
##|-PRIV
43

    
44
require("guiconfig.inc");
45
require("filter.inc");
46
require("shaper.inc");
47

    
48
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
49
$ifdisp = get_configured_interface_with_descr();
50
foreach ($ifdisp as $kif => $kdescr) {
51
	$specialsrcdst[] = "{$kif}";
52
	$specialsrcdst[] = "{$kif}ip";
53
}
54

    
55
if (!is_array($config['filter']['rule'])) {
56
	$config['filter']['rule'] = array();
57
}
58
filter_rules_sort();
59
$a_filter = &$config['filter']['rule'];
60

    
61
$id = $_GET['id'];
62
if (is_numeric($_POST['id']))
63
	$id = $_POST['id'];
64

    
65
$after = $_GET['after'];
66

    
67
if (isset($_POST['after']))
68
	$after = $_POST['after'];
69

    
70
if (isset($_GET['dup'])) {
71
	$id = $_GET['dup'];
72
	$after = $_GET['dup'];
73
}
74

    
75
if (isset($id) && $a_filter[$id]) {
76
	$pconfig['interface'] = $a_filter[$id]['interface'];
77

    
78
	if (isset($a_filter[$id]['id']))
79
		$pconfig['ruleid'] = $a_filter[$id]['id'];
80

    
81
	if (!isset($a_filter[$id]['type']))
82
		$pconfig['type'] = "pass";
83
	else
84
		$pconfig['type'] = $a_filter[$id]['type'];
85

    
86
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
87
		$pconfig['floating'] = $a_filter[$id]['floating'];
88
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "") 
89
			$pconfig['interface'] = $a_filter[$id]['interface'];
90
	}
91
	
92
	if (isset($a_filter['floating'])) 
93
		$pconfig['floating'] = "yes";
94

    
95
	if (isset($a_filter[$id]['direction']))
96
                $pconfig['direction'] = $a_filter[$id]['direction'];
97

    
98
	if (isset($a_filter[$id]['protocol']))
99
		$pconfig['proto'] = $a_filter[$id]['protocol'];
100
	else
101
		$pconfig['proto'] = "any";
102

    
103
	if ($a_filter[$id]['protocol'] == "icmp")
104
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
105

    
106
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
107
		$pconfig['srcmask'], $pconfig['srcnot'],
108
		$pconfig['srcbeginport'], $pconfig['srcendport']);
109

    
110
	if($a_filter[$id]['os'] <> "")
111
		$pconfig['os'] = $a_filter[$id]['os'];
112

    
113
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
114
		$pconfig['dstmask'], $pconfig['dstnot'],
115
		$pconfig['dstbeginport'], $pconfig['dstendport']);
116

    
117
	if ($a_filter[$id]['dscp'] <> "")
118
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
119

    
120
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
121
	$pconfig['log'] = isset($a_filter[$id]['log']);
122
	$pconfig['descr'] = $a_filter[$id]['descr'];
123

    
124
	if (isset($a_filter[$id]['tcpflags_any']))
125
		$pconfig['tcpflags_any'] = true;
126
	else {
127
		if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "") 
128
			$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
129
		if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "") 
130
			$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
131
	}
132

    
133
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "") 
134
		$pconfig['tag'] = $a_filter[$id]['tag'];
135
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
136
        	$pconfig['tagged'] = $a_filter[$id]['tagged'];
137
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
138
		$pconfig['quick'] = $a_filter[$id]['quick'];
139
	if (isset($a_filter[$id]['allowopts']))
140
		$pconfig['allowopts'] = true;
141
	if (isset($a_filter[$id]['disablereplyto']))
142
		$pconfig['disablereplyto'] = true;
143

    
144
	/* advanced */
145
	$pconfig['max'] = $a_filter[$id]['max'];
146
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
147
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
148
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
149
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
150
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
151

    
152
	/* advanced - nosync */
153
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
154

    
155
	/* advanced - new connection per second banning*/
156
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
157
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
158

    
159
	/* Multi-WAN next-hop support */
160
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
161
	
162
	/* Shaper support */
163
	$pconfig['defaultqueue'] = $a_filter[$id]['defaultqueue'];
164
	$pconfig['ackqueue'] = $a_filter[$id]['ackqueue'];
165
	$pconfig['dnpipe'] = $a_filter[$id]['dnpipe'];
166
	$pconfig['pdnpipe'] = $a_filter[$id]['pdnpipe'];
167
	$pconfig['l7container'] = $a_filter[$id]['l7container'];
168

    
169
	//schedule support
170
	$pconfig['sched'] = $a_filter[$id]['sched'];
171
	if (!isset($_GET['dup']))
172
		$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
173

    
174
} else {
175
	/* defaults */
176
	if ($_GET['if'])
177
		$pconfig['interface'] = $_GET['if'];
178
	$pconfig['type'] = "pass";
179
	$pconfig['src'] = "any";
180
	$pconfig['dst'] = "any";
181
}
182
/* Allow the FlotingRules to work */
183
$if = $pconfig['interface'];
184

    
185
if (isset($_GET['dup']))
186
	unset($id);
187

    
188
if ($_POST) {
189

    
190
	if( isset($a_filter[$id]['associated-rule-id']) ) {
191
		$_POST['proto'] = $pconfig['proto'];
192
		if ($pconfig['proto'] == "icmp")
193
			$_POST['icmptype'] = $pconfig['icmptype'];
194
	}
195

    
196
	if ($_POST['type'] == "reject" && $_POST['proto'] <> "tcp")
197
		$input_errors[] = gettext("Reject type rules only works when the protocol is set to TCP.");
198

    
199
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
200
		$_POST['srcbeginport'] = 0;
201
		$_POST['srcendport'] = 0;
202
		$_POST['dstbeginport'] = 0;
203
		$_POST['dstendport'] = 0;
204
	} else {
205

    
206
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
207
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
208
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
209
			$_POST['srcendport'] = $_POST['srcendport_cust'];
210

    
211
		if ($_POST['srcbeginport'] == "any") {
212
			$_POST['srcbeginport'] = 0;
213
			$_POST['srcendport'] = 0;
214
		} else {
215
			if (!$_POST['srcendport'])
216
				$_POST['srcendport'] = $_POST['srcbeginport'];
217
		}
218
		if ($_POST['srcendport'] == "any")
219
			$_POST['srcendport'] = $_POST['srcbeginport'];
220

    
221
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
222
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
223
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
224
			$_POST['dstendport'] = $_POST['dstendport_cust'];
225

    
226
		if ($_POST['dstbeginport'] == "any") {
227
			$_POST['dstbeginport'] = 0;
228
			$_POST['dstendport'] = 0;
229
		} else {
230
			if (!$_POST['dstendport'])
231
				$_POST['dstendport'] = $_POST['dstbeginport'];
232
		}
233
		if ($_POST['dstendport'] == "any")
234
			$_POST['dstendport'] = $_POST['dstbeginport'];
235
	}
236

    
237
	if (is_specialnet($_POST['srctype'])) {
238
		$_POST['src'] = $_POST['srctype'];
239
		$_POST['srcmask'] = 0;
240
	} else if ($_POST['srctype'] == "single") {
241
		$_POST['srcmask'] = 32;
242
	}
243
	if (is_specialnet($_POST['dsttype'])) {
244
		$_POST['dst'] = $_POST['dsttype'];
245
		$_POST['dstmask'] = 0;
246
	}  else if ($_POST['dsttype'] == "single") {
247
		$_POST['dstmask'] = 32;
248
	}
249

    
250
	unset($input_errors);
251
	$pconfig = $_POST;
252

    
253
	/*  run through $_POST items encoding HTML entties so that the user
254
	 *  cannot think he is slick and perform a XSS attack on the unwilling 
255
	 */
256
	foreach ($_POST as $key => $value) {
257
		$temp = str_replace(">", "", $value);
258
			
259
		if (isset($_POST['floating']) && $key == "interface")
260
			continue;
261
		$newpost = htmlentities($temp);
262
		if($newpost <> $temp)   	 
263
			$input_errors[] = sprintf(gettext("Invalid characters detected (%s).  Please remove invalid characters and save again."),$temp);		
264
	}
265

    
266
	/* input validation */
267
	$reqdfields = explode(" ", "type proto");
268
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
269
		$reqdfields[] = "src";
270
		$reqdfields[] = "dst";
271
	}
272
	$reqdfieldsn = explode(",", "Type,Protocol");
273
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
274
		$reqdfieldsn[] = "Source";
275
		$reqdfieldsn[] = "Destination";
276
	}
277

    
278
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
279
		if( $_POST['proto'] != "tcp" )
280
			$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
281
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
282
			$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
283
	}
284
        
285
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
286
	(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
287
		$reqdfields[] = "srcmask";
288
		$reqdfieldsn[] = "Source bit count";
289
	}
290
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
291
	(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
292
		$reqdfields[] = "dstmask";
293
		$reqdfieldsn[] = gettext("Destination bit count");
294
	}
295

    
296
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
297

    
298
	if (!$_POST['srcbeginport']) {
299
		$_POST['srcbeginport'] = 0;
300
		$_POST['srcendport'] = 0;
301
	}
302
	if (!$_POST['dstbeginport']) {
303
		$_POST['dstbeginport'] = 0;
304
		$_POST['dstendport'] = 0;
305
	}
306

    
307
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
308
                $input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."),$_POST['srcbeginposrt']);
309
        if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
310
                $input_errors[] = sprintf(gettext("%s  is not a valid end source port. It must be a port alias or integer between 1 and 65535."),$_POST['srcendport']);
311
        if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
312
                $input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."),$_POST['dstbeginport']);
313
        if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
314
                $input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."),$_POST['dstendport']);
315

    
316
	/* if user enters an alias and selects "network" then disallow. */
317
	if($_POST['srctype'] == "network") {
318
		if(is_alias($_POST['src']))
319
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
320
	}
321
	if($_POST['dsttype'] == "network") {
322
		if(is_alias($_POST['dst']))
323
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
324
	}
325

    
326
	if (!is_specialnet($_POST['srctype'])) {
327
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
328
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
329
		}
330
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
331
			$input_errors[] = gettext("A valid source bit count must be specified.");
332
		}
333
	}
334
	if (!is_specialnet($_POST['dsttype'])) {
335
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
336
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
337
		}
338
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
339
			$input_errors[] = gettext("A valid destination bit count must be specified.");
340
		}
341
	}
342

    
343
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
344
		/* swap */
345
		$tmp = $_POST['srcendport'];
346
		$_POST['srcendport'] = $_POST['srcbeginport'];
347
		$_POST['srcbeginport'] = $tmp;
348
	}
349
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
350
		/* swap */
351
		$tmp = $_POST['dstendport'];
352
		$_POST['dstendport'] = $_POST['dstbeginport'];
353
		$_POST['dstbeginport'] = $tmp;
354
	}
355
	if ($_POST['os'])
356
		if( $_POST['proto'] != "tcp" )
357
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
358

    
359
	if ($_POST['ackqueue'] && $_POST['ackqueue'] != "none") {
360
		if ($_POST['defaultqueue'] == "none" )
361
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
362
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
363
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");		
364
	}
365
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "none") {
366
		if ($_POST['dnpipe'] == "none" )
367
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
368
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
369
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
370
		else if ($pdnpipe[0] == "?" && $dnpipe[0] <> "?")
371
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
372
		else if ($dnpipe[0] == "?" && $pdnpipe[0] <> "?")			
373
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
374
	}
375
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
376
		$input_errors[] = gettext('ID must be an integer');
377
	if($_POST['l7container'] && $_POST['l7container'] != "none") {
378
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
379
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
380
		if ($_POST['type'] <> "pass")
381
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
382
	}
383

    
384
	if (!$_POST['tcpflags_any']) {
385
		$settcpflags = array();
386
		$outoftcpflags = array();
387
		foreach ($tcpflags as $tcpflag) {
388
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
389
				$settcpflags[] = $tcpflag;
390
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
391
				$outoftcpflags[] = $tcpflag;
392
		}
393
		if (empty($outoftcpflags) && !empty($settcpflags))
394
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
395
	}
396

    
397
	if (!$input_errors) {
398
		$filterent = array();
399
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
400
		$filterent['type'] = $_POST['type'];
401
		if (isset($_POST['interface'] ))
402
			$filterent['interface'] = $_POST['interface'];
403

    
404
		if ($_POST['tcpflags_any']) {
405
			$filterent['tcpflags_any'] = true;
406
		} else {
407
			$settcpflags = array();
408
			$outoftcpflags = array();
409
			foreach ($tcpflags as $tcpflag) {
410
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
411
					$settcpflags[] = $tcpflag;
412
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
413
					$outoftcpflags[] = $tcpflag;
414
			}
415
			if (!empty($outoftcpflags)) {
416
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
417
				if (!empty($settcpflags))
418
					$filterent['tcpflags1'] = join(",", $settcpflags);
419
			}
420
		}
421

    
422
		if (isset($_POST['tag']))
423
			$filterent['tag'] = $_POST['tag'];
424
		if (isset($_POST['tagged']))
425
			$filterent['tagged'] = $_POST['tagged'];
426
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
427
			$filterent['direction'] = $_POST['direction'];
428
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
429
				$filterent['quick'] = $_POST['quick'];
430
			$filterent['floating'] = "yes";
431
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
432
				$filterent['interface'] = implode(",", $_POST['interface']);
433
			}
434
		}
435

    
436
		/* Advanced options */
437
		if ($_POST['allowopts'] == "yes")
438
			$filterent['allowopts'] = true;
439
		else
440
			unset($filterent['allowopts']);
441
		if ($_POST['disablereplyto'] == "yes")
442
			$filterent['disablereplyto'] = true;
443
		else
444
			unset($filterent['disablereplyto']);
445
		$filterent['max'] = $_POST['max'];
446
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
447
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
448
		$filterent['max-src-states'] = $_POST['max-src-states'];
449
		$filterent['statetimeout'] = $_POST['statetimeout'];
450
		$filterent['statetype'] = $_POST['statetype'];
451
		$filterent['os'] = $_POST['os'];
452

    
453
		/* Nosync directive - do not xmlrpc sync this item */
454
		if($_POST['nosync'] <> "")
455
			$filterent['nosync'] = true;
456
		else
457
			unset($filterent['nosync']);
458

    
459
		/* unless both values are provided, unset the values - ticket #650 */
460
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
461
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
462
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
463
		} else {
464
			unset($filterent['max-src-conn-rate']);
465
			unset($filterent['max-src-conn-rates']);
466
		}
467

    
468
		if ($_POST['proto'] != "any")
469
			$filterent['protocol'] = $_POST['proto'];
470
		else
471
			unset($filterent['protocol']);
472

    
473
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
474
			$filterent['icmptype'] = $_POST['icmptype'];
475
		else
476
			unset($filterent['icmptype']);
477

    
478
		pconfig_to_address($filterent['source'], $_POST['src'],
479
			$_POST['srcmask'], $_POST['srcnot'],
480
			$_POST['srcbeginport'], $_POST['srcendport']);
481

    
482
		pconfig_to_address($filterent['destination'], $_POST['dst'],
483
			$_POST['dstmask'], $_POST['dstnot'],
484
			$_POST['dstbeginport'], $_POST['dstendport']);
485

    
486
		if ($_POST['disabled'])
487
			$filterent['disabled'] = true;
488
		else
489
			unset($filterent['disabled']);
490

    
491
		if ($_POST['dscp'])
492
			$filterent['dscp'] = $_POST['dscp'];
493

    
494
		if ($_POST['log'])
495
			$filterent['log'] = true;
496
		else
497
			unset($filterent['log']);
498
		strncpy($filterent['descr'], $_POST['descr'], 52);
499

    
500
		if ($_POST['gateway'] != "") {
501
			$filterent['gateway'] = $_POST['gateway'];
502
		}
503
		
504
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
505
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
506
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
507
				$filterent['ackqueue'] = $_POST['ackqueue'];
508
		}
509

    
510
		if (isset($_POST['dnpipe']) && $_POST['dnpipe'] != "none") {
511
			$filterent['dnpipe'] = $_POST['dnpipe'];
512
			if (isset($_POST['pdnpipe']) && $_POST['pdnpipe'] != "none")
513
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
514
		}
515

    
516
		if (isset($_POST['l7container']) && $_POST['l7container'] != "none") {
517
			$filterent['l7container'] = $_POST['l7container'];
518
		}
519
		
520
		if ($_POST['sched'] != "") {
521
			$filterent['sched'] = $_POST['sched'];
522
		}
523

    
524
		// If we have an associated nat rule, make sure the source and destination doesn't change
525
		if( isset($a_filter[$id]['associated-rule-id']) ) {
526
			$filterent['interface'] = $a_filter[$id]['interface'];
527
			if (isset($a_filter[$id]['protocol']))
528
				$filterent['protocol'] = $a_filter[$id]['protocol'];
529
			else if (isset($filterent['protocol']))
530
				unset($filterent['protocol']);
531
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
532
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
533
			else if (isset($filterent['icmptype']))
534
				unset($filterent['icmptype']);
535
			$filterent['source'] = $a_filter[$id]['source'];
536
			$filterent['destination'] = $a_filter[$id]['destination'];
537
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
538
		}
539

    
540
		if (isset($id) && $a_filter[$id])
541
			$a_filter[$id] = $filterent;
542
		else {
543
			if (is_numeric($after))
544
				array_splice($a_filter, $after+1, 0, array($filterent));
545
			else
546
				$a_filter[] = $filterent;
547
		}
548

    
549
		write_config();
550
		mark_subsystem_dirty('filter');
551

    
552
		if (isset($_POST['floating']))
553
			header("Location: firewall_rules.php?if=FloatingRules");
554
		else
555
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
556
		exit;
557
	}
558
}
559

    
560
read_altq_config(); /* XXX: */
561
$qlist =& get_unique_queue_list();
562
read_dummynet_config(); /* XXX: */
563
$dnqlist =& get_unique_dnqueue_list();
564
read_layer7_config();
565
$l7clist =& get_l7_unique_list();
566

    
567
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
568
$statusurl = "status_filter_reload.php";
569
$logurl = "diag_logs_filter.php";
570

    
571
$closehead = false;
572

    
573
$page_filename = "firewall_rules_edit.php";
574
include("head.inc");
575

    
576
?>
577

    
578
</head>
579

    
580
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
581
<?php include("fbegin.inc"); ?>
582
<?php if ($input_errors) print_input_errors($input_errors); ?>
583

    
584
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
585
<input type='hidden' name="ruleid" value="<?=(isset($pconfig['ruleid'])&&$pconfig['ruleid']>0)?htmlspecialchars($pconfig['ruleid']):''?>">
586

    
587
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
588
		<tr>
589
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
590
		</tr>	
591
    	<tr>
592
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
593
			<td width="78%" class="vtable">
594
				<select name="type" class="formselect">
595
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
596
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
597
					<?=htmlspecialchars($type);?>
598
					</option>
599
					<?php endforeach; ?>
600
				</select>
601
				<br/>
602
				<span class="vexpl">
603
					<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br/>
604
					<?=gettext("Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded.");?> 
605
				</span>
606
			</td>
607
		</tr>
608
		<tr>
609
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
610
			<td width="78%" class="vtable">
611
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
612
				<strong><?=gettext("Disable this rule");?></strong><br />
613
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
614
			</td>
615
		</tr>
616
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
617
		<tr>
618
			<td width="22%" valign="top" class="vncellreq">
619
				<?=gettext("Quick");?>
620
			</td>
621
			<td width="78%" class="vtable">
622
				<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
623
				<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
624
				<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
625
			</td>
626
		</tr>
627
<?php endif; ?>
628
<?php $edit_disabled = ""; ?>
629
<?php if( isset($pconfig['associated-rule-id']) ): ?>
630
		<tr>
631
			<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
632
			<td width="78%" class="vtable">
633
				<span class="red"><strong><?=gettext("NOTE: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
634
				<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
635
				<br />
636
				<?php
637
					$edit_disabled = "disabled";
638
					if (is_array($config['nat']['rule'])) {
639
						foreach( $config['nat']['rule'] as $index => $nat_rule ) {
640
							if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
641
								echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br>";
642
								break;
643
							}
644
						}
645
					}
646
					echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' >";
647
					if (!empty($pconfig['interface']))
648
						echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' >";
649
				?>
650
				<script type="text/javascript">
651
				editenabled = 0;
652
				</script>
653
			</td>
654
		</tr>
655
<?php endif; ?>
656
		<tr>
657
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
658
			<td width="78%" class="vtable">
659
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
660
				<select name="interface[]" multiple="true" class="formselect" size="3" <?=$edit_disabled;?>>
661
<?php else: ?>
662
				<select name="interface" class="formselect" <?=$edit_disabled;?>>
663
<?php
664
   endif;
665
				/* add group interfaces */
666
				if (is_array($config['ifgroups']['ifgroupentry']))
667
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
668
						if (have_ruleint_access($ifgen['ifname']))
669
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
670
				$ifdescs = get_configured_interface_with_descr();
671
				foreach ($ifdescs as $ifent => $ifdesc)
672
        				if(have_ruleint_access($ifent))
673
							$interfaces[$ifent] = $ifdesc;
674
					if ($config['l2tp']['mode'] == "server")
675
						if(have_ruleint_access("l2tp"))
676
							$interfaces['l2tp'] = "L2TP VPN";
677
					if ($config['pptpd']['mode'] == "server")
678
						if(have_ruleint_access("pptp")) 
679
							$interfaces['pptp'] = "PPTP VPN";
680
					
681
					if ($config['pppoe']['mode'] == "server")
682
						if(have_ruleint_access("pppoe")) 
683
							$interfaces['pppoe'] = "PPPoE VPN";
684
					/* add ipsec interfaces */
685
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
686
						if(have_ruleint_access("enc0")) 
687
							$interfaces["enc0"] = "IPsec";
688
					/* add openvpn/tun interfaces */
689
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
690
						$interfaces["openvpn"] = "OpenVPN";
691
					$selected_interfaces = explode(",", $pconfig['interface']);
692
					foreach ($interfaces as $iface => $ifacename): ?>
693
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected"; ?>><?=$ifacename?></option>
694
<?php 				endforeach; ?>
695
				</select>
696
				<br />
697
				<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
698
			</td>
699
		</tr>
700
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
701
		<tr>
702
			<td width="22%" valign="top" class="vncellreq">
703
				<?=gettext("Direction");?>
704
			</td>
705
			<td width="78%" class="vtable">
706
				<select name="direction" class="formselect">
707
					<?php      $directions = array('any','in','out');
708
				foreach ($directions as $direction): ?>
709
				<option value="<?=$direction;?>"
710
					<?php if ($direction == $pconfig['direction']): ?>
711
						selected="selected" 
712
					<?php endif; ?>
713
					><?=$direction;?></option>
714
				<?php endforeach; ?>      
715
				</select>
716
				<input type="hidden" id="floating" name="floating" value="floating">
717
			</td>
718
		<tr>
719
<?php endif; ?>
720
		<tr>
721
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
722
			<td width="78%" class="vtable">
723
				<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
724
<?php
725
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IGMP any carp pfsync");
726
				foreach ($protocols as $proto): ?>
727
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
728
<?php 			endforeach; ?>
729
				</select>
730
				<br />
731
				<span class="vexpl"><?=gettext("Choose which IP protocol this rule should match.");?> <br /> <?=gettext("Hint: in most cases, you should specify ");?><em>TCP</em> &nbsp;<?=gettext("here.");?></span>
732
			</td>
733
		</tr>
734
		<tr id="icmpbox" name="icmpbox">
735
			<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
736
			<td class="vtable">
737
				<select <?=$edit_disabled;?> name="icmptype" class="formselect">
738
<?php
739
				$icmptypes = array(
740
				"" => gettext("any"),
741
				"echorep" => gettext("Echo reply"),
742
				"unreach" => gettext("Destination unreachable"),
743
				"squench" => gettext("Source quench"),
744
				"redir" => gettext("Redirect"),
745
				"althost" => gettext("Alternate Host"),
746
				"echoreq" => gettext("Echo"),
747
				"routeradv" => gettext("Router advertisement"),
748
				"routersol" => gettext("Router solicitation"),
749
				"timex" => gettext("Time exceeded"),
750
				"paramprob" => gettext("Invalid IP header"),
751
				"timereq" => gettext("Timestamp"),
752
				"timerep" => gettext("Timestamp reply"),
753
				"inforeq" => gettext("Information request"),
754
				"inforep" => gettext("Information reply"),
755
				"maskreq" => gettext("Address mask request"),
756
				"maskrep" => gettext("Address mask reply")
757
				);
758

    
759
				foreach ($icmptypes as $icmptype => $descr): ?>
760
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
761
<?php 			endforeach; ?>
762
			</select>
763
			<br />
764
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
765
		</td>
766
		</tr>
767
		<tr>
768
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
769
			<td width="78%" class="vtable">
770
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
771
				<strong><?=gettext("not");?></strong>
772
				<br />
773
				<?=gettext("Use this option to invert the sense of the match.");?>
774
				<br />
775
				<br />
776
				<table border="0" cellspacing="0" cellpadding="0">
777
					<tr>
778
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
779
						<td>
780
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onChange="typesel_change()">
781
<?php
782
								$sel = is_specialnet($pconfig['src']); ?>
783
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>><?=gettext("any");?></option>
784
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>><?=gettext("Single host or alias");?></option>
785
								<option value="network" <?php if (!$sel) echo "selected"; ?>><?=gettext("Network");?></option>
786
								<?php if(have_ruleint_access("pptp")): ?>
787
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>><?=gettext("PPTP clients");?></option>
788
								<?php endif; ?>
789
								<?php if(have_ruleint_access("pppoe")): ?>
790
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected"; } ?>><?=gettext("PPPoE clients");?></option>
791
								<?php endif; ?>								
792
								 <?php if(have_ruleint_access("l2tp")): ?>
793
                                                                <option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected"; } ?>><?=gettext("L2TP clients");?></option>
794
                                                                <?php endif; ?>
795
<?php
796
								foreach ($ifdisp as $ifent => $ifdesc): ?>
797
								<?php if(have_ruleint_access($ifent)): ?>
798
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?><?=gettext(" subnet");?></option>
799
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected"; } ?>>
800
										<?=$ifdesc?> <?=gettext("address");?>
801
									</option>
802
								<?php endif; ?>
803
<?php 							endforeach; ?>
804
							</select>
805
						</td>
806
					</tr>
807
					<tr>
808
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
809
						<td>
810
							<input <?=$edit_disabled;?> autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>"> /
811
							<select <?=$edit_disabled;?> name="srcmask" class="formselect" id="srcmask">
812
<?php						for ($i = 31; $i > 0; $i--): ?>
813
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
814
<?php 						endfor; ?>
815
							</select>
816
						</td>
817
					</tr>
818
				</table>
819
				<div id="showadvancedboxspr">
820
					<p>
821
					<input <?=$edit_disabled;?> type="button" onClick="show_source_port_range()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show source port range");?></a>
822
				</div>
823
			</td>
824
		</tr>
825
		<tr style="display:none" id="sprtable" name="sprtable">
826
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
827
			<td width="78%" class="vtable">
828
				<table border="0" cellspacing="0" cellpadding="0">
829
					<tr>
830
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
831
						<td>
832
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
833
								<option value="">(<?=gettext("other"); ?>)</option>
834
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
835
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
836
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
837
<?php 							endforeach; ?>
838
							</select>
839
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>">
840
						</td>
841
					</tr>
842
					<tr>
843
						<td><?=gettext("to:");?></td>
844
						<td>
845
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
846
								<option value="">(<?=gettext("other"); ?>)</option>
847
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
848
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
849
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
850
<?php							endforeach; ?>
851
							</select>
852
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>">
853
						</td>
854
					</tr>
855
				</table>
856
				<br />
857
				<span class="vexpl"><?=gettext("Specify the source port or port range for this rule."); ?> <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be"); ?> &quot;<?=gettext("any"); ?>&quot;).</b>")."<br />".<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("\"to\""); ?></em> <?=gettext("field empty if you only want to filter a single port.");?></span><br/>
858
			</td>
859
		</tr>
860
		<tr>
861
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
862
			<td width="78%" class="vtable">
863
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
864
				<strong><?=gettext("not");?></strong>
865
					<br />
866
				<?=gettext("Use this option to invert the sense of the match.");?>
867
					<br />
868
					<br />
869
				<table border="0" cellspacing="0" cellpadding="0">
870
					<tr>
871
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
872
						<td>
873
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onChange="typesel_change()">
874
<?php
875
								$sel = is_specialnet($pconfig['dst']); ?>
876
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>><?=gettext("any");?></option>
877
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>><?=gettext("Single host or alias");?></option>
878
								<option value="network" <?php if (!$sel) echo "selected"; ?>><?=gettext("Network");?></option>
879
								<?php if(have_ruleint_access("pptp")): ?>
880
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>><?=gettext("PPTP clients");?></option>
881
								<?php endif; ?>
882
								<?php if(have_ruleint_access("pppoe")): ?>
883
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected"; } ?>><?=gettext("PPPoE clients");?></option>
884
								<?php endif; ?>								
885
								<?php if(have_ruleint_access("l2tp")): ?>
886
                                                                <option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected"; } ?>><?=gettext("L2TP clients");?></option>
887
                                                                <?php endif; ?>
888

    
889
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
890
								<?php if(have_ruleint_access($if)): ?>
891
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("subnet");?></option>
892
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
893
										<?=$ifdesc;?> <?=gettext("address");?>
894
									</option>
895
								<?php endif; ?>
896
<?php 							endforeach; ?>
897
							</select>
898
						</td>
899
					</tr>
900
					<tr>
901
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
902
						<td>
903
							<input <?=$edit_disabled;?> name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
904
							/
905
							<select <?=$edit_disabled;?> name="dstmask" class="formselect" id="dstmask">
906
<?php
907
							for ($i = 31; $i > 0; $i--): ?>
908
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
909
<?php						endfor; ?>
910
							</select>
911
						</td>
912
					</tr>
913
				</table>
914
			</td>
915
		</tr>
916
		<tr id="dprtr" name="dprtr">
917
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range ");?></td>
918
			<td width="78%" class="vtable">
919
				<table border="0" cellspacing="0" cellpadding="0">
920
					<tr>
921
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
922
						<td>
923
							<select <?=$edit_disabled;?> name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
924
								<option value="">(<?=gettext("other"); ?>)</option>
925
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
926
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
927
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected"; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
928
<?php 							endforeach; ?>
929
							</select>
930
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>">
931
						</td>
932
					</tr>
933
					<tr>
934
						<td><?=gettext("to:");?></td>
935
						<td>
936
							<select <?=$edit_disabled;?> name="dstendport" class="formselect" onchange="ext_change()">
937
								<option value="">(<?=gettext("other"); ?>)</option>
938
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
939
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
940
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
941
<?php 							endforeach; ?>
942
							</select>
943
								<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>">
944
						</td>
945
					</tr>
946
				</table>
947
				<br />
948
				<span class="vexpl">
949
					<?=gettext("Specify the port or port range for the destination of the packet for this rule.");?>
950
					<br />
951
					<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port");?>
952
				</span>
953
			</td>
954
		</tr>
955
		<tr>
956
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Log");?></td>
957
			<td width="78%" class="vtable">
958
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
959
				<strong><?=gettext("Log packets that are handled by this rule");?></strong>
960
				<br />
961
				<span class="vexpl"><?=gettext("Hint: the firewall has limited local log space. Don't turn on logging for everything. If you want to do a lot of logging, consider using a remote syslog server"); ?> (<?=gettext("see the"); ?> <a href="diag_logs_settings.php"><?=gettext("Diagnostics: System logs: Settings"); ?></a> <?=gettext("page"); ?>).</span>
962
			</td>
963
		</tr>
964
		<tr>
965
			<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
966
			<td width="78%" class="vtable">
967
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
968
				<br />
969
				<span class="vexpl"><?=gettext("You may enter a description here for your reference.");?></span>
970
			</td>
971
		</tr>
972
		<tr>
973
			<td width="22%" valign="top">&nbsp;</td>
974
			<td width="78%">
975
				&nbsp;<br>&nbsp;
976
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
977
<?php			if (isset($id) && $a_filter[$id]): ?>
978
					<input name="id" type="hidden" value="<?=$id;?>">
979
<?php 			endif; ?>
980
				<input name="after" type="hidden" value="<?=$after;?>">
981
			</td>
982
		</tr>
983
		<tr>
984
			<td>&nbsp;</td>
985
		</tr>
986
		<tr>
987
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced features");?></td>
988
		</tr>	
989
		<tr>
990
			<td width="22%" valign="top" class="vncell"><?=gettext("Source OS");?></td>
991
			<td width="78%" class="vtable">
992
				<div id="showadvsourceosbox" <?php if ($pconfig['os']) echo "style='display:none'"; ?>>
993
					<input type="button" onClick="show_advanced_sourceos()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
994
				</div>
995
				<div id="showsourceosadv" <?php if (empty($pconfig['os'])) echo "style='display:none'"; ?>>
996
					<?=gettext("OS Type:");?>&nbsp;
997
					<select name="os" id="os" class="formselect">
998
<?php
999
						$ostypes = array(
1000
							 "" => gettext("any"),
1001
							"AIX" => "AIX",
1002
							"Linux" => "Linux",
1003
							"FreeBSD" => "FreeBSD",
1004
							"NetBSD" => "NetBSD",
1005
							"OpenBSD" => "OpenBSD",
1006
							"Solaris" => "Solaris",
1007
							"MacOS" => "MacOS",
1008
							"Windows" => "Windows",
1009
							"Novell" => "Novell",
1010
							"NMAP" => "NMAP"
1011
			           );
1012
						foreach ($ostypes as $ostype => $descr): ?>
1013
							<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
1014
<?php
1015
					endforeach; 
1016
?>
1017
					</select>
1018
					<br />
1019
					<?=gettext("Note: this only works for TCP rules");?>
1020
				</div>
1021
			</td>
1022
		</tr>
1023
		<tr>
1024
			<td width="22%" valign="top" class="vncell"><?=gettext("Diffserv Code Point");?></td>
1025
			<td width="78%" class="vtable">
1026
				<div id="dsadv" name="dsadv" <?php if ($pconfig['dscp']) echo "style='display:none'"; ?>>
1027
					<input type="button" onClick="show_dsdiv();" value="<?=gettext("Advanced"); ?>"> - <?=gettext("Show advanced option");?>
1028
				</div>
1029
				<div id="dsdivmain" name="dsdivmain" <?php if (empty($pconfig['dscp'])) echo "style='display:none'"; ?>>
1030
					<select name="dscp" id="dscp">
1031
						<option value=""></option>
1032
						<?php foreach($firewall_rules_dscp_types as $frdt): ?>
1033
							<option value="<?=$frdt?>"<?php if($pconfig['dscp'] == $frdt) echo " SELECTED"; ?>><?=$frdt?></option>
1034
						<?php endforeach; ?>
1035
					</select>
1036
				</div>
1037
			</td>
1038
		</tr>
1039
		<tr>
1040
			<td width="22%" valign="top" class="vncell"><?=gettext("Advanced Options");?></td>
1041
			<td width="78%" class="vtable">
1042
			<div id="aoadv" name="aoadv">
1043
				<input type="button" onClick="show_aodiv();" value="<?=gettext("Advanced"); ?>"> - <?=gettext("Show advanced option");?>
1044
			</div>
1045
			<div id="aodivmain" name="aodivmain" style="display:none">
1046
				<input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked"; ?>>
1047
				<br/><span class="vexpl"><?=gettext("This allows packets with IP options to pass. Otherwise they are blocked by default. This is usually only seen with multicast traffic.");?>
1048
				</span><p>
1049
				<input type="checkbox" id="disablereplyto" value="yes" name="disablereplyto"<?php if($pconfig['disablereplyto'] == true) echo " checked"; ?>>
1050
				<br/><span class="vexpl"><?=gettext("This will disable auto generated reply-to for this rule.");?>
1051
				</span><p>
1052
				<input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
1053
				<br /><span class="vexpl"><?=gettext("You can mark a packet matching this rule and use this mark to match on other NAT/filter rules. It is called"); ?> <b><?=gettext("Policy filtering"); ?></b>
1054
				</span><p>
1055
				<input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>">
1056
				<br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
1057
				</span> <p>
1058
				<input name="max" id="max" value="<?php echo $pconfig['max'] ?>"><br><?=gettext(" Maximum state entries this rule can create");?><p>
1059
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br><?=gettext(" Maximum number of unique source hosts");?><p>
1060
				<input name="max-src-conn" id="max-src-conn" value="<?php echo $pconfig['max-src-conn'] ?>"><br><?=gettext(" Maximum number of established connections per host");?><p>	 
1061
				<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br><?=gettext(" Maximum state entries per host");?><p>
1062
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
1063
				<select name="max-src-conn-rates" id="max-src-conn-rates">
1064
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
1065
<?php				for($x=1; $x<255; $x++) {
1066
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
1067
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
1068
					} ?>
1069
				</select><br />
1070
				<?=gettext("Maximum new connections / per second(s)");?>
1071
				<p>
1072

    
1073
				<input name="statetimeout" value="<?php echo $pconfig['statetimeout'] ?>"><br>
1074
				<?=gettext("State Timeout in seconds");?>
1075
				<p />
1076

    
1077
				<p><strong><?=gettext("NOTE: Leave fields blank to disable that feature.");?></strong>
1078
			  </div>
1079
			</td>
1080
		</tr>
1081
		<tr id="tcpflags" name="tcpflags"> 
1082
			<td width="22%" valign="top" class="vncell"><?=gettext("TCP flags");?></td>
1083
			<td width="78%" class="vtable">
1084
			<div id="showtcpflagsbox" <?php if ($pconfig['tcpflags_any'] || $pconfig['tcpflags1'] || $pconfig['tcpflags2']) echo "style='display:none'"; ?>>
1085
                        	<input type="button" onClick="show_advanced_tcpflags()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1086
                        </div>
1087
                        <div id="showtcpflagsadv" <?php if (empty($pconfig['tcpflags_any']) && empty($pconfig['tcpflags1']) && empty($pconfig['tcpflags2'])) echo "style='display:none'"; ?>>
1088
			<div id="tcpheader" name="tcpheader">
1089
			<center>
1090
			<table border="0" cellspacing="0" cellpadding="0">
1091
			<?php 
1092
				$setflags = explode(",", $pconfig['tcpflags1']);
1093
				$outofflags = explode(",", $pconfig['tcpflags2']);
1094
				$header = "<td width='40' nowrap></td>";
1095
				$tcpflags1 = "<td width='40' nowrap>set</td>";
1096
				$tcpflags2 = "<td width='40' nowrap>out of</td>";
1097
				foreach ($tcpflags as $tcpflag) {
1098
					$header .= "<td  width='40' nowrap><strong>" . strtoupper($tcpflag) . "</strong></td>\n";
1099
					$tcpflags1 .= "<td  width='40' nowrap> <input type='checkbox' name='tcpflags1_{$tcpflag}' value='on' ";
1100
					if (array_search($tcpflag, $setflags) !== false)
1101
						$tcpflags1 .= "checked";
1102
					$tcpflags1 .= "></td>\n";
1103
					$tcpflags2 .= "<td  width='40' nowrap> <input type='checkbox' name='tcpflags2_{$tcpflag}' value='on' ";
1104
					if (array_search($tcpflag, $outofflags) !== false)
1105
						$tcpflags2 .= "checked";
1106
					$tcpflags2 .= "></td>\n";
1107
				}
1108
				echo "<tr id='tcpheader' name='tcpheader'>{$header}</tr>\n";
1109
				echo "<tr id='tcpflags1' name='tcpflags1'>{$tcpflags1}</tr>\n";
1110
				echo "<tr id='tcpflags2' name='tcpflags2'>{$tcpflags2}</tr>\n";
1111
			?>
1112
			</table>
1113
			<center>
1114
			</div>
1115
			<br/><center>
1116
			<input onClick='tcpflags_anyclick(this);' type='checkbox' name='tcpflags_any' value='on' <?php if ($pconfig['tcpflags_any']) echo "checked"; ?>><strong><?=gettext("Any flags.");?></strong><br/></center>
1117
			<br/>
1118
			<span class="vexpl"><?=gettext("Use this to choose TCP flags that must". 
1119
			"be set or cleared for this rule to match.");?></span>
1120
			</div>
1121
			</td>
1122
		</tr>
1123
		<tr>
1124
			<td width="22%" valign="top" class="vncell"><?=gettext("State Type");?></td>
1125
			<td width="78%" class="vtable">
1126
				<div id="showadvstatebox" <?php if (!empty($pconfig['statetype']) && $pconfig['statetype'] != "keep state") echo "style='display:none'"; ?>>
1127
					<input type="button" onClick="show_advanced_state()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1128
				</div>
1129
				<div id="showstateadv" <?php if (empty($pconfig['statetype']) || $pconfig['statetype'] == "keep state") echo "style='display:none'"; ?>>
1130
					<select name="statetype">
1131
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>><?=gettext("keep state");?></option>
1132
						<option value="sloppy state" <?php if($pconfig['statetype'] == "sloppy state") echo "selected"; ?>><?=gettext("sloppy state");?></option>
1133
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>><?=gettext("synproxy state");?></option>
1134
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>><?=gettext("none");?></option>
1135
					</select><br><?=gettext("HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.");?>
1136
					<p>
1137
					<table width="90%">
1138
						<tr><td width="25%"><ul><li><?=gettext("keep state");?></li></td><td><?=gettext("Works with all IP protocols.");?></ul></td></tr>
1139
						<tr><td width="25%"><ul><li><?=gettext("sloppy state");?></li></td><td><?=gettext("Works with all IP protocols.");?></ul></td></tr>
1140
						<tr><td width="25%"><ul><li><?=gettext("synproxy state");?></li></td><td><?=gettext("Proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined.");?></ul></td></tr>
1141
						<tr><td width="25%"><ul><li><?=gettext("none");?></li></td><td><?=gettext("Do not use state mechanisms to keep track.  This is only useful if you're doing advanced queueing in certain situations.  Please check the documentation.");?></ul></td></tr>
1142
					</table>
1143
					</p>
1144
			  </div>
1145
			</td>
1146
		</tr>
1147
		<tr>
1148
			<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
1149
			<td width="78%" class="vtable">
1150
				<div id="showadvnoxmlrpcsyncbox" <?php if ($pconfig['nosync']) echo "style='display:none'"; ?>>
1151
					<input type="button" onClick="show_advanced_noxmlrpc()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1152
				</div>
1153
				<div id="shownoxmlrpcadv" <?php if (empty($pconfig['nosync'])) echo "style='display:none'"; ?>>
1154
					<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
1155
					<?=gettext("HINT: This prevents the rule from automatically syncing to other CARP members.");?>
1156
				</div>
1157
			</td>
1158
		</tr>
1159
		<?php
1160
			//build list of schedules
1161
			$schedules = array();
1162
			$schedules[] = "none";//leave none to leave rule enabled all the time
1163
			if(is_array($config['schedules']['schedule'])) {
1164
				foreach ($config['schedules']['schedule'] as $schedule) {
1165
					if ($schedule['name'] <> "")
1166
						$schedules[] = $schedule['name'];
1167
				}
1168
			}
1169
		?>
1170
		<tr>
1171
			<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
1172
			<td width="78%" class="vtable">
1173
				<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1174
					<input type="button" onClick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1175
				</div>
1176
				<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1177
					<select name='sched'>
1178
<?php
1179
					foreach($schedules as $schedule) {
1180
						if($schedule == $pconfig['sched']) {
1181
							$selected = " SELECTED";
1182
						} else {
1183
							$selected = "";
1184
						}
1185
						if ($schedule == "none") {
1186
							echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
1187
						} else {
1188
							echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
1189
						}
1190
					}
1191
?>
1192
					</select>
1193
					<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
1194
				</div>
1195
			</td>
1196
		</tr>
1197
		<tr>
1198
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1199
			<td width="78%" class="vtable">
1200
				<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1201
					<input type="button" onClick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1202
				</div>
1203
				<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1204
					<select name='gateway'>
1205
					<option value="" ><?=gettext("default");?></option>
1206
<?php
1207
					/* build a list of gateways */
1208
					$gateways = return_gateways_array();
1209
					// add statically configured gateways to list
1210
					foreach($gateways as $gwname => $gw) {
1211
						if($gw == "") 
1212
							continue;
1213
						if($gwname == $pconfig['gateway']) {
1214
							$selected = " SELECTED";
1215
						} else {
1216
							$selected = "";
1217
						}
1218
						echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']} - {$gw['gateway']}</option>\n";
1219
					}
1220
					/* add gateway groups to the list */
1221
					if (is_array($config['gateways']['gateway_group'])) {
1222
						foreach($config['gateways']['gateway_group'] as $gw_group) {
1223
							if($gw_group['name'] == "")
1224
								continue;
1225
							if($pconfig['gateway'] == $gw_group['name']) {
1226
								echo "<option value=\"{$gw_group['name']}\" SELECTED>{$gw_group['name']}</option>\n";
1227
							} else {
1228
								echo "<option value=\"{$gw_group['name']}\">{$gw_group['name']}</option>\n";
1229
							}
1230
						}
1231
					}
1232
?>
1233
					</select>
1234
					<p><strong><?=gettext("Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.");?></strong></p>
1235
				</div>
1236
			</td>
1237
		</tr>
1238
		<tr>
1239
			<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
1240
			<td width="78%" class="vtable">
1241
				<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1242
					<input type="button" onClick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1243
				</div>
1244
				<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1245
					<select name="dnpipe">
1246
<?php
1247
		if (!is_array($dnqlist))
1248
			$dnqlist = array();
1249
		echo "<option value=\"none\"";
1250
		if (!$dnqselected) echo " SELECTED";
1251
		echo " >none</option>";
1252
		foreach ($dnqlist as $dnq => $dnqkey) {
1253
			if($dnq == "")
1254
				continue;
1255
			echo "<option value=\"$dnqkey\"";
1256
			if ($dnqkey == $pconfig['dnpipe']) {
1257
				$dnqselected = 1;
1258
				echo " SELECTED";
1259
			}
1260
			echo ">{$dnq}</option>"; 
1261
		}
1262
?>
1263
			</select> / 			
1264
			<select name="pdnpipe">
1265
<?php
1266
		$dnqselected = 0;
1267
		echo "<option value=\"none\"";
1268
		if (!$dnqselected) echo " SELECTED";
1269
		echo " >none</option>";
1270
		foreach ($dnqlist as $dnq => $dnqkey) {
1271
			if($dnq == "")
1272
				continue;
1273
			echo "<option value=\"$dnqkey\"";
1274
			if ($dnqkey == $pconfig['pdnpipe']) {
1275
				$dnqselected = 1;
1276
				echo " SELECTED";
1277
			}
1278
			echo ">{$dnq}</option>"; 
1279
		}
1280
?>
1281
				</select>
1282
				<br />
1283
				<span class="vexpl"><?=gettext("Choose the Out queue/Virtual interface only if you have selected In too.")."<br/>".gettext("The Out selection is applied to traffic going out the interface the rule is created, In is the incoming one.")."<br/>".gettext("If you are creating a rule on the Floating tab if the direction is In then the same rules apply, if the direction is out the selections are reverted Out is for incoming and In is for outgoing and if you do not select any direction use only the In since the Out selection does not make sense in there to prevent oddities.");?></span>
1284
				</div>
1285
			</td>
1286
		</tr>
1287

    
1288
		<tr>
1289
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1290
			<td width="78%" class="vtable">
1291
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1292
				<input type="button" onClick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1293
			</div>
1294
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1295
				<select name="ackqueue">
1296
<?php
1297
			if (!is_array($qlist))
1298
				$qlist = array();
1299
			echo "<option value=\"none\"";
1300
			if (!$qselected) echo " SELECTED";
1301
			echo " >none</option>";
1302
			foreach ($qlist as $q => $qkey) {
1303
				if($q == "")
1304
					continue;
1305
				echo "<option value=\"$q\"";
1306
				if ($q == $pconfig['ackqueue']) {
1307
					$qselected = 1;
1308
					echo " SELECTED";
1309
				}
1310
				echo ">{$q}</option>"; 
1311
			}
1312
?>
1313
				</select> / 			
1314
				<select name="defaultqueue">
1315
<?php
1316
			$qselected = 0;
1317
			echo "<option value=\"none\"";
1318
			if (!$qselected) echo " SELECTED";
1319
			echo " >none</option>";
1320
			foreach ($qlist as $q => $qkey) {
1321
				if($q == "")
1322
					continue;
1323
				echo "<option value=\"$q\"";
1324
				if ($q == $pconfig['defaultqueue']) {
1325
					$qselected = 1;
1326
					echo " SELECTED";
1327
				}
1328
				echo ">{$q}</option>"; 
1329
			}
1330
?>
1331
				</select>
1332
					<br />
1333
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1334
				</td>
1335
			</tr>
1336
			<tr>
1337
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1338
				<td width="78%" class="vtable">
1339
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1340
						<input type="button" onClick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1341
					</div>
1342
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1343
				<select name="l7container">
1344
<?php
1345
					if (!is_array($l7clist))
1346
						$l7clist = array();
1347
					echo "<option value=\"none\"";
1348
					echo " >none</option>";
1349
					foreach ($l7clist as $l7ckey) {
1350
						echo "<option value=\"{$l7ckey}\"";
1351
						if ($l7ckey == $pconfig['l7container']) {
1352
							echo " SELECTED";
1353
						}
1354
						echo ">{$l7ckey}</option>"; 
1355
					}
1356
?>
1357
				</select>			
1358
				<br/>
1359
				<span class="vexpl">
1360
					<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1361
					"These are valid for TCP and UDP protocols only.");?>
1362
				</span>
1363
			  </div>
1364
			</td>
1365
		</tr>
1366
		<tr>
1367
			<td width="22%" valign="top">&nbsp;</td>
1368
			<td width="78%">
1369
				&nbsp;<br>&nbsp;
1370
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
1371
<?php			if (isset($id) && $a_filter[$id]): ?>
1372
					<input name="id" type="hidden" value="<?=$id;?>">
1373
<?php 			endif; ?>
1374
				<input name="after" type="hidden" value="<?=$after;?>">
1375
			</td>
1376
		</tr>
1377
	</table>
1378
</form>
1379
<script language="JavaScript">
1380
<!--
1381
	ext_change();
1382
	typesel_change();
1383
	proto_change();
1384
	show_source_port_range();
1385

    
1386
<?php
1387
	$isfirst = 0;
1388
	$aliases = "";
1389
	$addrisfirst = 0;
1390
	$aliasesaddr = "";
1391
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1392
		foreach($config['aliases']['alias'] as $alias_name) {
1393
			switch ($alias_name['type']) {
1394
			case "port":
1395
				if($isfirst == 1) $portaliases .= ",";
1396
				$portaliases .= "'" . $alias_name['name'] . "'";
1397
				$isfirst = 1;
1398
				break;
1399
			case "host":
1400
			case "network":
1401
			case "openvpn":
1402
			case "urltable":
1403
				if($addrisfirst == 1) $aliasesaddr .= ",";
1404
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1405
				$addrisfirst = 1;
1406
				break;
1407
			default:
1408
				break;
1409
			}
1410
		}
1411
?>
1412

    
1413
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1414
	var customarray=new Array(<?php echo $portaliases; ?>);
1415

    
1416
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1417
        var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1418
        var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1419
        var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1420
        var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1421
        var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1422
//-->
1423
</script>
1424
<?php include("fend.inc"); ?>
1425
</body>
1426
</html>
(58-58/222)