Projet

Général

Profil

Télécharger (79,6 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_rules_edit.php @ 1b244d38

1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules_edit.php
5
	part of pfSense (https://www.pfsense.org)
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_once("filter.inc");
46
require("shaper.inc");
47

    
48
function is_posnumericint($arg) {
49
	// Note that to be safe we do not allow any leading zero - "01", "007"
50
	return (is_numericint($arg) && $arg[0] != '0' && $arg > 0);
51
}
52

    
53
function is_aoadv_used($rule_config) {
54
	// Note that the user could set "tag" or "tagged" to the string "0", which is valid but empty().
55
	// And if the user enters "0" in other fields, we want to present an error message, and keep the Advanced Options section open.
56
	if ((isset($rule_config['allowopts'])) ||
57
	    (isset($rule_config['disablereplyto'])) ||
58
	    ($rule_config['tag'] != "") ||
59
	    ($rule_config['tagged'] != "") ||
60
	    ($rule_config['max'] != "") ||
61
	    ($rule_config['max-src-nodes'] != "") ||
62
	    ($rule_config['max-src-conn'] != "") ||
63
	    ($rule_config['max-src-states'] != "") ||
64
	    ($rule_config['max-src-conn-rate'] != "") ||
65
	    ($rule_config['max-src-conn-rates'] != "") ||
66
	    ($rule_config['statetimeout'] != ""))
67
		return true;
68
	return false;
69
}
70

    
71
$ostypes = array();
72
exec('/sbin/pfctl -s osfp | /usr/bin/tr \'\t\' \' \'', $ostypes);
73

    
74
if (count($ostypes) > 2) {
75
	// Remove header rows from pfctl output
76
	array_shift($ostypes);
77
	array_shift($ostypes);
78
} else {
79
	// Fall back to a default list
80
	$ostypes = array(
81
		"AIX",
82
		"Linux",
83
		"FreeBSD",
84
		"NetBSD",
85
		"OpenBSD",
86
		"Solaris",
87
		"MacOS",
88
		"Windows",
89
		"Novell",
90
		"NMAP"
91
	);
92
}
93

    
94
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
95
$ifdisp = get_configured_interface_with_descr();
96
foreach ($ifdisp as $kif => $kdescr) {
97
	$specialsrcdst[] = "{$kif}";
98
	$specialsrcdst[] = "{$kif}ip";
99
}
100

    
101
if (!is_array($config['filter']['rule'])) {
102
	$config['filter']['rule'] = array();
103
}
104
filter_rules_sort();
105
$a_filter = &$config['filter']['rule'];
106

    
107
if (is_numericint($_GET['id']))
108
	$id = $_GET['id'];
109
if (isset($_POST['id']) && is_numericint($_POST['id']))
110
	$id = $_POST['id'];
111

    
112
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
113
	$after = $_GET['after'];
114
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
115
	$after = $_POST['after'];
116

    
117
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
118
        $id = $_GET['dup'];
119
        $after = $_GET['dup'];
120
}
121

    
122
if (isset($id) && $a_filter[$id]) {
123
	$pconfig['interface'] = $a_filter[$id]['interface'];
124

    
125
	if (isset($a_filter[$id]['id']))
126
		$pconfig['ruleid'] = $a_filter[$id]['id'];
127

    
128
	if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
129
		$pconfig['created'] = $a_filter[$id]['created'];
130

    
131
	if ( isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']) )
132
		$pconfig['updated'] = $a_filter[$id]['updated'];
133

    
134
	if (!isset($a_filter[$id]['type']))
135
		$pconfig['type'] = "pass";
136
	else
137
		$pconfig['type'] = $a_filter[$id]['type'];
138

    
139
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
140
		$pconfig['floating'] = $a_filter[$id]['floating'];
141
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "")
142
			$pconfig['interface'] = $a_filter[$id]['interface'];
143
	}
144

    
145
	if (isset($a_filter['floating']))
146
		$pconfig['floating'] = "yes";
147

    
148
	if (isset($a_filter[$id]['direction']))
149
		$pconfig['direction'] = $a_filter[$id]['direction'];
150

    
151
	if (isset($a_filter[$id]['ipprotocol']))
152
		$pconfig['ipprotocol'] = $a_filter[$id]['ipprotocol'];
153

    
154
	if (isset($a_filter[$id]['protocol']))
155
		$pconfig['proto'] = $a_filter[$id]['protocol'];
156
	else
157
		$pconfig['proto'] = "any";
158

    
159
	if ($a_filter[$id]['protocol'] == "icmp")
160
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
161

    
162
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
163
		$pconfig['srcmask'], $pconfig['srcnot'],
164
		$pconfig['srcbeginport'], $pconfig['srcendport']);
165

    
166
	if($a_filter[$id]['os'] <> "")
167
		$pconfig['os'] = $a_filter[$id]['os'];
168

    
169
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
170
		$pconfig['dstmask'], $pconfig['dstnot'],
171
		$pconfig['dstbeginport'], $pconfig['dstendport']);
172

    
173
	if ($a_filter[$id]['dscp'] <> "")
174
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
175

    
176
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
177
	$pconfig['log'] = isset($a_filter[$id]['log']);
178
	$pconfig['descr'] = $a_filter[$id]['descr'];
179

    
180
	if (isset($a_filter[$id]['tcpflags_any']))
181
		$pconfig['tcpflags_any'] = true;
182
	else {
183
		if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "")
184
			$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
185
		if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "")
186
			$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
187
	}
188

    
189
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "")
190
		$pconfig['tag'] = $a_filter[$id]['tag'];
191
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
192
		$pconfig['tagged'] = $a_filter[$id]['tagged'];
193
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
194
		$pconfig['quick'] = $a_filter[$id]['quick'];
195
	if (isset($a_filter[$id]['allowopts']))
196
		$pconfig['allowopts'] = true;
197
	if (isset($a_filter[$id]['disablereplyto']))
198
		$pconfig['disablereplyto'] = true;
199

    
200
	/* advanced */
201
	$pconfig['max'] = $a_filter[$id]['max'];
202
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
203
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
204
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
205
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
206
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
207
	$pconfig['nopfsync'] = isset($a_filter[$id]['nopfsync']);
208

    
209
	/* advanced - nosync */
210
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
211

    
212
	/* advanced - new connection per second banning*/
213
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
214
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
215

    
216
	/* Multi-WAN next-hop support */
217
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
218

    
219
	/* Shaper support */
220
	$pconfig['defaultqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['defaultqueue']);
221
	$pconfig['ackqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['ackqueue']);
222
	$pconfig['dnpipe'] = (($a_filter[$id]['dnpipe'] == "none") ? '' : $a_filter[$id]['dnpipe']);
223
	$pconfig['pdnpipe'] = (($a_filter[$id]['pdnpipe'] == "none") ? '' : $a_filter[$id]['pdnpipe']);
224
	$pconfig['l7container'] = (($a_filter[$id]['l7container'] == "none") ? '' : $a_filter[$id]['l7container']);
225

    
226
	//schedule support
227
	$pconfig['sched'] = (($a_filter[$id]['sched'] == "none") ? '' : $a_filter[$id]['sched']);
228
	$pconfig['vlanprio'] = (($a_filter[$id]['vlanprio'] == "none") ? '' : $a_filter[$id]['vlanprio']);
229
	$pconfig['vlanprioset'] = (($a_filter[$id]['vlanprioset'] == "none") ? '' : $a_filter[$id]['vlanprioset']);
230
	if (!isset($_GET['dup']) || !is_numericint($_GET['dup']))
231
		$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
232

    
233
	$pconfig['tracker'] = $a_filter[$id]['tracker'];
234

    
235
} else {
236
	/* defaults */
237
	if ($_GET['if'])
238
		$pconfig['interface'] = $_GET['if'];
239
	$pconfig['type'] = "pass";
240
	$pconfig['src'] = "any";
241
	$pconfig['dst'] = "any";
242
}
243
/* Allow the FloatingRules to work */
244
$if = $pconfig['interface'];
245

    
246
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
247
	unset($id);
248

    
249
read_altq_config(); /* XXX: */
250
$qlist =& get_unique_queue_list();
251
read_dummynet_config(); /* XXX: */
252
$dnqlist =& get_unique_dnqueue_list();
253
read_layer7_config();
254
$l7clist =& get_l7_unique_list();
255
$a_gatewaygroups = return_gateway_groups_array();
256

    
257
if ($_POST) {
258
	unset($input_errors);
259

    
260
	if( isset($a_filter[$id]['associated-rule-id']) ) {
261
		$_POST['proto'] = $pconfig['proto'];
262
		if ($pconfig['proto'] == "icmp")
263
			$_POST['icmptype'] = $pconfig['icmptype'];
264
	}
265

    
266
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
267
		if(is_array($config['gateways']['gateway_group'])) {
268
			foreach($config['gateways']['gateway_group'] as $gw_group) {
269
				if($gw_group['name'] == $_POST['gateway']) {
270
					$family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol'];
271
					if($_POST['ipprotocol'] == $family) {
272
						continue;
273
					}
274
					if(($_POST['ipprotocol'] == "inet46") && ($_POST['ipprotocol'] != $family)) {
275
						$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
276
					}
277
					if(($_POST['ipprotocol'] == "inet6") && ($_POST['ipprotocol'] != $family)) {
278
						$input_errors[] = gettext("You can not assign a IPv4 gateway group on IPv6 Address Family rule");
279
					}
280
					if(($_POST['ipprotocol'] == "inet") && ($_POST['ipprotocol'] != $family)) {
281
						$input_errors[] = gettext("You can not assign a IPv6 gateway group on IPv4 Address Family rule");
282
					}
283
				}
284
			}
285
		}
286
	}
287
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "") && (is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway'])))) {
288
		if(($_POST['ipprotocol'] == "inet46") && ($_POST['gateway'] <> "")) {
289
			$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
290
		}
291
		if(($_POST['ipprotocol'] == "inet6") && (!is_ipaddrv6(lookup_gateway_ip_by_name($_POST['gateway'])))) {
292
			$input_errors[] = gettext("You can not assign the IPv4 Gateway to a IPv6 Filter rule");
293
		}
294
		if(($_POST['ipprotocol'] == "inet") && (!is_ipaddrv4(lookup_gateway_ip_by_name($_POST['gateway'])))) {
295
			$input_errors[] = gettext("You can not assign the IPv6 Gateway to a IPv4 Filter rule");
296
		}
297
	}
298

    
299
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp") && ($_POST['proto'] != "icmp")) {
300
		if($_POST['ipprotocol'] == "inet46")
301
			$input_errors[] =  gettext("You can not assign a protocol other then ICMP, TCP, UDP or TCP/UDP to a rule that applies to IPv4 and IPv6");
302
	}
303
	if (($_POST['proto'] == "icmp") && ($_POST['icmptype'] <> "")){
304
		if($_POST['ipprotocol'] == "inet46")
305
			$input_errors[] =  gettext("You can not assign a ICMP type to a rule that applies to IPv4 and IPv6");
306
	}
307

    
308
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
309
		$_POST['srcbeginport'] = 0;
310
		$_POST['srcendport'] = 0;
311
		$_POST['dstbeginport'] = 0;
312
		$_POST['dstendport'] = 0;
313
	} else {
314
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
315
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
316
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
317
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
318
		if ($_POST['srcbeginport'] == "any") {
319
			$_POST['srcbeginport'] = 0;
320
			$_POST['srcendport'] = 0;
321
		} else {
322
			if (!$_POST['srcendport'])
323
				$_POST['srcendport'] = $_POST['srcbeginport'];
324
		}
325
		if ($_POST['srcendport'] == "any")
326
			$_POST['srcendport'] = $_POST['srcbeginport'];
327

    
328
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
329
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
330
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
331
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
332

    
333
		if ($_POST['dstbeginport'] == "any") {
334
			$_POST['dstbeginport'] = 0;
335
			$_POST['dstendport'] = 0;
336
		} else {
337
			if (!$_POST['dstendport'])
338
				$_POST['dstendport'] = $_POST['dstbeginport'];
339
		}
340
		if ($_POST['dstendport'] == "any")
341
			$_POST['dstendport'] = $_POST['dstbeginport'];
342
	}
343

    
344
	if (is_specialnet($_POST['srctype'])) {
345
		$_POST['src'] = $_POST['srctype'];
346
		$_POST['srcmask'] = 0;
347
	} else if ($_POST['srctype'] == "single") {
348
		if (is_ipaddrv6($_POST['src']))
349
			$_POST['srcmask'] = 128;
350
		else
351
			$_POST['srcmask'] = 32;
352
	}
353
	if (is_specialnet($_POST['dsttype'])) {
354
		$_POST['dst'] = $_POST['dsttype'];
355
		$_POST['dstmask'] = 0;
356
	}  else if ($_POST['dsttype'] == "single") {
357
		if (is_ipaddrv6($_POST['dst']))
358
			$_POST['dstmask'] = 128;
359
		else
360
			$_POST['dstmask'] = 32;
361
	}
362

    
363
	$pconfig = $_POST;
364

    
365
	/* input validation */
366
	$reqdfields = explode(" ", "type proto");
367
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
368
		$reqdfields[] = "src";
369
		$reqdfields[] = "dst";
370
	}
371
	$reqdfieldsn = explode(",", "Type,Protocol");
372
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
373
		$reqdfieldsn[] = "Source";
374
		$reqdfieldsn[] = "Destination";
375
	}
376

    
377
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
378
		if( $_POST['proto'] != "tcp" )
379
			$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
380
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
381
			$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
382
	}
383

    
384
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
385
	(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
386
		$reqdfields[] = "srcmask";
387
		$reqdfieldsn[] = "Source bit count";
388
	}
389
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
390
	(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
391
		$reqdfields[] = "dstmask";
392
		$reqdfieldsn[] = gettext("Destination bit count");
393
	}
394

    
395
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
396

    
397
	if (!$_POST['srcbeginport']) {
398
		$_POST['srcbeginport'] = 0;
399
		$_POST['srcendport'] = 0;
400
	}
401
	if (!$_POST['dstbeginport']) {
402
		$_POST['dstbeginport'] = 0;
403
		$_POST['dstendport'] = 0;
404
	}
405

    
406
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
407
		$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']);
408
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
409
			$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']);
410
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
411
			$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']);
412
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
413
			$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']);
414
	if ( !$_POST['srcbeginport_cust'] && $_POST['srcendport_cust'])
415
		if (is_alias($_POST['srcendport_cust']))
416
			$input_errors[] = 'If you put port alias in Source port range to: field you must put the same port alias in from: field';
417
	if ( $_POST['srcbeginport_cust'] && $_POST['srcendport_cust']){
418
		if (is_alias($_POST['srcendport_cust']) && is_alias($_POST['srcendport_cust']) && $_POST['srcbeginport_cust'] != $_POST['srcendport_cust'])
419
			$input_errors[] = 'The same port alias must be used in Source port range from: and to: fields';
420
		if ((is_alias($_POST['srcbeginport_cust']) && (!is_alias($_POST['srcendport_cust']) && $_POST['srcendport_cust']!='')) ||
421
		    ((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust']!='') && is_alias($_POST['srcendport_cust'])))
422
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Source port range from: and to: field';
423
	}
424
	if ( !$_POST['dstbeginport_cust'] && $_POST['dstendport_cust'])
425
		if (is_alias($_POST['dstendport_cust']))
426
			$input_errors[] = 'If you put port alias in Destination port range to: field you must put the same port alias in from: field';
427
	if ( $_POST['dstbeginport_cust'] && $_POST['dstendport_cust']){
428
		if (is_alias($_POST['dstendport_cust']) && is_alias($_POST['dstendport_cust']) && $_POST['dstbeginport_cust'] != $_POST['dstendport_cust'])
429
			$input_errors[] = 'The same port alias must be used in Destination port range from: and to: fields';
430
		if ((is_alias($_POST['dstbeginport_cust']) && (!is_alias($_POST['dstendport_cust']) && $_POST['dstendport_cust']!='')) ||
431
		    ((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust']!='') && is_alias($_POST['dstendport_cust'])))
432
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field';
433
	}
434

    
435
	if ($_POST['src'])
436
		$_POST['src'] = trim($_POST['src']);
437
	if ($_POST['dst'])
438
		$_POST['dst'] = trim($_POST['dst']);
439

    
440
	/* if user enters an alias and selects "network" then disallow. */
441
	if($_POST['srctype'] == "network") {
442
		if(is_alias($_POST['src']))
443
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
444
	}
445
	if($_POST['dsttype'] == "network") {
446
		if(is_alias($_POST['dst']))
447
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
448
	}
449

    
450
	if (!is_specialnet($_POST['srctype'])) {
451
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
452
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
453
		}
454
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
455
			$input_errors[] = gettext("A valid source bit count must be specified.");
456
		}
457
	}
458
	if (!is_specialnet($_POST['dsttype'])) {
459
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
460
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
461
		}
462
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
463
			$input_errors[] = gettext("A valid destination bit count must be specified.");
464
		}
465
	}
466
	if((is_ipaddr($_POST['src']) && is_ipaddr($_POST['dst']))) {
467
		if(!validate_address_family($_POST['src'], $_POST['dst']))
468
			$input_errors[] = sprintf(gettext("The Source IP address %s Address Family differs from the destination %s."), $_POST['src'], $_POST['dst']);
469
		if((is_ipaddrv6($_POST['src']) || is_ipaddrv6($_POST['dst'])) && ($_POST['ipprotocol'] == "inet"))
470
			$input_errors[] = gettext("You can not use IPv6 addresses in IPv4 rules.");
471
		if((is_ipaddrv4($_POST['src']) || is_ipaddrv4($_POST['dst'])) && ($_POST['ipprotocol'] == "inet6"))
472
			$input_errors[] = gettext("You can not use IPv4 addresses in IPv6 rules.");
473
	}
474

    
475
	if((is_ipaddr($_POST['src']) || is_ipaddr($_POST['dst'])) && ($_POST['ipprotocol'] == "inet46"))
476
		$input_errors[] = gettext("You can not use a IPv4 or IPv6 address in combined IPv4 + IPv6 rules.");
477

    
478
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
479
		/* swap */
480
		$tmp = $_POST['srcendport'];
481
		$_POST['srcendport'] = $_POST['srcbeginport'];
482
		$_POST['srcbeginport'] = $tmp;
483
	}
484
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
485
		/* swap */
486
		$tmp = $_POST['dstendport'];
487
		$_POST['dstendport'] = $_POST['dstbeginport'];
488
		$_POST['dstbeginport'] = $tmp;
489
	}
490
	if ($_POST['os']) {
491
		if( $_POST['proto'] != "tcp" )
492
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
493
		if (!in_array($_POST['os'], $ostypes))
494
			$input_errors[] = gettext("Invalid OS detection selection. Please select a valid OS.");
495
	}
496

    
497
	if ($_POST['ackqueue'] != "") {
498
		if ($_POST['defaultqueue'] == "" )
499
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
500
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
501
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
502
	}
503
	if (isset($_POST['floating']) && $_POST['pdnpipe'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
504
		$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
505
	if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
506
		$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
507
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "") {
508
		if ($_POST['dnpipe'] == "" )
509
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
510
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
511
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
512
		else if ($dnqlist[$_POST['pdnpipe']][0] == "?" && $dnqlist[$_POST['dnpipe']][0] <> "?")
513
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
514
		else if ($dnqlist[$_POST['dnpipe']][0] == "?" && $dnqlist[$_POST['pdnpipe']][0] <> "?")
515
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
516
		if ($_POST['direction'] == "out" && empty($_POST['gateway']))
517
			$input_errors[] = gettext("Please select a gateway, normaly the interface selected gateway, so the limiters work correctly");
518
	}
519
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
520
		$input_errors[] = gettext('ID must be an integer');
521
	if($_POST['l7container'] && $_POST['l7container'] != "") {
522
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
523
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
524
		if ($_POST['type'] <> "pass")
525
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
526
	}
527

    
528
	if (!in_array($_POST['proto'], array("tcp","tcp/udp"))) {
529
		if (!empty($_POST['max-src-conn']))
530
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
531
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
532
			$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for TCP protocol.");
533
		if (!empty($_POST['statetimeout']))
534
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
535
	}
536

    
537
	if ($_POST['type'] <> "pass") {
538
		if (!empty($_POST['max']))
539
			$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for Pass type rules.");
540
		if (!empty($_POST['max-src-nodes']))
541
			$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for Pass type rules.");
542
		if (!empty($_POST['max-src-conn']))
543
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for Pass type rules.");
544
		if (!empty($_POST['max-src-states']))
545
			$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for Pass type rules.");
546
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
547
			$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for Pass type rules.");
548
		if (!empty($_POST['statetimeout']))
549
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for Pass type rules.");
550
	}
551

    
552
	if (($_POST['statetype'] == "none") && (empty($_POST['l7container']))) {
553
		if (!empty($_POST['max']))
554
			$input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected.");
555
		if (!empty($_POST['max-src-nodes']))
556
			$input_errors[] = gettext("You cannot specify the maximum number of unique source hosts (advanced option) if statetype is none and no L7 container is selected.");
557
		if (!empty($_POST['max-src-conn']))
558
			$input_errors[] = gettext("You cannot specify the maximum number of established connections per host (advanced option) if statetype is none and no L7 container is selected.");
559
		if (!empty($_POST['max-src-states']))
560
			$input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected.");
561
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
562
			$input_errors[] = gettext("You cannot specify the maximum new connections per host / per second(s) (advanced option) if statetype is none and no L7 container is selected.");
563
		if (!empty($_POST['statetimeout']))
564
			$input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected.");
565
	}
566

    
567
	if (($_POST['max'] != "") && !is_posnumericint($_POST['max']))
568
		$input_errors[] = gettext("Maximum state entries (advanced option) must be a positive integer");
569

    
570
	if (($_POST['max-src-nodes'] != "") && !is_posnumericint($_POST['max-src-nodes']))
571
		$input_errors[] = gettext("Maximum number of unique source hosts (advanced option) must be a positive integer");
572

    
573
	if (($_POST['max-src-conn'] != "") && !is_posnumericint($_POST['max-src-conn']))
574
		$input_errors[] = gettext("Maximum number of established connections per host (advanced option) must be a positive integer");
575

    
576
	if (($_POST['max-src-states'] != "") && !is_posnumericint($_POST['max-src-states']))
577
		$input_errors[] = gettext("Maximum state entries per host (advanced option) must be a positive integer");
578

    
579
	if (($_POST['max-src-conn-rate'] != "") && !is_posnumericint($_POST['max-src-conn-rate']))
580
		$input_errors[] = gettext("Maximum new connections per host / per second(s) (advanced option) must be a positive integer");
581

    
582
	if (($_POST['statetimeout'] != "") && !is_posnumericint($_POST['statetimeout']))
583
		$input_errors[] = gettext("State timeout (advanced option) must be a positive integer");
584

    
585
	if ((($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] == "")) || 
586
	    (($_POST['max-src-conn-rate'] == "" and $_POST['max-src-conn-rates'] <> "")))
587
		$input_errors[] = gettext("Both maximum new connections per host and the interval (per second(s)) must be specified");
588

    
589
	if (!$_POST['tcpflags_any']) {
590
		$settcpflags = array();
591
		$outoftcpflags = array();
592
		foreach ($tcpflags as $tcpflag) {
593
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
594
				$settcpflags[] = $tcpflag;
595
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
596
				$outoftcpflags[] = $tcpflag;
597
		}
598
		if (empty($outoftcpflags) && !empty($settcpflags))
599
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
600
	}
601

    
602
	// Allow extending of the firewall edit page and include custom input validation
603
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
604

    
605
	if (!$input_errors) {
606
		$filterent = array();
607
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
608

    
609
		$filterent['tracker'] = empty($_POST['tracker']) ? (int)microtime(true) : $_POST['tracker'];
610

    
611
		$filterent['type'] = $_POST['type'];
612
		if (isset($_POST['interface'] ))
613
			$filterent['interface'] = $_POST['interface'];
614

    
615
		if (isset($_POST['ipprotocol'] ))
616
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
617

    
618
		if ($_POST['tcpflags_any']) {
619
			$filterent['tcpflags_any'] = true;
620
		} else {
621
			$settcpflags = array();
622
			$outoftcpflags = array();
623
			foreach ($tcpflags as $tcpflag) {
624
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
625
					$settcpflags[] = $tcpflag;
626
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
627
					$outoftcpflags[] = $tcpflag;
628
			}
629
			if (!empty($outoftcpflags)) {
630
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
631
				if (!empty($settcpflags))
632
					$filterent['tcpflags1'] = join(",", $settcpflags);
633
			}
634
		}
635

    
636
		if (isset($_POST['tag']))
637
			$filterent['tag'] = $_POST['tag'];
638
		if (isset($_POST['tagged']))
639
			$filterent['tagged'] = $_POST['tagged'];
640
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
641
			$filterent['direction'] = $_POST['direction'];
642
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
643
				$filterent['quick'] = $_POST['quick'];
644
			$filterent['floating'] = "yes";
645
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
646
				$filterent['interface'] = implode(",", $_POST['interface']);
647
			}
648
		}
649

    
650
		/* Advanced options */
651
		if ($_POST['allowopts'] == "yes")
652
			$filterent['allowopts'] = true;
653
		else
654
			unset($filterent['allowopts']);
655
		if ($_POST['disablereplyto'] == "yes")
656
			$filterent['disablereplyto'] = true;
657
		else
658
			unset($filterent['disablereplyto']);
659
		$filterent['max'] = $_POST['max'];
660
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
661
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
662
		$filterent['max-src-states'] = $_POST['max-src-states'];
663
		$filterent['statetimeout'] = $_POST['statetimeout'];
664
		$filterent['statetype'] = $_POST['statetype'];
665
		$filterent['os'] = $_POST['os'];
666
		if($_POST['nopfsync'] <> "")
667
			$filterent['nopfsync'] = true;
668
		else
669
			unset($filterent['nopfsync']);
670

    
671
		/* Nosync directive - do not xmlrpc sync this item */
672
		if($_POST['nosync'] <> "")
673
			$filterent['nosync'] = true;
674
		else
675
			unset($filterent['nosync']);
676

    
677
		/* unless both values are provided, unset the values - ticket #650 */
678
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
679
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
680
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
681
		} else {
682
			unset($filterent['max-src-conn-rate']);
683
			unset($filterent['max-src-conn-rates']);
684
		}
685

    
686
		if ($_POST['proto'] != "any")
687
			$filterent['protocol'] = $_POST['proto'];
688
		else
689
			unset($filterent['protocol']);
690

    
691
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
692
			$filterent['icmptype'] = $_POST['icmptype'];
693
		else
694
			unset($filterent['icmptype']);
695

    
696
		pconfig_to_address($filterent['source'], $_POST['src'],
697
			$_POST['srcmask'], $_POST['srcnot'],
698
			$_POST['srcbeginport'], $_POST['srcendport']);
699

    
700
		pconfig_to_address($filterent['destination'], $_POST['dst'],
701
			$_POST['dstmask'], $_POST['dstnot'],
702
			$_POST['dstbeginport'], $_POST['dstendport']);
703

    
704
		if ($_POST['disabled'])
705
			$filterent['disabled'] = true;
706
		else
707
			unset($filterent['disabled']);
708

    
709
		if ($_POST['dscp'])
710
			$filterent['dscp'] = $_POST['dscp'];
711

    
712
		if ($_POST['log'])
713
			$filterent['log'] = true;
714
		else
715
			unset($filterent['log']);
716
		strncpy($filterent['descr'], $_POST['descr'], 52);
717

    
718
		if ($_POST['gateway'] != "") {
719
			$filterent['gateway'] = $_POST['gateway'];
720
		}
721

    
722
		if ($_POST['defaultqueue'] != "") {
723
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
724
			if ($_POST['ackqueue'] != "")
725
				$filterent['ackqueue'] = $_POST['ackqueue'];
726
		}
727

    
728
		if ($_POST['dnpipe'] != "") {
729
			$filterent['dnpipe'] = $_POST['dnpipe'];
730
			if ($_POST['pdnpipe'] != "")
731
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
732
		}
733

    
734
		if ($_POST['l7container'] != "") {
735
			$filterent['l7container'] = $_POST['l7container'];
736
		}
737

    
738
		if ($_POST['sched'] != "") {
739
			$filterent['sched'] = $_POST['sched'];
740
		}
741

    
742
		if ($_POST['vlanprio'] != "") {
743
			$filterent['vlanprio'] = $_POST['vlanprio'];
744
		}
745
		if ($_POST['vlanprioset'] != "") {
746
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
747
		}
748

    
749
		// If we have an associated nat rule, make sure the source and destination doesn't change
750
		if( isset($a_filter[$id]['associated-rule-id']) ) {
751
			$filterent['interface'] = $a_filter[$id]['interface'];
752
			if (isset($a_filter[$id]['protocol']))
753
				$filterent['protocol'] = $a_filter[$id]['protocol'];
754
			else if (isset($filterent['protocol']))
755
				unset($filterent['protocol']);
756
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
757
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
758
			else if (isset($filterent['icmptype']))
759
				unset($filterent['icmptype']);
760

    
761
			$filterent['source'] = $a_filter[$id]['source'];
762
			$filterent['destination'] = $a_filter[$id]['destination'];
763
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
764
		}
765

    
766
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
767
			$filterent['created'] = $a_filter[$id]['created'];
768

    
769
		$filterent['updated'] = make_config_revision_entry();
770

    
771
		// Allow extending of the firewall edit page and include custom input validation
772
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
773

    
774
		if (isset($id) && $a_filter[$id])
775
			$a_filter[$id] = $filterent;
776
		else {
777
			$filterent['created'] = make_config_revision_entry();
778
			if (is_numeric($after))
779
				array_splice($a_filter, $after+1, 0, array($filterent));
780
			else
781
				$a_filter[] = $filterent;
782
		}
783

    
784
		filter_rules_sort();
785

    
786
		if (write_config())
787
			mark_subsystem_dirty('filter');
788

    
789
		if (isset($_POST['floating']))
790
			header("Location: firewall_rules.php?if=FloatingRules");
791
		else
792
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
793
		exit;
794
	}
795
}
796

    
797
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
798
$shortcut_section = "firewall";
799

    
800
$closehead = false;
801

    
802
$page_filename = "firewall_rules_edit.php";
803
include("head.inc");
804

    
805
?>
806
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
807
</head>
808

    
809
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
810
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
811
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
812
<?php include("fbegin.inc"); ?>
813
<?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_input_errors"); ?>
814
<?php if ($input_errors) print_input_errors($input_errors); ?>
815

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

    
819
	<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall rules edit">
820
		<tr>
821
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
822
		</tr>
823
<?php
824
		// Allow extending of the firewall edit page and include custom input validation
825
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
826
?>
827
		<tr>
828
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
829
			<td width="78%" class="vtable">
830
				<select name="type" class="formselect">
831
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
832
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>
833
					<?=htmlspecialchars($type);?>
834
					</option>
835
					<?php endforeach; ?>
836
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
837
					<option value="match" <?php if ("match" == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>Match</option>
838
<?php endif; ?>
839
				</select>
840
				<br />
841
				<span class="vexpl">
842
					<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br />
843
					<?=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.");?>
844
				</span>
845
			</td>
846
		</tr>
847
		<tr>
848
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
849
			<td width="78%" class="vtable">
850
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
851
				<strong><?=gettext("Disable this rule");?></strong><br />
852
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
853
			</td>
854
		</tr>
855
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
856
		<tr>
857
			<td width="22%" valign="top" class="vncellreq">
858
				<?=gettext("Quick");?>
859
			</td>
860
			<td width="78%" class="vtable">
861
				<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
862
				<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
863
				<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
864
			</td>
865
		</tr>
866
<?php endif; ?>
867
<?php $edit_disabled = ""; ?>
868
<?php if( isset($pconfig['associated-rule-id']) ): ?>
869
		<tr>
870
			<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
871
			<td width="78%" class="vtable">
872
				<span class="red"><strong><?=gettext("Note: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
873
				<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
874
				<br />
875
				<?php
876
					$edit_disabled = "disabled";
877
					if (is_array($config['nat']['rule'])) {
878
						foreach( $config['nat']['rule'] as $index => $nat_rule ) {
879
							if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
880
								echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br />";
881
								break;
882
							}
883
						}
884
					}
885
					echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' />";
886
					if (!empty($pconfig['interface']))
887
						echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' />";
888
				?>
889
				<script type="text/javascript">
890
				//<![CDATA[
891
				editenabled = 0;
892
				//]]>
893
				</script>
894
			</td>
895
		</tr>
896
<?php endif; ?>
897
		<tr>
898
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
899
			<td width="78%" class="vtable">
900
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
901
				<select name="interface[]" title="Select interfaces..." multiple="multiple" style="width:350px;" class="chzn-select" tabindex="2" <?=$edit_disabled;?>>
902
<?php else: ?>
903
				<select name="interface" class="formselect" <?=$edit_disabled;?>>
904
<?php endif;
905
				/* add group interfaces */
906
				if (is_array($config['ifgroups']['ifgroupentry']))
907
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
908
						if (have_ruleint_access($ifgen['ifname']))
909
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
910
				$ifdescs = get_configured_interface_with_descr();
911
				// Allow extending of the firewall edit page and include custom input validation
912
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
913
				foreach ($ifdescs as $ifent => $ifdesc)
914
					if(have_ruleint_access($ifent))
915
							$interfaces[$ifent] = $ifdesc;
916
					if ($config['l2tp']['mode'] == "server")
917
						if(have_ruleint_access("l2tp"))
918
							$interfaces['l2tp'] = "L2TP VPN";
919
					if ($config['pptpd']['mode'] == "server")
920
						if(have_ruleint_access("pptp"))
921
							$interfaces['pptp'] = "PPTP VPN";
922

    
923
					if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
924
						$interfaces['pppoe'] = "PPPoE VPN";
925
					/* add ipsec interfaces */
926
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
927
						if(have_ruleint_access("enc0"))
928
							$interfaces["enc0"] = "IPsec";
929
					/* add openvpn/tun interfaces */
930
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
931
						$interfaces["openvpn"] = "OpenVPN";
932
					if (is_array($pconfig['interface']))
933
						$pconfig['interface'] = implode(",", $pconfig['interface']);
934
					$selected_interfaces = explode(",", $pconfig['interface']);
935
					foreach ($interfaces as $iface => $ifacename): ?>
936
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected=\"selected\""; ?>><?=$ifacename?></option>
937
<?php 				endforeach; ?>
938
				</select>
939
				<br />
940
				<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
941
			</td>
942
		</tr>
943
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
944
		<tr>
945
			<td width="22%" valign="top" class="vncellreq">
946
				<?=gettext("Direction");?>
947
			</td>
948
			<td width="78%" class="vtable">
949
				<select name="direction" class="formselect">
950
					<?php      $directions = array('any','in','out');
951
				foreach ($directions as $direction): ?>
952
				<option value="<?=$direction;?>"
953
					<?php if ($direction == $pconfig['direction']): ?>
954
						selected="selected"
955
					<?php endif; ?>
956
					><?=$direction;?></option>
957
				<?php endforeach; ?>
958
				</select>
959
				<input type="hidden" id="floating" name="floating" value="floating" />
960
			</td>
961
		<tr>
962
<?php endif; ?>
963
		<tr>
964
			<td width="22%" valign="top" class="vncellreq"><?=gettext("TCP/IP Version");?></td>
965
			<td width="78%" class="vtable">
966
				<select name="ipprotocol" class="formselect">
967
					<?php      $ipproto = array('inet' => 'IPv4','inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6' );
968
				foreach ($ipproto as $proto => $name): ?>
969
				<option value="<?=$proto;?>"
970
					<?php if ($proto == $pconfig['ipprotocol']): ?>
971
						selected="selected"
972
					<?php endif; ?>
973
					><?=$name;?></option>
974
				<?php endforeach; ?>
975
				</select>
976
				<strong><?=gettext("Select the Internet Protocol version this rule applies to");?></strong><br />
977
			</td>
978
		</tr>
979
		<tr>
980
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
981
			<td width="78%" class="vtable">
982
				<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
983
<?php
984
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP PIM OSPF any carp pfsync");
985
				foreach ($protocols as $proto): ?>
986
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
987
<?php 			endforeach; ?>
988
				</select>
989
				<br />
990
				<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>
991
			</td>
992
		</tr>
993
		<tr id="icmpbox">
994
			<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
995
			<td class="vtable">
996
				<select <?=$edit_disabled;?> name="icmptype" class="formselect">
997
<?php
998
				$icmptypes = array(
999
				"" => gettext("any"),
1000
				"echoreq" => gettext("Echo request"),
1001
				"echorep" => gettext("Echo reply"),
1002
				"unreach" => gettext("Destination unreachable"),
1003
				"squench" => gettext("Source quench"),
1004
				"redir" => gettext("Redirect"),
1005
				"althost" => gettext("Alternate Host"),
1006
				"routeradv" => gettext("Router advertisement"),
1007
				"routersol" => gettext("Router solicitation"),
1008
				"timex" => gettext("Time exceeded"),
1009
				"paramprob" => gettext("Invalid IP header"),
1010
				"timereq" => gettext("Timestamp"),
1011
				"timerep" => gettext("Timestamp reply"),
1012
				"inforeq" => gettext("Information request"),
1013
				"inforep" => gettext("Information reply"),
1014
				"maskreq" => gettext("Address mask request"),
1015
				"maskrep" => gettext("Address mask reply")
1016
				);
1017

    
1018
				foreach ($icmptypes as $icmptype => $descr): ?>
1019
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
1020
<?php 			endforeach; ?>
1021
			</select>
1022
			<br />
1023
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
1024
		</td>
1025
		</tr>
1026
		<tr>
1027
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
1028
			<td width="78%" class="vtable">
1029
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
1030
				<strong><?=gettext("not");?></strong>
1031
				<br />
1032
				<?=gettext("Use this option to invert the sense of the match.");?>
1033
				<br />
1034
				<br />
1035
				<table border="0" cellspacing="0" cellpadding="0">
1036
					<tr>
1037
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
1038
						<td>
1039
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onchange="typesel_change()">
1040
<?php
1041
								$sel = is_specialnet($pconfig['src']); ?>
1042
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1043
								<option value="single"
1044
						<?php  if (!$sel &&
1045
							    ((is_ipaddrv6($pconfig['src']) && $pconfig['srcmask'] == 128) ||
1046
							    (is_ipaddrv4($pconfig['src']) && $pconfig['srcmask'] == 32) || is_alias($pconfig['src'])))
1047
								{ echo "selected=\"selected\""; $sel = 1; }
1048
						?>
1049
								> <?=gettext("Single host or alias");?></option>
1050
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1051
								<?php if(have_ruleint_access("pptp")): ?>
1052
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1053
								<?php endif; ?>
1054
								<?php if(have_ruleint_access("pppoe")): ?>
1055
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1056
								<?php endif; ?>
1057
								<?php if(have_ruleint_access("l2tp")): ?>
1058
								<option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1059
								<?php endif; ?>
1060
<?php
1061
								foreach ($ifdisp as $ifent => $ifdesc): ?>
1062
								<?php if(have_ruleint_access($ifent)): ?>
1063
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
1064
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
1065
										<?=$ifdesc?> <?=gettext("address");?>
1066
									</option>
1067
								<?php endif; ?>
1068
<?php 							endforeach; ?>
1069
							</select>
1070
						</td>
1071
					</tr>
1072
					<tr>
1073
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
1074
						<td>
1075
							<input <?=$edit_disabled;?> autocomplete='off' name="src" type="text" class="formfldalias ipv4v6" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
1076
							<select <?=$edit_disabled;?> name="srcmask" class="formselect ipv4v6" id="srcmask">
1077
<?php						for ($i = 127; $i > 0; $i--): ?>
1078
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
1079
<?php 						endfor; ?>
1080
							</select>
1081
						</td>
1082
					</tr>
1083
				</table>
1084
				<div id="showadvancedboxspr">
1085
					<p>
1086
					<input <?=$edit_disabled;?> type="button" onclick="show_source_port_range()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source port range");?>
1087
					</p>
1088
				</div>
1089
			</td>
1090
		</tr>
1091
		<tr style="display:none" id="sprtable">
1092
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
1093
			<td width="78%" class="vtable">
1094
				<table border="0" cellspacing="0" cellpadding="0">
1095
					<tr>
1096
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1097
						<td>
1098
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
1099
								<option value="">(<?=gettext("other"); ?>)</option>
1100
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1101
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1102
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
1103
<?php 							endforeach; ?>
1104
							</select>
1105
							<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']); ?>" />
1106
						</td>
1107
					</tr>
1108
					<tr>
1109
						<td><?=gettext("to:");?></td>
1110
						<td>
1111
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
1112
								<option value="">(<?=gettext("other"); ?>)</option>
1113
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1114
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1115
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
1116
<?php							endforeach; ?>
1117
							</select>
1118
							<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']); ?>" />
1119
						</td>
1120
					</tr>
1121
				</table>
1122
				<br />
1123
				<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 />
1124
			</td>
1125
		</tr>
1126
		<tr>
1127
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
1128
			<td width="78%" class="vtable">
1129
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
1130
				<strong><?=gettext("not");?></strong>
1131
					<br />
1132
				<?=gettext("Use this option to invert the sense of the match.");?>
1133
					<br />
1134
					<br />
1135
				<table border="0" cellspacing="0" cellpadding="0">
1136
					<tr>
1137
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
1138
						<td>
1139
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onchange="typesel_change()">
1140
<?php
1141
								$sel = is_specialnet($pconfig['dst']); ?>
1142
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1143
								<option value="single"
1144
								<?php  if (!$sel &&
1145
									    ((is_ipaddrv6($pconfig['dst']) && $pconfig['dstmask'] == 128) ||
1146
									    (is_ipaddrv4($pconfig['dst']) && $pconfig['dstmask'] == 32) || is_alias($pconfig['dst'])))
1147
										{ echo "selected=\"selected\""; $sel = 1; }
1148
								?>
1149
								><?=gettext("Single host or alias");?></option>
1150
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1151
								<?php if(have_ruleint_access("pptp")): ?>
1152
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1153
								<?php endif; ?>
1154
								<?php if(have_ruleint_access("pppoe")): ?>
1155
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1156
								<?php endif; ?>
1157
								<?php if(have_ruleint_access("l2tp")): ?>
1158
								<option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1159
								<?php endif; ?>
1160

    
1161
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
1162
								<?php if(have_ruleint_access($if)): ?>
1163
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
1164
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected=\"selected\""; } ?>>
1165
										<?=$ifdesc;?> <?=gettext("address");?>
1166
									</option>
1167
								<?php endif; ?>
1168
<?php 							endforeach; ?>
1169
							</select>
1170
						</td>
1171
					</tr>
1172
					<tr>
1173
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
1174
						<td>
1175
							<input <?=$edit_disabled;?> autocomplete='off' name="dst" type="text" class="formfldalias ipv4v6" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>" />
1176
							/
1177
							<select <?=$edit_disabled;?> name="dstmask" class="formselect ipv4v6" id="dstmask">
1178
<?php
1179
							for ($i = 127; $i > 0;
1180
$i--): ?>
1181
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
1182
<?php						endfor; ?>
1183
							</select>
1184
						</td>
1185
					</tr>
1186
				</table>
1187
			</td>
1188
		</tr>
1189
		<tr id="dprtr">
1190
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range ");?></td>
1191
			<td width="78%" class="vtable">
1192
				<table border="0" cellspacing="0" cellpadding="0">
1193
					<tr>
1194
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1195
						<td>
1196
							<select <?=$edit_disabled;?> name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
1197
								<option value="">(<?=gettext("other"); ?>)</option>
1198
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1199
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1200
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected=\"selected\""; $bfound = 1; }?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
1201
<?php 							endforeach; ?>
1202
							</select>
1203
							<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']); ?>" />
1204
						</td>
1205
					</tr>
1206
					<tr>
1207
						<td><?=gettext("to:");?></td>
1208
						<td>
1209
							<select <?=$edit_disabled;?> name="dstendport" class="formselect" onchange="ext_change()">
1210
								<option value="">(<?=gettext("other"); ?>)</option>
1211
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1212
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1213
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars("{$wkportdesc} ({$wkport})");?></option>
1214
<?php 							endforeach; ?>
1215
							</select>
1216
								<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']); ?>" />
1217
						</td>
1218
					</tr>
1219
				</table>
1220
				<br />
1221
				<span class="vexpl">
1222
					<?=gettext("Specify the port or port range for the destination of the packet for this rule.");?>
1223
					<br />
1224
					<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port");?>
1225
				</span>
1226
			</td>
1227
		</tr>
1228
		<tr>
1229
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Log");?></td>
1230
			<td width="78%" class="vtable">
1231
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked=\"checked\""; ?> />
1232
				<strong><?=gettext("Log packets that are handled by this rule");?></strong>
1233
				<br />
1234
				<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>
1235
			</td>
1236
		</tr>
1237
		<tr>
1238
			<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
1239
			<td width="78%" class="vtable">
1240
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1241
				<br />
1242
				<span class="vexpl"><?=gettext("You may enter a description here for your reference.");?></span>
1243
			</td>
1244
		</tr>
1245
<?php		if (!isset($id) || !($a_filter[$id] && firewall_check_for_advanced_options($a_filter[$id]) <> "")): ?>
1246
		<tr>
1247
			<td width="22%" valign="top">&nbsp;</td>
1248
			<td width="78%">
1249
				&nbsp;<br />&nbsp;
1250
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1251
<?php			if (isset($id) && $a_filter[$id]): ?>
1252
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1253
<?php 			endif; ?>
1254
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1255
			</td>
1256
		</tr>
1257
<?php		endif; ?>
1258
		<tr>
1259
			<td>&nbsp;</td>
1260
		</tr>
1261
		<tr>
1262
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced features");?></td>
1263
		</tr>
1264
		<tr>
1265
			<td width="22%" valign="top" class="vncell"><?=gettext("Source OS");?></td>
1266
			<td width="78%" class="vtable">
1267
				<div id="showadvsourceosbox" <?php if ($pconfig['os']) echo "style='display:none'"; ?>>
1268
					<input type="button" onclick="show_advanced_sourceos()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1269
				</div>
1270
				<div id="showsourceosadv" <?php if (empty($pconfig['os'])) echo "style='display:none'"; ?>>
1271
					<?=gettext("OS Type:");?>&nbsp;
1272
					<select name="os" id="os" class="formselect">
1273
						<option value="" <?php if (empty($pconfig['os'])) echo "selected=\"selected\""; ?>>Any</option>
1274
<?php
1275
						foreach ($ostypes as $ostype): ?>
1276
							<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($ostype);?></option>
1277
<?php
1278
					endforeach;
1279
?>
1280
					</select>
1281
					<br />
1282
					<?=gettext("Note: this only works for TCP rules. General OS choice matches all subtypes.");?>
1283
				</div>
1284
			</td>
1285
		</tr>
1286
		<tr>
1287
			<td width="22%" valign="top" class="vncell"><?=gettext("Diffserv Code Point");?></td>
1288
			<td width="78%" class="vtable">
1289
				<div id="dsadv" <?php if ($pconfig['dscp']) echo "style='display:none'"; ?>>
1290
					<input type="button" onclick="show_dsdiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1291
				</div>
1292
				<div id="dsdivmain" <?php if (empty($pconfig['dscp'])) echo "style='display:none'"; ?>>
1293
					<select name="dscp" id="dscp">
1294
						<option value=""></option>
1295
						<?php foreach($firewall_rules_dscp_types as $frdt): ?>
1296
							<option value="<?=$frdt?>"<?php if($pconfig['dscp'] == $frdt) echo " selected=\"selected\""; ?>><?=$frdt?></option>
1297
						<?php endforeach; ?>
1298
					</select>
1299
				</div>
1300
			</td>
1301
		</tr>
1302
		<tr>
1303
			<td width="22%" valign="top" class="vncell"><?=gettext("Advanced Options");?></td>
1304
			<td width="78%" class="vtable">
1305
			<div id="aoadv" <?php if (is_aoadv_used($pconfig)) echo "style='display:none'"; ?>>
1306
				<input type="button" onclick="show_aodiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1307
			</div>
1308
			<div id="aodivmain" <?php if (!is_aoadv_used($pconfig)) echo "style='display:none'"; ?>>
1309
				<input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked=\"checked\""; ?> />
1310
				<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.");?>
1311
				</span><p>
1312
				<input type="checkbox" id="disablereplyto" value="yes" name="disablereplyto"<?php if($pconfig['disablereplyto'] == true) echo " checked=\"checked\""; ?> />
1313
				<br /><span class="vexpl"><?=gettext("This will disable auto generated reply-to for this rule.");?>
1314
				</span></p><p>
1315
				<input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>" />
1316
				<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>
1317
				</span></p><p>
1318
				<input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>" />
1319
				<br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
1320
				</span></p><p>
1321
				<input name="max" id="max" value="<?php echo htmlspecialchars($pconfig['max']) ?>" /><br /><?=gettext(" Maximum state entries this rule can create");?></p><p>
1322
				<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>
1323
				<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 (TCP only)");?></p><p>
1324
				<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>
1325
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo htmlspecialchars($pconfig['max-src-conn-rate']) ?>" /> /
1326
				<select name="max-src-conn-rates" id="max-src-conn-rates">
1327
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected=\"selected\""; ?>></option>
1328
<?php				for($x=1; $x<255; $x++) {
1329
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected=\"selected\""; else $selected = "";
1330
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
1331
					} ?>
1332
				</select><br />
1333
				<?=gettext("Maximum new connections per host / per second(s) (TCP only)");?>
1334
				</p><p>
1335
				<input name="statetimeout" value="<?php echo htmlspecialchars($pconfig['statetimeout']) ?>" /><br />
1336
				<?=gettext("State Timeout in seconds (TCP only)");?>
1337
				</p>
1338
				<p><strong><?=gettext("Note: Leave fields blank to disable that feature.");?></strong></p>
1339
			</div>
1340
			</td>
1341
		</tr>
1342
		<tr id="tcpflags">
1343
			<td width="22%" valign="top" class="vncell"><?=gettext("TCP flags");?></td>
1344
			<td width="78%" class="vtable">
1345
			<div id="showtcpflagsbox" <?php if ($pconfig['tcpflags_any'] || $pconfig['tcpflags1'] || $pconfig['tcpflags2']) echo "style='display:none'"; ?>>
1346
				<input type="button" onclick="show_advanced_tcpflags()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1347
			</div>
1348
			<div id="showtcpflagsadv" <?php if (empty($pconfig['tcpflags_any']) && empty($pconfig['tcpflags1']) && empty($pconfig['tcpflags2'])) echo "style='display:none'"; ?>>
1349
			<div id="tcpheader" align="center">
1350
			<table border="0" cellspacing="0" cellpadding="0">
1351
			<?php
1352
				$setflags = explode(",", $pconfig['tcpflags1']);
1353
				$outofflags = explode(",", $pconfig['tcpflags2']);
1354
				$header = "<td width='40' class='nowrap'></td>";
1355
				$tcpflags1 = "<td width='40' class='nowrap'>set</td>";
1356
				$tcpflags2 = "<td width='40' class='nowrap'>out of</td>";
1357
				foreach ($tcpflags as $tcpflag) {
1358
					$header .= "<td  width='40' class='nowrap'><strong>" . strtoupper($tcpflag) . "</strong></td>\n";
1359
					$tcpflags1 .= "<td  width='40' class='nowrap'> <input type='checkbox' name='tcpflags1_{$tcpflag}' value='on' ";
1360
					if (array_search($tcpflag, $setflags) !== false)
1361
						$tcpflags1 .= "checked=\"checked\"";
1362
					$tcpflags1 .= " /></td>\n";
1363
					$tcpflags2 .= "<td  width='40' class='nowrap'> <input type='checkbox' name='tcpflags2_{$tcpflag}' value='on' ";
1364
					if (array_search($tcpflag, $outofflags) !== false)
1365
						$tcpflags2 .= "checked=\"checked\"";
1366
					$tcpflags2 .= " /></td>\n";
1367
				}
1368
				echo "<tr id='tcpheader'>{$header}</tr>\n";
1369
				echo "<tr id='tcpflags1'>{$tcpflags1}</tr>\n";
1370
				echo "<tr id='tcpflags2'>{$tcpflags2}</tr>\n";
1371
			?>
1372
			</table>
1373
			</div>
1374
			<br /><center>
1375
			<input onclick='tcpflags_anyclick(this);' type='checkbox' name='tcpflags_any' value='on' <?php if ($pconfig['tcpflags_any']) echo "checked=\"checked\""; ?> /><strong><?=gettext("Any flags.");?></strong><br /></center>
1376
			<br />
1377
			<span class="vexpl"><?=gettext("Use this to choose TCP flags that must ".
1378
			"be set or cleared for this rule to match.");?></span>
1379
			</div>
1380
			</td>
1381
		</tr>
1382
		<tr>
1383
			<td width="22%" valign="top" class="vncell"><?=gettext("State Type");?></td>
1384
			<td width="78%" class="vtable">
1385
				<div id="showadvstatebox" <?php if (!empty($pconfig['nopfsync']) || (!empty($pconfig['statetype']) && $pconfig['statetype'] != "keep state")) echo "style='display:none'"; ?>>
1386
					<input type="button" onclick="show_advanced_state()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1387
				</div>
1388
				<div id="showstateadv" <?php if (empty($pconfig['nopfsync']) && (empty($pconfig['statetype']) || $pconfig['statetype'] == "keep state")) echo "style='display:none'"; ?>>
1389
					<input name="nopfsync" type="checkbox" id="nopfsync" value="yes" <?php if ($pconfig['nopfsync']) echo "checked=\"checked\""; ?> />
1390
					<span class="vexpl">
1391
						NO pfsync<br />
1392
						<?=gettext("Hint: This prevents states created by this rule to be sync'ed over pfsync.");?><br />
1393
					</span><br />
1394
					<select name="statetype">
1395
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected=\"selected\""; ?>><?=gettext("keep state");?></option>
1396
						<option value="sloppy state" <?php if($pconfig['statetype'] == "sloppy state") echo "selected=\"selected\""; ?>><?=gettext("sloppy state");?></option>
1397
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected=\"selected\""; ?>><?=gettext("synproxy state");?></option>
1398
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected=\"selected\""; ?>><?=gettext("none");?></option>
1399
					</select><br />
1400
					<span class="vexpl">
1401
						<?=gettext("Hint: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.");?>
1402
					</span>
1403
					<table width="90%">
1404
						<tr><td width="25%"><ul><li><?=gettext("keep state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1405
						<tr><td width="25%"><ul><li><?=gettext("sloppy state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1406
						<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>
1407
						<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>
1408
					</table>
1409
				</div>
1410
			</td>
1411
		</tr>
1412
		<tr>
1413
			<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
1414
			<td width="78%" class="vtable">
1415
				<div id="showadvnoxmlrpcsyncbox" <?php if ($pconfig['nosync']) echo "style='display:none'"; ?>>
1416
					<input type="button" onclick="show_advanced_noxmlrpc()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1417
				</div>
1418
				<div id="shownoxmlrpcadv" <?php if (empty($pconfig['nosync'])) echo "style='display:none'"; ?>>
1419
					<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br />
1420
					<?=gettext("Hint: This prevents the rule on Master from automatically syncing to other CARP members. This does NOT prevent the rule from being overwritten on Slave.");?>
1421
				</div>
1422
			</td>
1423
		</tr>
1424
		<tr>
1425
			<td width="22%" valign="top" class="vncell"><?=gettext("802.1p");?></td>
1426
			<td width="78%" class="vtable">
1427
				<div id="showadvvlanpriobox" <?php if (!empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
1428
					<input type="button" onclick="show_advanced_vlanprio()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1429
				</div>
1430
				<div id="showvlanprioadv" <?php if (empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
1431
					<?php $vlanprio = array("none", "be", "bk", "ee", "ca", "vi", "vo", "ic", "nc"); ?>
1432
<?php
1433
					$opts = "";
1434
					foreach($vlanprio as $vprio) {
1435
						if ($vprio == $pconfig['vlanprio'])
1436
							$selected = " selected=\"selected\"";
1437
						else
1438
							$selected = "";
1439
						if ($vprio == "none")
1440
							$opts .= "<option value=\"\">{$vprio}</option>\n";
1441
						else
1442
							$opts .= "<option value=\"{$vprio}\" {$selected}>" . strtoupper($vprio) . "</option>\n";
1443
					}
1444

    
1445
					$optsset = "";
1446
					foreach($vlanprio as $vprioset) {
1447
						if ($vprioset == $pconfig['vlanprioset'])
1448
							$selected = " selected=\"selected\"";
1449
						else
1450
							$selected = "";
1451
						if ($vprioset == "none")
1452
							$optsset .= "<option value=\"\">{$vprioset}</option>\n";
1453
						else
1454
							$optsset .= "<option value=\"{$vprioset}\" {$selected}>" . strtoupper($vprioset) . "</option>\n";
1455
					}
1456
?>
1457
					<select name='vlanprio'>
1458
					<?php echo $opts; ?>
1459
					</select>
1460
					<p><?=gettext("Choose 802.1p priority to match on");?></p>
1461
					<select name='vlanprioset'>
1462
					<?php echo $optsset; ?>
1463
					</select>
1464
					<p><?=gettext("Choose 802.1p priority to apply");?></p>
1465
				</div>
1466
			</td>
1467
		</tr>
1468
		<?php
1469
			//build list of schedules
1470
			$schedules = array();
1471
			$schedules[] = "none";//leave none to leave rule enabled all the time
1472
			if(is_array($config['schedules']['schedule'])) {
1473
				foreach ($config['schedules']['schedule'] as $schedule) {
1474
					if ($schedule['name'] <> "")
1475
						$schedules[] = $schedule['name'];
1476
				}
1477
			}
1478
		?>
1479
		<tr>
1480
			<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
1481
			<td width="78%" class="vtable">
1482
				<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1483
					<input type="button" onclick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1484
				</div>
1485
				<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1486
					<select name='sched'>
1487
<?php
1488
					foreach($schedules as $schedule) {
1489
						if($schedule == $pconfig['sched']) {
1490
							$selected = " selected=\"selected\"";
1491
						} else {
1492
							$selected = "";
1493
						}
1494
						if ($schedule == "none") {
1495
							echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
1496
						} else {
1497
							echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
1498
						}
1499
					}
1500
?>
1501
					</select>
1502
					<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
1503
				</div>
1504
			</td>
1505
		</tr>
1506
		<tr>
1507
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1508
			<td width="78%" class="vtable">
1509
				<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1510
					<input type="button" onclick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1511
				</div>
1512
				<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1513
					<select name='gateway'>
1514
					<option value="" ><?=gettext("default");?></option>
1515
<?php
1516
					/* build a list of gateways */
1517
					$gateways = return_gateways_array();
1518
					// add statically configured gateways to list
1519
					foreach($gateways as $gwname => $gw) {
1520
						if(($pconfig['ipprotocol'] == "inet46"))
1521
							continue;
1522
						if(($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway']))))
1523
							continue;
1524
						if(($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway']))))
1525
							continue;
1526
						if($gw == "")
1527
							continue;
1528
						if($gwname == $pconfig['gateway']) {
1529
							$selected = " selected=\"selected\"";
1530
						} else {
1531
							$selected = "";
1532
						}
1533
						$gateway_addr_str = empty($gw['gateway']) ? "" : " - " . $gw[gateway];
1534
						echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']}{$gateway_addr_str}</option>\n";
1535
					}
1536
					/* add gateway groups to the list */
1537
					if (is_array($a_gatewaygroups)) {
1538
						foreach($a_gatewaygroups as $gwg_name => $gwg_data) {
1539
							if((empty($pconfig['ipprotocol'])) || ($pconfig['ipprotocol'] == $gwg_data['ipprotocol'])) {
1540
								if($pconfig['gateway'] == $gwg_name) {
1541
									$selected = " selected=\"selected\"";
1542
								} else {
1543
									$selected = "";
1544
								}
1545
								echo "<option value=\"{$gwg_name}\" $selected>{$gwg_name}</option>\n";
1546
							}
1547
						}
1548
					}
1549
?>
1550
					</select>
1551
					<p><?=gettext("Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.");?></p>
1552
				</div>
1553
			</td>
1554
		</tr>
1555
		<tr>
1556
			<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
1557
			<td width="78%" class="vtable">
1558
				<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1559
					<input type="button" onclick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1560
				</div>
1561
				<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1562
					<select name="dnpipe">
1563
<?php
1564
		if (!is_array($dnqlist))
1565
			$dnqlist = array();
1566
		echo "<option value=\"\"";
1567
		if (!$dnqselected) echo " selected=\"selected\"";
1568
		echo " >none</option>";
1569
		foreach ($dnqlist as $dnq => $dnqkey) {
1570
			if($dnq == "")
1571
				continue;
1572
			echo "<option value=\"$dnq\"";
1573
			if ($dnq == $pconfig['dnpipe']) {
1574
				$dnqselected = 1;
1575
				echo " selected=\"selected\"";
1576
			}
1577
			echo ">{$dnq}</option>";
1578
		}
1579
?>
1580
			</select> /
1581
			<select name="pdnpipe">
1582
<?php
1583
		$dnqselected = 0;
1584
		echo "<option value=\"\"";
1585
		if (!$dnqselected) echo " selected=\"selected\"";
1586
		echo " >none</option>";
1587
		foreach ($dnqlist as $dnq => $dnqkey) {
1588
			if($dnq == "")
1589
				continue;
1590
			echo "<option value=\"$dnq\"";
1591
			if ($dnq == $pconfig['pdnpipe']) {
1592
				$dnqselected = 1;
1593
				echo " selected=\"selected\"";
1594
			}
1595
			echo ">{$dnq}</option>";
1596
		}
1597
?>
1598
				</select>
1599
				<br />
1600
				<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>
1601
				</div>
1602
			</td>
1603
		</tr>
1604

    
1605
		<tr>
1606
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1607
			<td width="78%" class="vtable">
1608
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1609
				<input type="button" onclick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1610
			</div>
1611
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1612
				<select name="ackqueue">
1613
<?php
1614
			if (!is_array($qlist))
1615
				$qlist = array();
1616
			echo "<option value=\"\"";
1617
			if (!$qselected) echo " selected=\"selected\"";
1618
			echo " >none</option>";
1619
			foreach ($qlist as $q => $qkey) {
1620
				if($q == "")
1621
					continue;
1622
				echo "<option value=\"$q\"";
1623
				if ($q == $pconfig['ackqueue']) {
1624
					$qselected = 1;
1625
					echo " selected=\"selected\"";
1626
				}
1627
				if (isset($ifdisp[$q]))
1628
					echo ">{$ifdisp[$q]}</option>";
1629
				else
1630
					echo ">{$q}</option>";
1631
			}
1632
?>
1633
				</select> /
1634
				<select name="defaultqueue">
1635
<?php
1636
			$qselected = 0;
1637
			echo "<option value=\"\"";
1638
			if (!$qselected) echo " selected=\"selected\"";
1639
			echo " >none</option>";
1640
			foreach ($qlist as $q => $qkey) {
1641
				if($q == "")
1642
					continue;
1643
				echo "<option value=\"$q\"";
1644
				if ($q == $pconfig['defaultqueue']) {
1645
					$qselected = 1;
1646
					echo " selected=\"selected\"";
1647
				}
1648
				if (isset($ifdisp[$q]))
1649
					echo ">{$ifdisp[$q]}</option>";
1650
				else
1651
					echo ">{$q}</option>";
1652
			}
1653
?>
1654
				</select>
1655
					<br />
1656
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1657
					</div>
1658
				</td>
1659
			</tr>
1660
			<tr>
1661
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1662
				<td width="78%" class="vtable">
1663
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1664
						<input type="button" onclick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1665
					</div>
1666
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1667
						<select name="l7container">
1668
<?php
1669
						if (!is_array($l7clist))
1670
							$l7clist = array();
1671
						echo "<option value=\"\"";
1672
						echo " >none</option>";
1673
						foreach ($l7clist as $l7ckey) {
1674
							echo "<option value=\"{$l7ckey}\"";
1675
							if ($l7ckey == $pconfig['l7container']) {
1676
								echo " selected=\"selected\"";
1677
							}
1678
							echo ">{$l7ckey}</option>";
1679
						}
1680
?>
1681
						</select>
1682
						<br />
1683
						<span class="vexpl">
1684
							<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1685
							"These are valid for TCP and UDP protocols only.");?>
1686
						</span>
1687
					</div>
1688
				</td>
1689
			</tr>
1690
<?php
1691
		// Allow extending of the firewall edit page and include custom input validation
1692
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphplate");
1693
?>
1694
<?php
1695
$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
1696
$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
1697
?>
1698
		<?php if ($has_created_time || $has_updated_time): ?>
1699
		<tr>
1700
			<td>&nbsp;</td>
1701
		</tr>
1702
		<tr>
1703
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
1704
		</tr>
1705
		<?php if ($has_created_time): ?>
1706
		<tr>
1707
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
1708
			<td width="78%" class="vtable">
1709
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['created']['username'] ?></strong>
1710
			</td>
1711
		</tr>
1712
		<?php endif; ?>
1713
		<?php if ($has_updated_time): ?>
1714
		<tr>
1715
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
1716
			<td width="78%" class="vtable">
1717
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['updated']['username'] ?></strong>
1718
			</td>
1719
		</tr>
1720
		<?php endif; ?>
1721
		<?php endif; ?>
1722
		<tr>
1723
			<td width="22%" valign="top">&nbsp;</td>
1724
			<td width="78%">
1725
				&nbsp;<br />&nbsp;
1726
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1727
<?php			if (isset($id) && $a_filter[$id]): ?>
1728
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1729
					<input name="tracker" type="hidden" value="<?=htmlspecialchars($pconfig['tracker']);?>">
1730
<?php 			endif; ?>
1731
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1732
			</td>
1733
		</tr>
1734
	</table>
1735
</form>
1736
<script type="text/javascript">
1737
//<![CDATA[
1738
	ext_change();
1739
	typesel_change();
1740
	proto_change();
1741
	<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
1742
	show_source_port_range();
1743
	<?php endif; ?>
1744

    
1745
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1746
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
1747

    
1748
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1749
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1750
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1751
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1752
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1753
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1754
//]]>
1755
</script>
1756
<?php include("fend.inc"); ?>
1757
</body>
1758
</html>
(70-70/254)