Project

General

Profile

Download (62.7 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]['ipprotocol']))
99
                $pconfig['ipprotocol'] = $a_filter[$id]['ipprotocol'];
100

    
101
	if (isset($a_filter[$id]['protocol']))
102
		$pconfig['proto'] = $a_filter[$id]['protocol'];
103
	else
104
		$pconfig['proto'] = "any";
105

    
106
	if ($a_filter[$id]['protocol'] == "icmp")
107
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
108

    
109
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
110
		$pconfig['srcmask'], $pconfig['srcnot'],
111
		$pconfig['srcbeginport'], $pconfig['srcendport']);
112

    
113
	if($a_filter[$id]['os'] <> "")
114
		$pconfig['os'] = $a_filter[$id]['os'];
115

    
116
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
117
		$pconfig['dstmask'], $pconfig['dstnot'],
118
		$pconfig['dstbeginport'], $pconfig['dstendport']);
119

    
120
	if ($a_filter[$id]['dscp'] <> "")
121
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
122

    
123
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
124
	$pconfig['log'] = isset($a_filter[$id]['log']);
125
	$pconfig['descr'] = $a_filter[$id]['descr'];
126

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

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

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

    
155
	/* advanced - nosync */
156
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
157

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

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

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

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

    
188
if (isset($_GET['dup']))
189
	unset($id);
190

    
191
if ($_POST) {
192

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

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

    
202
	if ($_POST['type'] == "match" && $_POST['defaultqueue'] == "none")
203
		$input_errors[] = gettext("Queue type rules only work with queues.");
204

    
205
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
206
		$_POST['srcbeginport'] = 0;
207
		$_POST['srcendport'] = 0;
208
		$_POST['dstbeginport'] = 0;
209
		$_POST['dstendport'] = 0;
210
	} else {
211

    
212
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
213
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
214
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
215
			$_POST['srcendport'] = $_POST['srcendport_cust'];
216

    
217
		if ($_POST['srcbeginport'] == "any") {
218
			$_POST['srcbeginport'] = 0;
219
			$_POST['srcendport'] = 0;
220
		} else {
221
			if (!$_POST['srcendport'])
222
				$_POST['srcendport'] = $_POST['srcbeginport'];
223
		}
224
		if ($_POST['srcendport'] == "any")
225
			$_POST['srcendport'] = $_POST['srcbeginport'];
226

    
227
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
228
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
229
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
230
			$_POST['dstendport'] = $_POST['dstendport_cust'];
231

    
232
		if ($_POST['dstbeginport'] == "any") {
233
			$_POST['dstbeginport'] = 0;
234
			$_POST['dstendport'] = 0;
235
		} else {
236
			if (!$_POST['dstendport'])
237
				$_POST['dstendport'] = $_POST['dstbeginport'];
238
		}
239
		if ($_POST['dstendport'] == "any")
240
			$_POST['dstendport'] = $_POST['dstbeginport'];
241
	}
242

    
243
	if (is_specialnet($_POST['srctype'])) {
244
		$_POST['src'] = $_POST['srctype'];
245
		$_POST['srcmask'] = 0;
246
	} else if ($_POST['srctype'] == "single") {
247
		$_POST['srcmask'] = 32;
248
	}
249
	if (is_specialnet($_POST['dsttype'])) {
250
		$_POST['dst'] = $_POST['dsttype'];
251
		$_POST['dstmask'] = 0;
252
	}  else if ($_POST['dsttype'] == "single") {
253
		$_POST['dstmask'] = 32;
254
	}
255

    
256
	unset($input_errors);
257
	$pconfig = $_POST;
258

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

    
272
	/* input validation */
273
	$reqdfields = explode(" ", "type proto");
274
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
275
		$reqdfields[] = "src";
276
		$reqdfields[] = "dst";
277
	}
278
	$reqdfieldsn = explode(",", "Type,Protocol");
279
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
280
		$reqdfieldsn[] = "Source";
281
		$reqdfieldsn[] = "Destination";
282
	}
283

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

    
302
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
303

    
304
	if (!$_POST['srcbeginport']) {
305
		$_POST['srcbeginport'] = 0;
306
		$_POST['srcendport'] = 0;
307
	}
308
	if (!$_POST['dstbeginport']) {
309
		$_POST['dstbeginport'] = 0;
310
		$_POST['dstendport'] = 0;
311
	}
312

    
313
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
314
                $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']);
315
        if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
316
                $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']);
317
        if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
318
                $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']);
319
        if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
320
                $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']);
321

    
322
	/* if user enters an alias and selects "network" then disallow. */
323
	if($_POST['srctype'] == "network") {
324
		if(is_alias($_POST['src']))
325
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
326
	}
327
	if($_POST['dsttype'] == "network") {
328
		if(is_alias($_POST['dst']))
329
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
330
	}
331

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

    
349
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
350
		/* swap */
351
		$tmp = $_POST['srcendport'];
352
		$_POST['srcendport'] = $_POST['srcbeginport'];
353
		$_POST['srcbeginport'] = $tmp;
354
	}
355
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
356
		/* swap */
357
		$tmp = $_POST['dstendport'];
358
		$_POST['dstendport'] = $_POST['dstbeginport'];
359
		$_POST['dstbeginport'] = $tmp;
360
	}
361
	if ($_POST['os'])
362
		if( $_POST['proto'] != "tcp" )
363
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
364

    
365
	if ($_POST['ackqueue'] && $_POST['ackqueue'] != "none") {
366
		if ($_POST['defaultqueue'] == "none" )
367
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
368
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
369
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");		
370
	}
371
	if (isset($_POST['floating']) && $_POST['pdnpipe'] != "none" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
372
		$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
373
	if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
374
		$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
375
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "none") {
376
		if ($_POST['dnpipe'] == "none" )
377
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
378
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
379
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
380
		else if ($pdnpipe[0] == "?" && $dnpipe[0] <> "?")
381
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
382
		else if ($dnpipe[0] == "?" && $pdnpipe[0] <> "?")			
383
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
384
	}
385
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
386
		$input_errors[] = gettext('ID must be an integer');
387
	if($_POST['l7container'] && $_POST['l7container'] != "none") {
388
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
389
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
390
		if ($_POST['type'] <> "pass")
391
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
392
	}
393

    
394
	if (!$_POST['tcpflags_any']) {
395
		$settcpflags = array();
396
		$outoftcpflags = array();
397
		foreach ($tcpflags as $tcpflag) {
398
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
399
				$settcpflags[] = $tcpflag;
400
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
401
				$outoftcpflags[] = $tcpflag;
402
		}
403
		if (empty($outoftcpflags) && !empty($settcpflags))
404
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
405
	}
406

    
407
	if (!$input_errors) {
408
		$filterent = array();
409
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
410
		$filterent['type'] = $_POST['type'];
411
		if (isset($_POST['interface'] ))
412
			$filterent['interface'] = $_POST['interface'];
413

    
414
		if (isset($_POST['ipprotocol'] ))
415
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
416

    
417
		if ($_POST['tcpflags_any']) {
418
			$filterent['tcpflags_any'] = true;
419
		} else {
420
			$settcpflags = array();
421
			$outoftcpflags = array();
422
			foreach ($tcpflags as $tcpflag) {
423
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
424
					$settcpflags[] = $tcpflag;
425
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
426
					$outoftcpflags[] = $tcpflag;
427
			}
428
			if (!empty($outoftcpflags)) {
429
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
430
				if (!empty($settcpflags))
431
					$filterent['tcpflags1'] = join(",", $settcpflags);
432
			}
433
		}
434

    
435
		if (isset($_POST['tag']))
436
			$filterent['tag'] = $_POST['tag'];
437
		if (isset($_POST['tagged']))
438
			$filterent['tagged'] = $_POST['tagged'];
439
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
440
			$filterent['direction'] = $_POST['direction'];
441
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
442
				$filterent['quick'] = $_POST['quick'];
443
			$filterent['floating'] = "yes";
444
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
445
				$filterent['interface'] = implode(",", $_POST['interface']);
446
			}
447
		}
448

    
449
		/* Advanced options */
450
		if ($_POST['allowopts'] == "yes")
451
			$filterent['allowopts'] = true;
452
		else
453
			unset($filterent['allowopts']);
454
		if ($_POST['disablereplyto'] == "yes")
455
			$filterent['disablereplyto'] = true;
456
		else
457
			unset($filterent['disablereplyto']);
458
		$filterent['max'] = $_POST['max'];
459
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
460
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
461
		$filterent['max-src-states'] = $_POST['max-src-states'];
462
		$filterent['statetimeout'] = $_POST['statetimeout'];
463
		$filterent['statetype'] = $_POST['statetype'];
464
		$filterent['os'] = $_POST['os'];
465

    
466
		/* Nosync directive - do not xmlrpc sync this item */
467
		if($_POST['nosync'] <> "")
468
			$filterent['nosync'] = true;
469
		else
470
			unset($filterent['nosync']);
471

    
472
		/* unless both values are provided, unset the values - ticket #650 */
473
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
474
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
475
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
476
		} else {
477
			unset($filterent['max-src-conn-rate']);
478
			unset($filterent['max-src-conn-rates']);
479
		}
480

    
481
		if ($_POST['proto'] != "any")
482
			$filterent['protocol'] = $_POST['proto'];
483
		else
484
			unset($filterent['protocol']);
485

    
486
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
487
			$filterent['icmptype'] = $_POST['icmptype'];
488
		else
489
			unset($filterent['icmptype']);
490

    
491
		pconfig_to_address($filterent['source'], $_POST['src'],
492
			$_POST['srcmask'], $_POST['srcnot'],
493
			$_POST['srcbeginport'], $_POST['srcendport']);
494

    
495
		pconfig_to_address($filterent['destination'], $_POST['dst'],
496
			$_POST['dstmask'], $_POST['dstnot'],
497
			$_POST['dstbeginport'], $_POST['dstendport']);
498

    
499
		if ($_POST['disabled'])
500
			$filterent['disabled'] = true;
501
		else
502
			unset($filterent['disabled']);
503

    
504
		if ($_POST['dscp'])
505
			$filterent['dscp'] = $_POST['dscp'];
506

    
507
		if ($_POST['log'])
508
			$filterent['log'] = true;
509
		else
510
			unset($filterent['log']);
511
		strncpy($filterent['descr'], $_POST['descr'], 52);
512

    
513
		if ($_POST['gateway'] != "") {
514
			$filterent['gateway'] = $_POST['gateway'];
515
		}
516
		
517
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
518
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
519
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
520
				$filterent['ackqueue'] = $_POST['ackqueue'];
521
		}
522

    
523
		if (isset($_POST['dnpipe']) && $_POST['dnpipe'] != "none") {
524
			$filterent['dnpipe'] = $_POST['dnpipe'];
525
			if (isset($_POST['pdnpipe']) && $_POST['pdnpipe'] != "none")
526
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
527
		}
528

    
529
		if (isset($_POST['l7container']) && $_POST['l7container'] != "none") {
530
			$filterent['l7container'] = $_POST['l7container'];
531
		}
532
		
533
		if ($_POST['sched'] != "") {
534
			$filterent['sched'] = $_POST['sched'];
535
		}
536

    
537
		// If we have an associated nat rule, make sure the source and destination doesn't change
538
		if( isset($a_filter[$id]['associated-rule-id']) ) {
539
			$filterent['interface'] = $a_filter[$id]['interface'];
540
			if (isset($a_filter[$id]['protocol']))
541
				$filterent['protocol'] = $a_filter[$id]['protocol'];
542
			else if (isset($filterent['protocol']))
543
				unset($filterent['protocol']);
544
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
545
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
546
			else if (isset($filterent['icmptype']))
547
				unset($filterent['icmptype']);
548

    
549
			$filterent['source'] = $a_filter[$id]['source'];
550
			$filterent['destination'] = $a_filter[$id]['destination'];
551
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
552
		}
553

    
554
		if (isset($id) && $a_filter[$id])
555
			$a_filter[$id] = $filterent;
556
		else {
557
			if (is_numeric($after))
558
				array_splice($a_filter, $after+1, 0, array($filterent));
559
			else
560
				$a_filter[] = $filterent;
561
		}
562

    
563
		filter_rules_sort();
564
		write_config();
565
		mark_subsystem_dirty('filter');
566

    
567
		if (isset($_POST['floating']))
568
			header("Location: firewall_rules.php?if=FloatingRules");
569
		else
570
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
571
		exit;
572
	}
573
}
574

    
575
read_altq_config(); /* XXX: */
576
$qlist =& get_unique_queue_list();
577
read_dummynet_config(); /* XXX: */
578
$dnqlist =& get_unique_dnqueue_list();
579
read_layer7_config();
580
$l7clist =& get_l7_unique_list();
581

    
582
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
583
$statusurl = "status_filter_reload.php";
584
$logurl = "diag_logs_filter.php";
585

    
586
$closehead = false;
587

    
588
$page_filename = "firewall_rules_edit.php";
589
include("head.inc");
590

    
591
?>
592

    
593
</head>
594

    
595
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
596
<?php include("fbegin.inc"); ?>
597
<?php if ($input_errors) print_input_errors($input_errors); ?>
598

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

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

    
792
				foreach ($icmptypes as $icmptype => $descr): ?>
793
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
794
<?php 			endforeach; ?>
795
			</select>
796
			<br />
797
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
798
		</td>
799
		</tr>
800
		<tr>
801
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
802
			<td width="78%" class="vtable">
803
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
804
				<strong><?=gettext("not");?></strong>
805
				<br />
806
				<?=gettext("Use this option to invert the sense of the match.");?>
807
				<br />
808
				<br />
809
				<table border="0" cellspacing="0" cellpadding="0">
810
					<tr>
811
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
812
						<td>
813
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onChange="typesel_change()">
814
<?php
815
								$sel = is_specialnet($pconfig['src']); ?>
816
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>><?=gettext("any");?></option>
817
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>><?=gettext("Single host or alias");?></option>
818
								<option value="network" <?php if (!$sel) echo "selected"; ?>><?=gettext("Network");?></option>
819
								<?php if(have_ruleint_access("pptp")): ?>
820
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>><?=gettext("PPTP clients");?></option>
821
								<?php endif; ?>
822
								<?php if(have_ruleint_access("pppoe")): ?>
823
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected"; } ?>><?=gettext("PPPoE clients");?></option>
824
								<?php endif; ?>								
825
								 <?php if(have_ruleint_access("l2tp")): ?>
826
                                                                <option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected"; } ?>><?=gettext("L2TP clients");?></option>
827
                                                                <?php endif; ?>
828
<?php
829
								foreach ($ifdisp as $ifent => $ifdesc): ?>
830
								<?php if(have_ruleint_access($ifent)): ?>
831
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?><?=gettext(" subnet");?></option>
832
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected"; } ?>>
833
										<?=$ifdesc?> <?=gettext("address");?>
834
									</option>
835
								<?php endif; ?>
836
<?php 							endforeach; ?>
837
							</select>
838
						</td>
839
					</tr>
840
					<tr>
841
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
842
						<td>
843
							<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']);?>"> /
844
							<select <?=$edit_disabled;?> name="srcmask" class="formselect" id="srcmask">
845
<?php						for ($i = 127; $i > 0; $i--): ?>
846
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
847
<?php 						endfor; ?>
848
							</select>
849
						</td>
850
					</tr>
851
				</table>
852
				<div id="showadvancedboxspr">
853
					<p>
854
					<input <?=$edit_disabled;?> type="button" onClick="show_source_port_range()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show source port range");?></a>
855
				</div>
856
			</td>
857
		</tr>
858
		<tr style="display:none" id="sprtable" name="sprtable">
859
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
860
			<td width="78%" class="vtable">
861
				<table border="0" cellspacing="0" cellpadding="0">
862
					<tr>
863
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
864
						<td>
865
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
866
								<option value="">(<?=gettext("other"); ?>)</option>
867
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
868
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
869
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
870
<?php 							endforeach; ?>
871
							</select>
872
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>">
873
						</td>
874
					</tr>
875
					<tr>
876
						<td><?=gettext("to:");?></td>
877
						<td>
878
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
879
								<option value="">(<?=gettext("other"); ?>)</option>
880
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
881
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
882
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
883
<?php							endforeach; ?>
884
							</select>
885
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>">
886
						</td>
887
					</tr>
888
				</table>
889
				<br />
890
				<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/>
891
			</td>
892
		</tr>
893
		<tr>
894
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
895
			<td width="78%" class="vtable">
896
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
897
				<strong><?=gettext("not");?></strong>
898
					<br />
899
				<?=gettext("Use this option to invert the sense of the match.");?>
900
					<br />
901
					<br />
902
				<table border="0" cellspacing="0" cellpadding="0">
903
					<tr>
904
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
905
						<td>
906
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onChange="typesel_change()">
907
<?php
908
								$sel = is_specialnet($pconfig['dst']); ?>
909
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>><?=gettext("any");?></option>
910
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>><?=gettext("Single host or alias");?></option>
911
								<option value="network" <?php if (!$sel) echo "selected"; ?>><?=gettext("Network");?></option>
912
								<?php if(have_ruleint_access("pptp")): ?>
913
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>><?=gettext("PPTP clients");?></option>
914
								<?php endif; ?>
915
								<?php if(have_ruleint_access("pppoe")): ?>
916
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected"; } ?>><?=gettext("PPPoE clients");?></option>
917
								<?php endif; ?>								
918
								<?php if(have_ruleint_access("l2tp")): ?>
919
                                                                <option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected"; } ?>><?=gettext("L2TP clients");?></option>
920
                                                                <?php endif; ?>
921

    
922
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
923
								<?php if(have_ruleint_access($if)): ?>
924
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("subnet");?></option>
925
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
926
										<?=$ifdesc;?> <?=gettext("address");?>
927
									</option>
928
								<?php endif; ?>
929
<?php 							endforeach; ?>
930
							</select>
931
						</td>
932
					</tr>
933
					<tr>
934
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
935
						<td>
936
							<input <?=$edit_disabled;?> autocomplete='off' name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
937
							/
938
							<select <?=$edit_disabled;?> name="dstmask" class="formselect" id="dstmask">
939
<?php
940
							for ($i = 127; $i > 0; 
941
$i--): ?>
942
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
943
<?php						endfor; ?>
944
							</select>
945
						</td>
946
					</tr>
947
				</table>
948
			</td>
949
		</tr>
950
		<tr id="dprtr" name="dprtr">
951
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range ");?></td>
952
			<td width="78%" class="vtable">
953
				<table border="0" cellspacing="0" cellpadding="0">
954
					<tr>
955
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
956
						<td>
957
							<select <?=$edit_disabled;?> name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
958
								<option value="">(<?=gettext("other"); ?>)</option>
959
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
960
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
961
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected"; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
962
<?php 							endforeach; ?>
963
							</select>
964
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo htmlspecialchars($pconfig['dstbeginport']); ?>">
965
						</td>
966
					</tr>
967
					<tr>
968
						<td><?=gettext("to:");?></td>
969
						<td>
970
							<select <?=$edit_disabled;?> name="dstendport" class="formselect" onchange="ext_change()">
971
								<option value="">(<?=gettext("other"); ?>)</option>
972
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>><?=gettext("any");?></option>
973
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
974
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
975
<?php 							endforeach; ?>
976
							</select>
977
								<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo htmlspecialchars($pconfig['dstendport']); ?>">
978
						</td>
979
					</tr>
980
				</table>
981
				<br />
982
				<span class="vexpl">
983
					<?=gettext("Specify the port or port range for the destination of the packet for this rule.");?>
984
					<br />
985
					<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port");?>
986
				</span>
987
			</td>
988
		</tr>
989
		<tr>
990
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Log");?></td>
991
			<td width="78%" class="vtable">
992
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
993
				<strong><?=gettext("Log packets that are handled by this rule");?></strong>
994
				<br />
995
				<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>
996
			</td>
997
		</tr>
998
		<tr>
999
			<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
1000
			<td width="78%" class="vtable">
1001
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
1002
				<br />
1003
				<span class="vexpl"><?=gettext("You may enter a description here for your reference.");?></span>
1004
			</td>
1005
		</tr>
1006
<?php		if (!isset($id) || !($a_filter[$id] && firewall_check_for_advanced_options($a_filter[$id]) <> "")): ?>
1007
		<tr>
1008
			<td width="22%" valign="top">&nbsp;</td>
1009
			<td width="78%">
1010
				&nbsp;<br>&nbsp;
1011
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
1012
<?php			if (isset($id) && $a_filter[$id]): ?>
1013
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
1014
<?php 			endif; ?>
1015
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>">
1016
			</td>
1017
		</tr>
1018
<?php		endif; ?>
1019
		<tr>
1020
			<td>&nbsp;</td>
1021
		</tr>
1022
		<tr>
1023
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced features");?></td>
1024
		</tr>	
1025
		<tr>
1026
			<td width="22%" valign="top" class="vncell"><?=gettext("Source OS");?></td>
1027
			<td width="78%" class="vtable">
1028
				<div id="showadvsourceosbox" <?php if ($pconfig['os']) echo "style='display:none'"; ?>>
1029
					<input type="button" onClick="show_advanced_sourceos()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1030
				</div>
1031
				<div id="showsourceosadv" <?php if (empty($pconfig['os'])) echo "style='display:none'"; ?>>
1032
					<?=gettext("OS Type:");?>&nbsp;
1033
					<select name="os" id="os" class="formselect">
1034
<?php
1035
						$ostypes = array(
1036
							 "" => gettext("any"),
1037
							"AIX" => "AIX",
1038
							"Linux" => "Linux",
1039
							"FreeBSD" => "FreeBSD",
1040
							"NetBSD" => "NetBSD",
1041
							"OpenBSD" => "OpenBSD",
1042
							"Solaris" => "Solaris",
1043
							"MacOS" => "MacOS",
1044
							"Windows" => "Windows",
1045
							"Novell" => "Novell",
1046
							"NMAP" => "NMAP"
1047
			           );
1048
						foreach ($ostypes as $ostype => $descr): ?>
1049
							<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
1050
<?php
1051
					endforeach; 
1052
?>
1053
					</select>
1054
					<br />
1055
					<?=gettext("Note: this only works for TCP rules");?>
1056
				</div>
1057
			</td>
1058
		</tr>
1059
		<tr>
1060
			<td width="22%" valign="top" class="vncell"><?=gettext("Diffserv Code Point");?></td>
1061
			<td width="78%" class="vtable">
1062
				<div id="dsadv" name="dsadv" <?php if ($pconfig['dscp']) echo "style='display:none'"; ?>>
1063
					<input type="button" onClick="show_dsdiv();" value="<?=gettext("Advanced"); ?>"> - <?=gettext("Show advanced option");?>
1064
				</div>
1065
				<div id="dsdivmain" name="dsdivmain" <?php if (empty($pconfig['dscp'])) echo "style='display:none'"; ?>>
1066
					<select name="dscp" id="dscp">
1067
						<option value=""></option>
1068
						<?php foreach($firewall_rules_dscp_types as $frdt): ?>
1069
							<option value="<?=$frdt?>"<?php if($pconfig['dscp'] == $frdt) echo " SELECTED"; ?>><?=$frdt?></option>
1070
						<?php endforeach; ?>
1071
					</select>
1072
				</div>
1073
			</td>
1074
		</tr>
1075
		<tr>
1076
			<td width="22%" valign="top" class="vncell"><?=gettext("Advanced Options");?></td>
1077
			<td width="78%" class="vtable">
1078
			<div id="aoadv" name="aoadv">
1079
				<input type="button" onClick="show_aodiv();" value="<?=gettext("Advanced"); ?>"> - <?=gettext("Show advanced option");?>
1080
			</div>
1081
			<div id="aodivmain" name="aodivmain" style="display:none">
1082
				<input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked"; ?>>
1083
				<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.");?>
1084
				</span><p>
1085
				<input type="checkbox" id="disablereplyto" value="yes" name="disablereplyto"<?php if($pconfig['disablereplyto'] == true) echo " checked"; ?>>
1086
				<br/><span class="vexpl"><?=gettext("This will disable auto generated reply-to for this rule.");?>
1087
				</span><p>
1088
				<input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
1089
				<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>
1090
				</span><p>
1091
				<input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>">
1092
				<br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
1093
				</span> <p>
1094
				<input name="max" id="max" value="<?php echo htmlspecialchars($pconfig['max']) ?>"><br><?=gettext(" Maximum state entries this rule can create");?></p><p>
1095
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo htmlspecialchars($pconfig['max-src-nodes']) ?>"><br><?=gettext(" Maximum number of unique source hosts");?></p><p>
1096
				<input name="max-src-conn" id="max-src-conn" value="<?php echo htmlspecialchars($pconfig['max-src-conn']) ?>"><br><?=gettext(" Maximum number of established connections per host");?></p><p>
1097
				<input name="max-src-states" id="max-src-states" value="<?php echo htmlspecialchars($pconfig['max-src-states']) ?>"><br><?=gettext(" Maximum state entries per host");?></p><p>
1098
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo htmlspecialchars($pconfig['max-src-conn-rate']) ?>"> /
1099
				<select name="max-src-conn-rates" id="max-src-conn-rates">
1100
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
1101
<?php				for($x=1; $x<255; $x++) {
1102
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
1103
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
1104
					} ?>
1105
				</select><br />
1106
				<?=gettext("Maximum new connections / per second(s)");?>
1107
				</p><p>
1108

    
1109
				<input name="statetimeout" value="<?php echo htmlspecialchars($pconfig['statetimeout']) ?>"><br>
1110
				<?=gettext("State Timeout in seconds");?>
1111
				</p>
1112

    
1113
				<p><strong><?=gettext("NOTE: Leave fields blank to disable that feature.");?></strong></p>
1114
			  </div>
1115
			</td>
1116
		</tr>
1117
		<tr id="tcpflags" name="tcpflags"> 
1118
			<td width="22%" valign="top" class="vncell"><?=gettext("TCP flags");?></td>
1119
			<td width="78%" class="vtable">
1120
			<div id="showtcpflagsbox" <?php if ($pconfig['tcpflags_any'] || $pconfig['tcpflags1'] || $pconfig['tcpflags2']) echo "style='display:none'"; ?>>
1121
                        	<input type="button" onClick="show_advanced_tcpflags()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1122
                        </div>
1123
                        <div id="showtcpflagsadv" <?php if (empty($pconfig['tcpflags_any']) && empty($pconfig['tcpflags1']) && empty($pconfig['tcpflags2'])) echo "style='display:none'"; ?>>
1124
			<div id="tcpheader" name="tcpheader">
1125
			<center>
1126
			<table border="0" cellspacing="0" cellpadding="0">
1127
			<?php 
1128
				$setflags = explode(",", $pconfig['tcpflags1']);
1129
				$outofflags = explode(",", $pconfig['tcpflags2']);
1130
				$header = "<td width='40' nowrap></td>";
1131
				$tcpflags1 = "<td width='40' nowrap>set</td>";
1132
				$tcpflags2 = "<td width='40' nowrap>out of</td>";
1133
				foreach ($tcpflags as $tcpflag) {
1134
					$header .= "<td  width='40' nowrap><strong>" . strtoupper($tcpflag) . "</strong></td>\n";
1135
					$tcpflags1 .= "<td  width='40' nowrap> <input type='checkbox' name='tcpflags1_{$tcpflag}' value='on' ";
1136
					if (array_search($tcpflag, $setflags) !== false)
1137
						$tcpflags1 .= "checked";
1138
					$tcpflags1 .= "></td>\n";
1139
					$tcpflags2 .= "<td  width='40' nowrap> <input type='checkbox' name='tcpflags2_{$tcpflag}' value='on' ";
1140
					if (array_search($tcpflag, $outofflags) !== false)
1141
						$tcpflags2 .= "checked";
1142
					$tcpflags2 .= "></td>\n";
1143
				}
1144
				echo "<tr id='tcpheader' name='tcpheader'>{$header}</tr>\n";
1145
				echo "<tr id='tcpflags1' name='tcpflags1'>{$tcpflags1}</tr>\n";
1146
				echo "<tr id='tcpflags2' name='tcpflags2'>{$tcpflags2}</tr>\n";
1147
			?>
1148
			</table>
1149
			<center>
1150
			</div>
1151
			<br/><center>
1152
			<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>
1153
			<br/>
1154
			<span class="vexpl"><?=gettext("Use this to choose TCP flags that must ". 
1155
			"be set or cleared for this rule to match.");?></span>
1156
			</div>
1157
			</td>
1158
		</tr>
1159
		<tr>
1160
			<td width="22%" valign="top" class="vncell"><?=gettext("State Type");?></td>
1161
			<td width="78%" class="vtable">
1162
				<div id="showadvstatebox" <?php if (!empty($pconfig['statetype']) && $pconfig['statetype'] != "keep state") echo "style='display:none'"; ?>>
1163
					<input type="button" onClick="show_advanced_state()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1164
				</div>
1165
				<div id="showstateadv" <?php if (empty($pconfig['statetype']) || $pconfig['statetype'] == "keep state") echo "style='display:none'"; ?>>
1166
					<select name="statetype">
1167
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>><?=gettext("keep state");?></option>
1168
						<option value="sloppy state" <?php if($pconfig['statetype'] == "sloppy state") echo "selected"; ?>><?=gettext("sloppy state");?></option>
1169
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>><?=gettext("synproxy state");?></option>
1170
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>><?=gettext("none");?></option>
1171
					</select><br><?=gettext("HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.");?>
1172
					<p>
1173
					<table width="90%">
1174
						<tr><td width="25%"><ul><li><?=gettext("keep state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1175
						<tr><td width="25%"><ul><li><?=gettext("sloppy state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1176
						<tr><td width="25%"><ul><li><?=gettext("synproxy state");?></li></ul></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.");?></td></tr>
1177
						<tr><td width="25%"><ul><li><?=gettext("none");?></li></ul></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.");?></td></tr>
1178
					</table>
1179
					</p>
1180
			  </div>
1181
			</td>
1182
		</tr>
1183
		<tr>
1184
			<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
1185
			<td width="78%" class="vtable">
1186
				<div id="showadvnoxmlrpcsyncbox" <?php if ($pconfig['nosync']) echo "style='display:none'"; ?>>
1187
					<input type="button" onClick="show_advanced_noxmlrpc()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1188
				</div>
1189
				<div id="shownoxmlrpcadv" <?php if (empty($pconfig['nosync'])) echo "style='display:none'"; ?>>
1190
					<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
1191
					<?=gettext("HINT: This prevents the rule from automatically syncing to other CARP members.");?>
1192
				</div>
1193
			</td>
1194
		</tr>
1195
		<?php
1196
			//build list of schedules
1197
			$schedules = array();
1198
			$schedules[] = "none";//leave none to leave rule enabled all the time
1199
			if(is_array($config['schedules']['schedule'])) {
1200
				foreach ($config['schedules']['schedule'] as $schedule) {
1201
					if ($schedule['name'] <> "")
1202
						$schedules[] = $schedule['name'];
1203
				}
1204
			}
1205
		?>
1206
		<tr>
1207
			<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
1208
			<td width="78%" class="vtable">
1209
				<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1210
					<input type="button" onClick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1211
				</div>
1212
				<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1213
					<select name='sched'>
1214
<?php
1215
					foreach($schedules as $schedule) {
1216
						if($schedule == $pconfig['sched']) {
1217
							$selected = " SELECTED";
1218
						} else {
1219
							$selected = "";
1220
						}
1221
						if ($schedule == "none") {
1222
							echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
1223
						} else {
1224
							echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
1225
						}
1226
					}
1227
?>
1228
					</select>
1229
					<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
1230
				</div>
1231
			</td>
1232
		</tr>
1233
		<tr>
1234
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1235
			<td width="78%" class="vtable">
1236
				<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1237
					<input type="button" onClick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1238
				</div>
1239
				<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1240
					<select name='gateway'>
1241
					<option value="" ><?=gettext("default");?></option>
1242
<?php
1243
					/* build a list of gateways */
1244
					$gateways = return_gateways_array();
1245
					// add statically configured gateways to list
1246
					foreach($gateways as $gwname => $gw) {
1247
						if($gw == "") 
1248
							continue;
1249
						if($gwname == $pconfig['gateway']) {
1250
							$selected = " SELECTED";
1251
						} else {
1252
							$selected = "";
1253
						}
1254
						echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']} - {$gw['gateway']}</option>\n";
1255
					}
1256
					/* add gateway groups to the list */
1257
					if (is_array($config['gateways']['gateway_group'])) {
1258
						foreach($config['gateways']['gateway_group'] as $gw_group) {
1259
							if($gw_group['name'] == "")
1260
								continue;
1261
							if($pconfig['gateway'] == $gw_group['name']) {
1262
								echo "<option value=\"{$gw_group['name']}\" SELECTED>{$gw_group['name']}</option>\n";
1263
							} else {
1264
								echo "<option value=\"{$gw_group['name']}\">{$gw_group['name']}</option>\n";
1265
							}
1266
						}
1267
					}
1268
?>
1269
					</select>
1270
					<p><?=gettext("Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.");?></p>
1271
				</div>
1272
			</td>
1273
		</tr>
1274
		<tr>
1275
			<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
1276
			<td width="78%" class="vtable">
1277
				<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1278
					<input type="button" onClick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1279
				</div>
1280
				<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1281
					<select name="dnpipe">
1282
<?php
1283
		if (!is_array($dnqlist))
1284
			$dnqlist = array();
1285
		echo "<option value=\"none\"";
1286
		if (!$dnqselected) echo " SELECTED";
1287
		echo " >none</option>";
1288
		foreach ($dnqlist as $dnq => $dnqkey) {
1289
			if($dnq == "")
1290
				continue;
1291
			echo "<option value=\"$dnqkey\"";
1292
			if ($dnqkey == $pconfig['dnpipe']) {
1293
				$dnqselected = 1;
1294
				echo " SELECTED";
1295
			}
1296
			echo ">{$dnq}</option>"; 
1297
		}
1298
?>
1299
			</select> / 			
1300
			<select name="pdnpipe">
1301
<?php
1302
		$dnqselected = 0;
1303
		echo "<option value=\"none\"";
1304
		if (!$dnqselected) echo " SELECTED";
1305
		echo " >none</option>";
1306
		foreach ($dnqlist as $dnq => $dnqkey) {
1307
			if($dnq == "")
1308
				continue;
1309
			echo "<option value=\"$dnqkey\"";
1310
			if ($dnqkey == $pconfig['pdnpipe']) {
1311
				$dnqselected = 1;
1312
				echo " SELECTED";
1313
			}
1314
			echo ">{$dnq}</option>"; 
1315
		}
1316
?>
1317
				</select>
1318
				<br />
1319
				<span class="vexpl"><?=gettext("Choose the Out queue/Virtual interface only if you have also selected In.")."<br/>".gettext("The Out selection is applied to traffic leaving the interface where the rule is created, In is applied to traffic coming into the chosen interface.")."<br/>".gettext("If you are creating a floating rule, 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.");?></span>
1320
				</div>
1321
			</td>
1322
		</tr>
1323

    
1324
		<tr>
1325
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1326
			<td width="78%" class="vtable">
1327
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1328
				<input type="button" onClick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1329
			</div>
1330
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1331
				<select name="ackqueue">
1332
<?php
1333
			if (!is_array($qlist))
1334
				$qlist = array();
1335
			echo "<option value=\"none\"";
1336
			if (!$qselected) echo " SELECTED";
1337
			echo " >none</option>";
1338
			foreach ($qlist as $q => $qkey) {
1339
				if($q == "")
1340
					continue;
1341
				echo "<option value=\"$q\"";
1342
				if ($q == $pconfig['ackqueue']) {
1343
					$qselected = 1;
1344
					echo " SELECTED";
1345
				}
1346
				if (isset($ifdisp[$q]))
1347
					echo ">{$ifdisp[$q]}</option>";
1348
				else
1349
					echo ">{$q}</option>"; 
1350
			}
1351
?>
1352
				</select> / 			
1353
				<select name="defaultqueue">
1354
<?php
1355
			$qselected = 0;
1356
			echo "<option value=\"none\"";
1357
			if (!$qselected) echo " SELECTED";
1358
			echo " >none</option>";
1359
			foreach ($qlist as $q => $qkey) {
1360
				if($q == "")
1361
					continue;
1362
				echo "<option value=\"$q\"";
1363
				if ($q == $pconfig['defaultqueue']) {
1364
					$qselected = 1;
1365
					echo " SELECTED";
1366
				}
1367
				if (isset($ifdisp[$q]))
1368
					echo ">{$ifdisp[$q]}</option>";
1369
				else
1370
					echo ">{$q}</option>"; 
1371
			}
1372
?>
1373
				</select>
1374
					<br />
1375
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1376
				</td>
1377
			</tr>
1378
			<tr>
1379
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1380
				<td width="78%" class="vtable">
1381
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1382
						<input type="button" onClick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>"></input> - <?=gettext("Show advanced option");?></a>
1383
					</div>
1384
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1385
				<select name="l7container">
1386
<?php
1387
					if (!is_array($l7clist))
1388
						$l7clist = array();
1389
					echo "<option value=\"none\"";
1390
					echo " >none</option>";
1391
					foreach ($l7clist as $l7ckey) {
1392
						echo "<option value=\"{$l7ckey}\"";
1393
						if ($l7ckey == $pconfig['l7container']) {
1394
							echo " SELECTED";
1395
						}
1396
						echo ">{$l7ckey}</option>"; 
1397
					}
1398
?>
1399
				</select>			
1400
				<br/>
1401
				<span class="vexpl">
1402
					<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1403
					"These are valid for TCP and UDP protocols only.");?>
1404
				</span>
1405
			  </div>
1406
			</td>
1407
		</tr>
1408
		<tr>
1409
			<td width="22%" valign="top">&nbsp;</td>
1410
			<td width="78%">
1411
				&nbsp;<br>&nbsp;
1412
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
1413
<?php			if (isset($id) && $a_filter[$id]): ?>
1414
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
1415
<?php 			endif; ?>
1416
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>">
1417
			</td>
1418
		</tr>
1419
	</table>
1420
</form>
1421
<script language="JavaScript">
1422
<!--
1423
	ext_change();
1424
	typesel_change();
1425
	proto_change();
1426
	<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
1427
	show_source_port_range();
1428
	<?php endif; ?>
1429

    
1430
<?php
1431
	$isfirst = 0;
1432
	$aliases = "";
1433
	$addrisfirst = 0;
1434
	$aliasesaddr = "";
1435
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1436
		foreach($config['aliases']['alias'] as $alias_name) {
1437
			switch ($alias_name['type']) {
1438
			case "port":
1439
				if($isfirst == 1) $portaliases .= ",";
1440
				$portaliases .= "'" . $alias_name['name'] . "'";
1441
				$isfirst = 1;
1442
				break;
1443
			case "host":
1444
			case "network":
1445
			case "openvpn":
1446
			case "urltable":
1447
				if($addrisfirst == 1) $aliasesaddr .= ",";
1448
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1449
				$addrisfirst = 1;
1450
				break;
1451
			default:
1452
				break;
1453
			}
1454
		}
1455
?>
1456

    
1457
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1458
	var customarray=new Array(<?php echo $portaliases; ?>);
1459

    
1460
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1461
        var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1462
        var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1463
        var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1464
        var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1465
        var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1466
//-->
1467
</script>
1468
<?php include("fend.inc"); ?>
1469
</body>
1470
</html>
(64-64/231)