Project

General

Profile

Download (78.4 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_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
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
72
$ifdisp = get_configured_interface_with_descr();
73
foreach ($ifdisp as $kif => $kdescr) {
74
	$specialsrcdst[] = "{$kif}";
75
	$specialsrcdst[] = "{$kif}ip";
76
}
77

    
78
if (!is_array($config['filter']['rule'])) {
79
	$config['filter']['rule'] = array();
80
}
81
filter_rules_sort();
82
$a_filter = &$config['filter']['rule'];
83

    
84
$id = $_GET['id'];
85
if (is_numeric($_POST['id']))
86
	$id = $_POST['id'];
87

    
88
$after = $_GET['after'];
89

    
90
if (isset($_POST['after']))
91
	$after = $_POST['after'];
92

    
93
if (isset($_GET['dup'])) {
94
	$id = $_GET['dup'];
95
	$after = $_GET['dup'];
96
}
97

    
98
if (isset($id) && $a_filter[$id]) {
99
	$pconfig['interface'] = $a_filter[$id]['interface'];
100

    
101
	if (isset($a_filter[$id]['id']))
102
		$pconfig['ruleid'] = $a_filter[$id]['id'];
103

    
104
	if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
105
		$pconfig['created'] = $a_filter[$id]['created'];
106

    
107
	if ( isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']) )
108
		$pconfig['updated'] = $a_filter[$id]['updated'];
109

    
110
	if (!isset($a_filter[$id]['type']))
111
		$pconfig['type'] = "pass";
112
	else
113
		$pconfig['type'] = $a_filter[$id]['type'];
114

    
115
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
116
		$pconfig['floating'] = $a_filter[$id]['floating'];
117
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "")
118
			$pconfig['interface'] = $a_filter[$id]['interface'];
119
	}
120

    
121
	if (isset($a_filter['floating']))
122
		$pconfig['floating'] = "yes";
123

    
124
	if (isset($a_filter[$id]['direction']))
125
		$pconfig['direction'] = $a_filter[$id]['direction'];
126

    
127
	if (isset($a_filter[$id]['ipprotocol']))
128
		$pconfig['ipprotocol'] = $a_filter[$id]['ipprotocol'];
129

    
130
	if (isset($a_filter[$id]['protocol']))
131
		$pconfig['proto'] = $a_filter[$id]['protocol'];
132
	else
133
		$pconfig['proto'] = "any";
134

    
135
	if ($a_filter[$id]['protocol'] == "icmp")
136
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
137

    
138
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
139
		$pconfig['srcmask'], $pconfig['srcnot'],
140
		$pconfig['srcbeginport'], $pconfig['srcendport']);
141

    
142
	if($a_filter[$id]['os'] <> "")
143
		$pconfig['os'] = $a_filter[$id]['os'];
144

    
145
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
146
		$pconfig['dstmask'], $pconfig['dstnot'],
147
		$pconfig['dstbeginport'], $pconfig['dstendport']);
148

    
149
	if ($a_filter[$id]['dscp'] <> "")
150
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
151

    
152
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
153
	$pconfig['log'] = isset($a_filter[$id]['log']);
154
	$pconfig['descr'] = $a_filter[$id]['descr'];
155

    
156
	if (isset($a_filter[$id]['tcpflags_any']))
157
		$pconfig['tcpflags_any'] = true;
158
	else {
159
		if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "")
160
			$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
161
		if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "")
162
			$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
163
	}
164

    
165
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "")
166
		$pconfig['tag'] = $a_filter[$id]['tag'];
167
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
168
		$pconfig['tagged'] = $a_filter[$id]['tagged'];
169
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
170
		$pconfig['quick'] = $a_filter[$id]['quick'];
171
	if (isset($a_filter[$id]['allowopts']))
172
		$pconfig['allowopts'] = true;
173
	if (isset($a_filter[$id]['disablereplyto']))
174
		$pconfig['disablereplyto'] = true;
175

    
176
	/* advanced */
177
	$pconfig['max'] = $a_filter[$id]['max'];
178
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
179
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
180
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
181
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
182
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
183

    
184
	/* advanced - nosync */
185
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
186

    
187
	/* advanced - new connection per second banning*/
188
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
189
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
190

    
191
	/* Multi-WAN next-hop support */
192
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
193

    
194
	/* Shaper support */
195
	$pconfig['defaultqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['defaultqueue']);
196
	$pconfig['ackqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['ackqueue']);
197
	$pconfig['dnpipe'] = (($a_filter[$id]['dnpipe'] == "none") ? '' : $a_filter[$id]['dnpipe']);
198
	$pconfig['pdnpipe'] = (($a_filter[$id]['pdnpipe'] == "none") ? '' : $a_filter[$id]['pdnpipe']);
199
	$pconfig['l7container'] = (($a_filter[$id]['l7container'] == "none") ? '' : $a_filter[$id]['l7container']);
200

    
201
	//schedule support
202
	$pconfig['sched'] = (($a_filter[$id]['sched'] == "none") ? '' : $a_filter[$id]['sched']);
203
	$pconfig['vlanprio'] = (($a_filter[$id]['vlanprio'] == "none") ? '' : $a_filter[$id]['vlanprio']);
204
	$pconfig['vlanprioset'] = (($a_filter[$id]['vlanprioset'] == "none") ? '' : $a_filter[$id]['vlanprioset']);
205
	if (!isset($_GET['dup']))
206
		$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
207

    
208
} else {
209
	/* defaults */
210
	if ($_GET['if'])
211
		$pconfig['interface'] = $_GET['if'];
212
	$pconfig['type'] = "pass";
213
	$pconfig['src'] = "any";
214
	$pconfig['dst'] = "any";
215
}
216
/* Allow the FloatingRules to work */
217
$if = $pconfig['interface'];
218

    
219
if (isset($_GET['dup']))
220
	unset($id);
221

    
222
read_altq_config(); /* XXX: */
223
$qlist =& get_unique_queue_list();
224
read_dummynet_config(); /* XXX: */
225
$dnqlist =& get_unique_dnqueue_list();
226
read_layer7_config();
227
$l7clist =& get_l7_unique_list();
228
$a_gatewaygroups = return_gateway_groups_array();
229

    
230
if ($_POST) {
231
	unset($input_errors);
232

    
233
	if( isset($a_filter[$id]['associated-rule-id']) ) {
234
		$_POST['proto'] = $pconfig['proto'];
235
		if ($pconfig['proto'] == "icmp")
236
			$_POST['icmptype'] = $pconfig['icmptype'];
237
	}
238

    
239
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
240
		if(is_array($config['gateways']['gateway_group'])) {
241
			foreach($config['gateways']['gateway_group'] as $gw_group) {
242
				if($gw_group['name'] == $_POST['gateway']) {
243
					$family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol'];
244
					if($_POST['ipprotocol'] == $family) {
245
						continue;
246
					}
247
					if(($_POST['ipprotocol'] == "inet46") && ($_POST['ipprotocol'] != $family)) {
248
						$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
249
					}
250
					if(($_POST['ipprotocol'] == "inet6") && ($_POST['ipprotocol'] != $family)) {
251
						$input_errors[] = gettext("You can not assign a IPv4 gateway group on IPv6 Address Family rule");
252
					}
253
					if(($_POST['ipprotocol'] == "inet") && ($_POST['ipprotocol'] != $family)) {
254
						$input_errors[] = gettext("You can not assign a IPv6 gateway group on IPv4 Address Family rule");
255
					}
256
				}
257
			}
258
		}
259
	}
260
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "") && (is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway'])))) {
261
		if(($_POST['ipprotocol'] == "inet46") && ($_POST['gateway'] <> "")) {
262
			$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
263
		}
264
		if(($_POST['ipprotocol'] == "inet6") && (!is_ipaddrv6(lookup_gateway_ip_by_name($_POST['gateway'])))) {
265
			$input_errors[] = gettext("You can not assign the IPv4 Gateway to a IPv6 Filter rule");
266
		}
267
		if(($_POST['ipprotocol'] == "inet") && (!is_ipaddrv4(lookup_gateway_ip_by_name($_POST['gateway'])))) {
268
			$input_errors[] = gettext("You can not assign the IPv6 Gateway to a IPv4 Filter rule");
269
		}
270
	}
271

    
272
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp") && ($_POST['proto'] != "icmp")) {
273
		if($_POST['ipprotocol'] == "inet46")
274
			$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");
275
	}
276
	if (($_POST['proto'] == "icmp") && ($_POST['icmptype'] <> "")){
277
		if($_POST['ipprotocol'] == "inet46")
278
			$input_errors[] =  gettext("You can not assign a ICMP type to a rule that applies to IPv4 and IPv6");
279
	}
280

    
281
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
282
		$_POST['srcbeginport'] = 0;
283
		$_POST['srcendport'] = 0;
284
		$_POST['dstbeginport'] = 0;
285
		$_POST['dstendport'] = 0;
286
	} else {
287
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
288
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
289
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
290
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
291
		if ($_POST['srcbeginport'] == "any") {
292
			$_POST['srcbeginport'] = 0;
293
			$_POST['srcendport'] = 0;
294
		} else {
295
			if (!$_POST['srcendport'])
296
				$_POST['srcendport'] = $_POST['srcbeginport'];
297
		}
298
		if ($_POST['srcendport'] == "any")
299
			$_POST['srcendport'] = $_POST['srcbeginport'];
300

    
301
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
302
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
303
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
304
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
305

    
306
		if ($_POST['dstbeginport'] == "any") {
307
			$_POST['dstbeginport'] = 0;
308
			$_POST['dstendport'] = 0;
309
		} else {
310
			if (!$_POST['dstendport'])
311
				$_POST['dstendport'] = $_POST['dstbeginport'];
312
		}
313
		if ($_POST['dstendport'] == "any")
314
			$_POST['dstendport'] = $_POST['dstbeginport'];
315
	}
316

    
317
	if (is_specialnet($_POST['srctype'])) {
318
		$_POST['src'] = $_POST['srctype'];
319
		$_POST['srcmask'] = 0;
320
	} else if ($_POST['srctype'] == "single") {
321
		if (is_ipaddrv6($_POST['src']))
322
			$_POST['srcmask'] = 128;
323
		else
324
			$_POST['srcmask'] = 32;
325
	}
326
	if (is_specialnet($_POST['dsttype'])) {
327
		$_POST['dst'] = $_POST['dsttype'];
328
		$_POST['dstmask'] = 0;
329
	}  else if ($_POST['dsttype'] == "single") {
330
		if (is_ipaddrv6($_POST['dst']))
331
			$_POST['dstmask'] = 128;
332
		else
333
			$_POST['dstmask'] = 32;
334
	}
335

    
336
	$pconfig = $_POST;
337

    
338
	/* input validation */
339
	$reqdfields = explode(" ", "type proto");
340
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
341
		$reqdfields[] = "src";
342
		$reqdfields[] = "dst";
343
	}
344
	$reqdfieldsn = explode(",", "Type,Protocol");
345
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
346
		$reqdfieldsn[] = "Source";
347
		$reqdfieldsn[] = "Destination";
348
	}
349

    
350
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
351
		if( $_POST['proto'] != "tcp" )
352
			$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
353
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
354
			$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
355
	}
356

    
357
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
358
	(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
359
		$reqdfields[] = "srcmask";
360
		$reqdfieldsn[] = "Source bit count";
361
	}
362
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
363
	(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
364
		$reqdfields[] = "dstmask";
365
		$reqdfieldsn[] = gettext("Destination bit count");
366
	}
367

    
368
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
369

    
370
	if (!$_POST['srcbeginport']) {
371
		$_POST['srcbeginport'] = 0;
372
		$_POST['srcendport'] = 0;
373
	}
374
	if (!$_POST['dstbeginport']) {
375
		$_POST['dstbeginport'] = 0;
376
		$_POST['dstendport'] = 0;
377
	}
378

    
379
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
380
		$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']);
381
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
382
			$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']);
383
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
384
			$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']);
385
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
386
			$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']);
387
	if ( !$_POST['srcbeginport_cust'] && $_POST['srcendport_cust'])
388
		if (is_alias($_POST['srcendport_cust']))
389
			$input_errors[] = 'If you put port alias in Source port range to: field you must put the same port alias in from: field';
390
	if ( $_POST['srcbeginport_cust'] && $_POST['srcendport_cust']){
391
		if (is_alias($_POST['srcendport_cust']) && is_alias($_POST['srcendport_cust']) && $_POST['srcbeginport_cust'] != $_POST['srcendport_cust'])
392
			$input_errors[] = 'The same port alias must be used in Source port range from: and to: fields';
393
		if ((is_alias($_POST['srcbeginport_cust']) && (!is_alias($_POST['srcendport_cust']) && $_POST['srcendport_cust']!='')) ||
394
		    ((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust']!='') && is_alias($_POST['srcendport_cust'])))
395
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Source port range from: and to: field';
396
	}
397
	if ( !$_POST['dstbeginport_cust'] && $_POST['dstendport_cust'])
398
		if (is_alias($_POST['dstendport_cust']))
399
			$input_errors[] = 'If you put port alias in Destination port range to: field you must put the same port alias in from: field';
400
	if ( $_POST['dstbeginport_cust'] && $_POST['dstendport_cust']){
401
		if (is_alias($_POST['dstendport_cust']) && is_alias($_POST['dstendport_cust']) && $_POST['dstbeginport_cust'] != $_POST['dstendport_cust'])
402
			$input_errors[] = 'The same port alias must be used in Destination port range from: and to: fields';
403
		if ((is_alias($_POST['dstbeginport_cust']) && (!is_alias($_POST['dstendport_cust']) && $_POST['dstendport_cust']!='')) ||
404
		    ((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust']!='') && is_alias($_POST['dstendport_cust'])))
405
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field';
406
	}
407

    
408
	if ($_POST['src'])
409
		$_POST['src'] = trim($_POST['src']);
410
	if ($_POST['dst'])
411
		$_POST['dst'] = trim($_POST['dst']);
412

    
413
	/* if user enters an alias and selects "network" then disallow. */
414
	if($_POST['srctype'] == "network") {
415
		if(is_alias($_POST['src']))
416
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
417
	}
418
	if($_POST['dsttype'] == "network") {
419
		if(is_alias($_POST['dst']))
420
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
421
	}
422

    
423
	if (!is_specialnet($_POST['srctype'])) {
424
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
425
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
426
		}
427
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
428
			$input_errors[] = gettext("A valid source bit count must be specified.");
429
		}
430
	}
431
	if (!is_specialnet($_POST['dsttype'])) {
432
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
433
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
434
		}
435
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
436
			$input_errors[] = gettext("A valid destination bit count must be specified.");
437
		}
438
	}
439
	if((is_ipaddr($_POST['src']) && is_ipaddr($_POST['dst']))) {
440
		if(!validate_address_family($_POST['src'], $_POST['dst']))
441
			$input_errors[] = sprintf(gettext("The Source IP address %s Address Family differs from the destination %s."), $_POST['src'], $_POST['dst']);
442
		if((is_ipaddrv6($_POST['src']) || is_ipaddrv6($_POST['dst'])) && ($_POST['ipprotocol'] == "inet"))
443
			$input_errors[] = gettext("You can not use IPv6 addresses in IPv4 rules.");
444
		if((is_ipaddrv4($_POST['src']) || is_ipaddrv4($_POST['dst'])) && ($_POST['ipprotocol'] == "inet6"))
445
			$input_errors[] = gettext("You can not use IPv4 addresses in IPv6 rules.");
446
	}
447

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

    
451
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
452
		/* swap */
453
		$tmp = $_POST['srcendport'];
454
		$_POST['srcendport'] = $_POST['srcbeginport'];
455
		$_POST['srcbeginport'] = $tmp;
456
	}
457
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
458
		/* swap */
459
		$tmp = $_POST['dstendport'];
460
		$_POST['dstendport'] = $_POST['dstbeginport'];
461
		$_POST['dstbeginport'] = $tmp;
462
	}
463
	if ($_POST['os'])
464
		if( $_POST['proto'] != "tcp" )
465
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
466

    
467
	if ($_POST['ackqueue'] != "") {
468
		if ($_POST['defaultqueue'] == "" )
469
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
470
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
471
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
472
	}
473
	if (isset($_POST['floating']) && $_POST['pdnpipe'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
474
		$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
475
	if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
476
		$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
477
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "") {
478
		if ($_POST['dnpipe'] == "" )
479
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
480
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
481
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
482
		else if ($dnqlist[$_POST['pdnpipe']][0] == "?" && $dnqlist[$_POST['dnpipe']][0] <> "?")
483
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
484
		else if ($dnqlist[$_POST['dnpipe']][0] == "?" && $dnqlist[$_POST['pdnpipe']][0] <> "?")
485
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
486
		if ($_POST['direction'] == "out" && empty($_POST['gateway']))
487
			$input_errors[] = gettext("Please select a gateway, normaly the interface selected gateway, so the limiters work correctly");
488
	}
489
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
490
		$input_errors[] = gettext('ID must be an integer');
491
	if($_POST['l7container'] && $_POST['l7container'] != "") {
492
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
493
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
494
		if ($_POST['type'] <> "pass")
495
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
496
	}
497

    
498
	if (!in_array($_POST['proto'], array("tcp","tcp/udp"))) {
499
		if (!empty($_POST['max-src-conn']))
500
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
501
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
502
			$input_errors[] = gettext("You can only specify the maximum new connections / per second(s) (advanced option) for TCP protocol.");
503
		if (!empty($_POST['statetimeout']))
504
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
505
	}
506

    
507
	if ($_POST['type'] <> "pass") {
508
		if (!empty($_POST['max']))
509
			$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for Pass type rules.");
510
		if (!empty($_POST['max-src-nodes']))
511
			$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for Pass type rules.");
512
		if (!empty($_POST['max-src-conn']))
513
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for Pass type rules.");
514
		if (!empty($_POST['max-src-states']))
515
			$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for Pass type rules.");
516
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
517
			$input_errors[] = gettext("You can only specify the maximum new connections / per second(s) (advanced option) for Pass type rules.");
518
		if (!empty($_POST['statetimeout']))
519
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for Pass type rules.");
520
	}
521

    
522
	if (($_POST['statetype'] == "none") && (empty($_POST['l7container']))) {
523
		if (!empty($_POST['max']))
524
			$input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected.");
525
		if (!empty($_POST['max-src-nodes']))
526
			$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.");
527
		if (!empty($_POST['max-src-conn']))
528
			$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.");
529
		if (!empty($_POST['max-src-states']))
530
			$input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected.");
531
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
532
			$input_errors[] = gettext("You cannot specify the maximum new connections / per second(s) (advanced option) if statetype is none and no L7 container is selected.");
533
		if (!empty($_POST['statetimeout']))
534
			$input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected.");
535
	}
536

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

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

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

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

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

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

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

    
559
	if (!$_POST['tcpflags_any']) {
560
		$settcpflags = array();
561
		$outoftcpflags = array();
562
		foreach ($tcpflags as $tcpflag) {
563
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
564
				$settcpflags[] = $tcpflag;
565
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
566
				$outoftcpflags[] = $tcpflag;
567
		}
568
		if (empty($outoftcpflags) && !empty($settcpflags))
569
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
570
	}
571

    
572
	// Allow extending of the firewall edit page and include custom input validation
573
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
574

    
575
	if (!$input_errors) {
576
		$filterent = array();
577
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
578
		$filterent['type'] = $_POST['type'];
579
		if (isset($_POST['interface'] ))
580
			$filterent['interface'] = $_POST['interface'];
581

    
582
		if (isset($_POST['ipprotocol'] ))
583
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
584

    
585
		if ($_POST['tcpflags_any']) {
586
			$filterent['tcpflags_any'] = true;
587
		} else {
588
			$settcpflags = array();
589
			$outoftcpflags = array();
590
			foreach ($tcpflags as $tcpflag) {
591
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
592
					$settcpflags[] = $tcpflag;
593
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
594
					$outoftcpflags[] = $tcpflag;
595
			}
596
			if (!empty($outoftcpflags)) {
597
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
598
				if (!empty($settcpflags))
599
					$filterent['tcpflags1'] = join(",", $settcpflags);
600
			}
601
		}
602

    
603
		if (isset($_POST['tag']))
604
			$filterent['tag'] = $_POST['tag'];
605
		if (isset($_POST['tagged']))
606
			$filterent['tagged'] = $_POST['tagged'];
607
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
608
			$filterent['direction'] = $_POST['direction'];
609
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
610
				$filterent['quick'] = $_POST['quick'];
611
			$filterent['floating'] = "yes";
612
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
613
				$filterent['interface'] = implode(",", $_POST['interface']);
614
			}
615
		}
616

    
617
		/* Advanced options */
618
		if ($_POST['allowopts'] == "yes")
619
			$filterent['allowopts'] = true;
620
		else
621
			unset($filterent['allowopts']);
622
		if ($_POST['disablereplyto'] == "yes")
623
			$filterent['disablereplyto'] = true;
624
		else
625
			unset($filterent['disablereplyto']);
626
		$filterent['max'] = $_POST['max'];
627
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
628
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
629
		$filterent['max-src-states'] = $_POST['max-src-states'];
630
		$filterent['statetimeout'] = $_POST['statetimeout'];
631
		$filterent['statetype'] = $_POST['statetype'];
632
		$filterent['os'] = $_POST['os'];
633

    
634
		/* Nosync directive - do not xmlrpc sync this item */
635
		if($_POST['nosync'] <> "")
636
			$filterent['nosync'] = true;
637
		else
638
			unset($filterent['nosync']);
639

    
640
		/* unless both values are provided, unset the values - ticket #650 */
641
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
642
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
643
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
644
		} else {
645
			unset($filterent['max-src-conn-rate']);
646
			unset($filterent['max-src-conn-rates']);
647
		}
648

    
649
		if ($_POST['proto'] != "any")
650
			$filterent['protocol'] = $_POST['proto'];
651
		else
652
			unset($filterent['protocol']);
653

    
654
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
655
			$filterent['icmptype'] = $_POST['icmptype'];
656
		else
657
			unset($filterent['icmptype']);
658

    
659
		pconfig_to_address($filterent['source'], $_POST['src'],
660
			$_POST['srcmask'], $_POST['srcnot'],
661
			$_POST['srcbeginport'], $_POST['srcendport']);
662

    
663
		pconfig_to_address($filterent['destination'], $_POST['dst'],
664
			$_POST['dstmask'], $_POST['dstnot'],
665
			$_POST['dstbeginport'], $_POST['dstendport']);
666

    
667
		if ($_POST['disabled'])
668
			$filterent['disabled'] = true;
669
		else
670
			unset($filterent['disabled']);
671

    
672
		if ($_POST['dscp'])
673
			$filterent['dscp'] = $_POST['dscp'];
674

    
675
		if ($_POST['log'])
676
			$filterent['log'] = true;
677
		else
678
			unset($filterent['log']);
679
		strncpy($filterent['descr'], $_POST['descr'], 52);
680

    
681
		if ($_POST['gateway'] != "") {
682
			$filterent['gateway'] = $_POST['gateway'];
683
		}
684

    
685
		if ($_POST['defaultqueue'] != "") {
686
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
687
			if ($_POST['ackqueue'] != "")
688
				$filterent['ackqueue'] = $_POST['ackqueue'];
689
		}
690

    
691
		if ($_POST['dnpipe'] != "") {
692
			$filterent['dnpipe'] = $_POST['dnpipe'];
693
			if ($_POST['pdnpipe'] != "")
694
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
695
		}
696

    
697
		if ($_POST['l7container'] != "") {
698
			$filterent['l7container'] = $_POST['l7container'];
699
		}
700

    
701
		if ($_POST['sched'] != "") {
702
			$filterent['sched'] = $_POST['sched'];
703
		}
704

    
705
		if ($_POST['vlanprio'] != "") {
706
			$filterent['vlanprio'] = $_POST['vlanprio'];
707
		}
708
		if ($_POST['vlanprioset'] != "") {
709
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
710
		}
711

    
712
		// If we have an associated nat rule, make sure the source and destination doesn't change
713
		if( isset($a_filter[$id]['associated-rule-id']) ) {
714
			$filterent['interface'] = $a_filter[$id]['interface'];
715
			if (isset($a_filter[$id]['protocol']))
716
				$filterent['protocol'] = $a_filter[$id]['protocol'];
717
			else if (isset($filterent['protocol']))
718
				unset($filterent['protocol']);
719
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
720
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
721
			else if (isset($filterent['icmptype']))
722
				unset($filterent['icmptype']);
723

    
724
			$filterent['source'] = $a_filter[$id]['source'];
725
			$filterent['destination'] = $a_filter[$id]['destination'];
726
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
727
		}
728

    
729
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
730
			$filterent['created'] = $a_filter[$id]['created'];
731

    
732
		$filterent['updated'] = make_config_revision_entry();
733

    
734
		// Allow extending of the firewall edit page and include custom input validation
735
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
736

    
737
		if (isset($id) && $a_filter[$id])
738
			$a_filter[$id] = $filterent;
739
		else {
740
			$filterent['created'] = make_config_revision_entry();
741
			if (is_numeric($after))
742
				array_splice($a_filter, $after+1, 0, array($filterent));
743
			else
744
				$a_filter[] = $filterent;
745
		}
746

    
747
		filter_rules_sort();
748

    
749
		if (write_config())
750
			mark_subsystem_dirty('filter');
751

    
752
		if (isset($_POST['floating']))
753
			header("Location: firewall_rules.php?if=FloatingRules");
754
		else
755
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
756
		exit;
757
	}
758
}
759

    
760
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
761
$shortcut_section = "firewall";
762

    
763
$closehead = false;
764

    
765
$page_filename = "firewall_rules_edit.php";
766
include("head.inc");
767

    
768
?>
769
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
770
</head>
771

    
772
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
773
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
774
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
775
<?php include("fbegin.inc"); ?>
776
<?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_input_errors"); ?>
777
<?php if ($input_errors) print_input_errors($input_errors); ?>
778

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

    
782
	<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall rules edit">
783
		<tr>
784
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
785
		</tr>
786
<?php
787
		// Allow extending of the firewall edit page and include custom input validation
788
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
789
?>
790
		<tr>
791
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
792
			<td width="78%" class="vtable">
793
				<select name="type" class="formselect">
794
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
795
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>
796
					<?=htmlspecialchars($type);?>
797
					</option>
798
					<?php endforeach; ?>
799
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
800
					<option value="match" <?php if ("match" == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>Match</option>
801
<?php endif; ?>
802
				</select>
803
				<br/>
804
				<span class="vexpl">
805
					<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br/>
806
					<?=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.");?>
807
				</span>
808
			</td>
809
		</tr>
810
		<tr>
811
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
812
			<td width="78%" class="vtable">
813
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
814
				<strong><?=gettext("Disable this rule");?></strong><br />
815
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
816
			</td>
817
		</tr>
818
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
819
		<tr>
820
			<td width="22%" valign="top" class="vncellreq">
821
				<?=gettext("Quick");?>
822
			</td>
823
			<td width="78%" class="vtable">
824
				<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
825
				<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
826
				<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
827
			</td>
828
		</tr>
829
<?php endif; ?>
830
<?php $edit_disabled = ""; ?>
831
<?php if( isset($pconfig['associated-rule-id']) ): ?>
832
		<tr>
833
			<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
834
			<td width="78%" class="vtable">
835
				<span class="red"><strong><?=gettext("Note: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
836
				<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
837
				<br />
838
				<?php
839
					$edit_disabled = "disabled=\"disabled\"";
840
					if (is_array($config['nat']['rule'])) {
841
						foreach( $config['nat']['rule'] as $index => $nat_rule ) {
842
							if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
843
								echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br/>";
844
								break;
845
							}
846
						}
847
					}
848
					echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' />";
849
					if (!empty($pconfig['interface']))
850
						echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' />";
851
				?>
852
				<script type="text/javascript">
853
				editenabled = 0;
854
				</script>
855
			</td>
856
		</tr>
857
<?php endif; ?>
858
		<tr>
859
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
860
			<td width="78%" class="vtable">
861
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
862
				<select name="interface[]" title="Select interfaces..." multiple="multiple" style="width:350px;" class="chzn-select" tabindex="2" <?=$edit_disabled;?>>
863
<?php else: ?>
864
				<select name="interface" class="formselect" <?=$edit_disabled;?>>
865
<?php endif;
866
				/* add group interfaces */
867
				if (is_array($config['ifgroups']['ifgroupentry']))
868
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
869
						if (have_ruleint_access($ifgen['ifname']))
870
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
871
				$ifdescs = get_configured_interface_with_descr();
872
				// Allow extending of the firewall edit page and include custom input validation
873
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
874
				foreach ($ifdescs as $ifent => $ifdesc)
875
					if(have_ruleint_access($ifent))
876
							$interfaces[$ifent] = $ifdesc;
877
					if ($config['l2tp']['mode'] == "server")
878
						if(have_ruleint_access("l2tp"))
879
							$interfaces['l2tp'] = "L2TP VPN";
880
					if ($config['pptpd']['mode'] == "server")
881
						if(have_ruleint_access("pptp"))
882
							$interfaces['pptp'] = "PPTP VPN";
883

    
884
					if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
885
						$interfaces['pppoe'] = "PPPoE VPN";
886
					/* add ipsec interfaces */
887
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
888
						if(have_ruleint_access("enc0"))
889
							$interfaces["enc0"] = "IPsec";
890
					/* add openvpn/tun interfaces */
891
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
892
						$interfaces["openvpn"] = "OpenVPN";
893
					if (is_array($pconfig['interface']))
894
						$pconfig['interface'] = implode(",", $pconfig['interface']);
895
					$selected_interfaces = explode(",", $pconfig['interface']);
896
					foreach ($interfaces as $iface => $ifacename): ?>
897
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected=\"selected\""; ?>><?=$ifacename?></option>
898
<?php 				endforeach; ?>
899
				</select>
900
				<br />
901
				<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
902
			</td>
903
		</tr>
904
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
905
		<tr>
906
			<td width="22%" valign="top" class="vncellreq">
907
				<?=gettext("Direction");?>
908
			</td>
909
			<td width="78%" class="vtable">
910
				<select name="direction" class="formselect">
911
					<?php      $directions = array('any','in','out');
912
				foreach ($directions as $direction): ?>
913
				<option value="<?=$direction;?>"
914
					<?php if ($direction == $pconfig['direction']): ?>
915
						selected="selected"
916
					<?php endif; ?>
917
					><?=$direction;?></option>
918
				<?php endforeach; ?>
919
				</select>
920
				<input type="hidden" id="floating" name="floating" value="floating" />
921
			</td>
922
		</tr>
923
<?php endif; ?>
924
		<tr>
925
			<td width="22%" valign="top" class="vncellreq"><?=gettext("TCP/IP Version");?></td>
926
			<td width="78%" class="vtable">
927
				<select name="ipprotocol" class="formselect">
928
					<?php      $ipproto = array('inet' => 'IPv4','inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6' );
929
				foreach ($ipproto as $proto => $name): ?>
930
				<option value="<?=$proto;?>"
931
					<?php if ($proto == $pconfig['ipprotocol']): ?>
932
						selected="selected"
933
					<?php endif; ?>
934
					><?=$name;?></option>
935
				<?php endforeach; ?>
936
				</select>
937
				<strong><?=gettext("Select the Internet Protocol version this rule applies to");?></strong><br />
938
			</td>
939
		</tr>
940
		<tr>
941
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
942
			<td width="78%" class="vtable">
943
				<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
944
<?php
945
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP OSPF any carp pfsync");
946
				foreach ($protocols as $proto): ?>
947
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
948
<?php 			endforeach; ?>
949
				</select>
950
				<br />
951
				<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>
952
			</td>
953
		</tr>
954
		<tr id="icmpbox">
955
			<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
956
			<td class="vtable">
957
				<select <?=$edit_disabled;?> name="icmptype" class="formselect">
958
<?php
959
				$icmptypes = array(
960
				"" => gettext("any"),
961
				"echoreq" => gettext("Echo request"),
962
				"echorep" => gettext("Echo reply"),
963
				"unreach" => gettext("Destination unreachable"),
964
				"squench" => gettext("Source quench"),
965
				"redir" => gettext("Redirect"),
966
				"althost" => gettext("Alternate Host"),
967
				"routeradv" => gettext("Router advertisement"),
968
				"routersol" => gettext("Router solicitation"),
969
				"timex" => gettext("Time exceeded"),
970
				"paramprob" => gettext("Invalid IP header"),
971
				"timereq" => gettext("Timestamp"),
972
				"timerep" => gettext("Timestamp reply"),
973
				"inforeq" => gettext("Information request"),
974
				"inforep" => gettext("Information reply"),
975
				"maskreq" => gettext("Address mask request"),
976
				"maskrep" => gettext("Address mask reply")
977
				);
978

    
979
				foreach ($icmptypes as $icmptype => $descr): ?>
980
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
981
<?php 			endforeach; ?>
982
			</select>
983
			<br />
984
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
985
		</td>
986
		</tr>
987
		<tr>
988
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
989
			<td width="78%" class="vtable">
990
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
991
				<strong><?=gettext("not");?></strong>
992
				<br />
993
				<?=gettext("Use this option to invert the sense of the match.");?>
994
				<br />
995
				<br />
996
				<table border="0" cellspacing="0" cellpadding="0">
997
					<tr>
998
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
999
						<td>
1000
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onchange="typesel_change()">
1001
<?php
1002
								$sel = is_specialnet($pconfig['src']); ?>
1003
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1004
								<option value="single"
1005
						<?php  if (!$sel &&
1006
							    ((is_ipaddrv6($pconfig['src']) && $pconfig['srcmask'] == 128) ||
1007
							    (is_ipaddrv4($pconfig['src']) && $pconfig['srcmask'] == 32) || is_alias($pconfig['src'])))
1008
								{ echo "selected=\"selected\""; $sel = 1; }
1009
						?>
1010
								> <?=gettext("Single host or alias");?></option>
1011
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1012
								<?php if(have_ruleint_access("pptp")): ?>
1013
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1014
								<?php endif; ?>
1015
								<?php if(have_ruleint_access("pppoe")): ?>
1016
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1017
								<?php endif; ?>
1018
								<?php if(have_ruleint_access("l2tp")): ?>
1019
								<option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1020
								<?php endif; ?>
1021
<?php
1022
								foreach ($ifdisp as $ifent => $ifdesc): ?>
1023
								<?php if(have_ruleint_access($ifent)): ?>
1024
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
1025
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
1026
										<?=$ifdesc?> <?=gettext("address");?>
1027
									</option>
1028
								<?php endif; ?>
1029
<?php 							endforeach; ?>
1030
							</select>
1031
						</td>
1032
					</tr>
1033
					<tr>
1034
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
1035
						<td>
1036
							<input <?=$edit_disabled;?> style="autocomplete:off" name="src" type="text" class="formfldalias ipv4v6" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
1037
							<select <?=$edit_disabled;?> name="srcmask" class="formselect ipv4v6" id="srcmask">
1038
<?php						for ($i = 127; $i > 0; $i--): ?>
1039
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
1040
<?php 						endfor; ?>
1041
							</select>
1042
						</td>
1043
					</tr>
1044
				</table>
1045
				<div id="showadvancedboxspr">
1046
					<p>
1047
					<input <?=$edit_disabled;?> type="button" onclick="show_source_port_range()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source port range");?>
1048
					</p>
1049
				</div>
1050
			</td>
1051
		</tr>
1052
		<tr style="display:none" id="sprtable">
1053
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
1054
			<td width="78%" class="vtable">
1055
				<table border="0" cellspacing="0" cellpadding="0">
1056
					<tr>
1057
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1058
						<td>
1059
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
1060
								<option value="">(<?=gettext("other"); ?>)</option>
1061
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1062
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1063
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1064
<?php 							endforeach; ?>
1065
							</select>
1066
							<input <?=$edit_disabled;?> style="autocomplete:off" class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>" />
1067
						</td>
1068
					</tr>
1069
					<tr>
1070
						<td><?=gettext("to:");?></td>
1071
						<td>
1072
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
1073
								<option value="">(<?=gettext("other"); ?>)</option>
1074
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1075
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1076
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1077
<?php							endforeach; ?>
1078
							</select>
1079
							<input <?=$edit_disabled;?> style="autocomplete:off" class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>" />
1080
						</td>
1081
					</tr>
1082
				</table>
1083
				<br />
1084
				<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/>
1085
			</td>
1086
		</tr>
1087
		<tr>
1088
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
1089
			<td width="78%" class="vtable">
1090
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
1091
				<strong><?=gettext("not");?></strong>
1092
					<br />
1093
				<?=gettext("Use this option to invert the sense of the match.");?>
1094
					<br />
1095
					<br />
1096
				<table border="0" cellspacing="0" cellpadding="0">
1097
					<tr>
1098
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
1099
						<td>
1100
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onchange="typesel_change()">
1101
<?php
1102
								$sel = is_specialnet($pconfig['dst']); ?>
1103
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1104
								<option value="single"
1105
								<?php  if (!$sel &&
1106
									    ((is_ipaddrv6($pconfig['dst']) && $pconfig['dstmask'] == 128) ||
1107
									    (is_ipaddrv4($pconfig['dst']) && $pconfig['dstmask'] == 32) || is_alias($pconfig['dst'])))
1108
										{ echo "selected=\"selected\""; $sel = 1; }
1109
								?>
1110
								><?=gettext("Single host or alias");?></option>
1111
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1112
								<?php if(have_ruleint_access("pptp")): ?>
1113
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1114
								<?php endif; ?>
1115
								<?php if(have_ruleint_access("pppoe")): ?>
1116
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1117
								<?php endif; ?>
1118
								<?php if(have_ruleint_access("l2tp")): ?>
1119
								<option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1120
								<?php endif; ?>
1121

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

    
1410
					$optsset = "";
1411
					foreach($vlanprio as $vprioset) {
1412
						if ($vprioset == $pconfig['vlanprioset'])
1413
							$selected = " selected=\"selected\"";
1414
						else
1415
							$selected = "";
1416
						if ($vprioset == "none")
1417
							$optsset .= "<option value=\"\">{$vprioset}</option>\n";
1418
						else
1419
							$optsset .= "<option value=\"{$vprioset}\" {$selected}>" . strtoupper($vprioset) . "</option>\n";
1420
					}
1421
?>
1422
					<select name='vlanprio'>
1423
					<?php echo $opts; ?>
1424
					</select>
1425
					<p><?=gettext("Choose 802.1p priority to match on");?></p>
1426
					<select name='vlanprioset'>
1427
					<?php echo $optsset; ?>
1428
					</select>
1429
					<p><?=gettext("Choose 802.1p priority to apply");?></p>
1430
				</div>
1431
			</td>
1432
		</tr>
1433
		<?php
1434
			//build list of schedules
1435
			$schedules = array();
1436
			$schedules[] = "none";//leave none to leave rule enabled all the time
1437
			if(is_array($config['schedules']['schedule'])) {
1438
				foreach ($config['schedules']['schedule'] as $schedule) {
1439
					if ($schedule['name'] <> "")
1440
						$schedules[] = $schedule['name'];
1441
				}
1442
			}
1443
		?>
1444
		<tr>
1445
			<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
1446
			<td width="78%" class="vtable">
1447
				<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1448
					<input type="button" onclick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1449
				</div>
1450
				<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1451
					<select name='sched'>
1452
<?php
1453
					foreach($schedules as $schedule) {
1454
						if($schedule == $pconfig['sched']) {
1455
							$selected = " selected=\"selected\"";
1456
						} else {
1457
							$selected = "";
1458
						}
1459
						if ($schedule == "none") {
1460
							echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
1461
						} else {
1462
							echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
1463
						}
1464
					}
1465
?>
1466
					</select>
1467
					<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
1468
				</div>
1469
			</td>
1470
		</tr>
1471
		<tr>
1472
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1473
			<td width="78%" class="vtable">
1474
				<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1475
					<input type="button" onclick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1476
				</div>
1477
				<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1478
					<select name='gateway'>
1479
					<option value="" ><?=gettext("default");?></option>
1480
<?php
1481
					/* build a list of gateways */
1482
					$gateways = return_gateways_array();
1483
					// add statically configured gateways to list
1484
					foreach($gateways as $gwname => $gw) {
1485
						if(($pconfig['ipprotocol'] == "inet46"))
1486
							continue;
1487
						if(($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway']))))
1488
							continue;
1489
						if(($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway']))))
1490
							continue;
1491
						if($gw == "")
1492
							continue;
1493
						if($gwname == $pconfig['gateway']) {
1494
							$selected = " selected=\"selected\"";
1495
						} else {
1496
							$selected = "";
1497
						}
1498
						$gateway_addr_str = empty($gw['gateway']) ? "" : " - " . $gw[gateway];
1499
						echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']}{$gateway_addr_str}</option>\n";
1500
					}
1501
					/* add gateway groups to the list */
1502
					if (is_array($a_gatewaygroups)) {
1503
						foreach($a_gatewaygroups as $gwg_name => $gwg_data) {
1504
							if((empty($pconfig['ipprotocol'])) || ($pconfig['ipprotocol'] == $gwg_data['ipprotocol'])) {
1505
								if($pconfig['gateway'] == $gwg_name) {
1506
									$selected = " selected=\"selected\"";
1507
								} else {
1508
									$selected = "";
1509
								}
1510
								echo "<option value=\"{$gwg_name}\" $selected>{$gwg_name}</option>\n";
1511
							}
1512
						}
1513
					}
1514
?>
1515
					</select>
1516
					<p><?=gettext("Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.");?></p>
1517
				</div>
1518
			</td>
1519
		</tr>
1520
		<tr>
1521
			<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
1522
			<td width="78%" class="vtable">
1523
				<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1524
					<input type="button" onclick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1525
				</div>
1526
				<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1527
					<select name="dnpipe">
1528
<?php
1529
		if (!is_array($dnqlist))
1530
			$dnqlist = array();
1531
		echo "<option value=\"\"";
1532
		if (!$dnqselected) echo " selected=\"selected\"";
1533
		echo " >none</option>";
1534
		foreach ($dnqlist as $dnq => $dnqkey) {
1535
			if($dnq == "")
1536
				continue;
1537
			echo "<option value=\"$dnq\"";
1538
			if ($dnq == $pconfig['dnpipe']) {
1539
				$dnqselected = 1;
1540
				echo " selected=\"selected\"";
1541
			}
1542
			echo ">{$dnq}</option>";
1543
		}
1544
?>
1545
			</select> /
1546
			<select name="pdnpipe">
1547
<?php
1548
		$dnqselected = 0;
1549
		echo "<option value=\"\"";
1550
		if (!$dnqselected) echo " selected=\"selected\"";
1551
		echo " >none</option>";
1552
		foreach ($dnqlist as $dnq => $dnqkey) {
1553
			if($dnq == "")
1554
				continue;
1555
			echo "<option value=\"$dnq\"";
1556
			if ($dnq == $pconfig['pdnpipe']) {
1557
				$dnqselected = 1;
1558
				echo " selected=\"selected\"";
1559
			}
1560
			echo ">{$dnq}</option>";
1561
		}
1562
?>
1563
				</select>
1564
				<br />
1565
				<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>
1566
				</div>
1567
			</td>
1568
		</tr>
1569

    
1570
		<tr>
1571
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1572
			<td width="78%" class="vtable">
1573
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1574
				<input type="button" onclick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1575
			</div>
1576
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1577
				<select name="ackqueue">
1578
<?php
1579
			if (!is_array($qlist))
1580
				$qlist = array();
1581
			echo "<option value=\"\"";
1582
			if (!$qselected) echo " selected=\"selected\"";
1583
			echo " >none</option>";
1584
			foreach ($qlist as $q => $qkey) {
1585
				if($q == "")
1586
					continue;
1587
				echo "<option value=\"$q\"";
1588
				if ($q == $pconfig['ackqueue']) {
1589
					$qselected = 1;
1590
					echo " selected=\"selected\"";
1591
				}
1592
				if (isset($ifdisp[$q]))
1593
					echo ">{$ifdisp[$q]}</option>";
1594
				else
1595
					echo ">{$q}</option>";
1596
			}
1597
?>
1598
				</select> /
1599
				<select name="defaultqueue">
1600
<?php
1601
			$qselected = 0;
1602
			echo "<option value=\"\"";
1603
			if (!$qselected) echo " selected=\"selected\"";
1604
			echo " >none</option>";
1605
			foreach ($qlist as $q => $qkey) {
1606
				if($q == "")
1607
					continue;
1608
				echo "<option value=\"$q\"";
1609
				if ($q == $pconfig['defaultqueue']) {
1610
					$qselected = 1;
1611
					echo " selected=\"selected\"";
1612
				}
1613
				if (isset($ifdisp[$q]))
1614
					echo ">{$ifdisp[$q]}</option>";
1615
				else
1616
					echo ">{$q}</option>";
1617
			}
1618
?>
1619
				</select>
1620
					<br />
1621
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1622
					</div>
1623
				</td>
1624
			</tr>
1625
			<tr>
1626
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1627
				<td width="78%" class="vtable">
1628
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1629
						<input type="button" onclick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1630
					</div>
1631
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1632
						<select name="l7container">
1633
<?php
1634
						if (!is_array($l7clist))
1635
							$l7clist = array();
1636
						echo "<option value=\"\"";
1637
						echo " >none</option>";
1638
						foreach ($l7clist as $l7ckey) {
1639
							echo "<option value=\"{$l7ckey}\"";
1640
							if ($l7ckey == $pconfig['l7container']) {
1641
								echo " selected=\"selected\"";
1642
							}
1643
							echo ">{$l7ckey}</option>";
1644
						}
1645
?>
1646
						</select>
1647
						<br/>
1648
						<span class="vexpl">
1649
							<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1650
							"These are valid for TCP and UDP protocols only.");?>
1651
						</span>
1652
					</div>
1653
				</td>
1654
			</tr>
1655
<?php
1656
		// Allow extending of the firewall edit page and include custom input validation
1657
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphplate");
1658
?>
1659
<?php
1660
$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
1661
$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
1662
?>
1663
		<?php if ($has_created_time || $has_updated_time): ?>
1664
		<tr>
1665
			<td>&nbsp;</td>
1666
		</tr>
1667
		<tr>
1668
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
1669
		</tr>
1670
		<?php if ($has_created_time): ?>
1671
		<tr>
1672
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
1673
			<td width="78%" class="vtable">
1674
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['created']['username'] ?></strong>
1675
			</td>
1676
		</tr>
1677
		<?php endif; ?>
1678
		<?php if ($has_updated_time): ?>
1679
		<tr>
1680
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
1681
			<td width="78%" class="vtable">
1682
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['updated']['username'] ?></strong>
1683
			</td>
1684
		</tr>
1685
		<?php endif; ?>
1686
		<?php endif; ?>
1687
		<tr>
1688
			<td width="22%" valign="top">&nbsp;</td>
1689
			<td width="78%">
1690
				&nbsp;<br/>&nbsp;
1691
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1692
<?php			if (isset($id) && $a_filter[$id]): ?>
1693
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1694
<?php 			endif; ?>
1695
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1696
			</td>
1697
		</tr>
1698
	</table>
1699
</form>
1700
<script type="text/javascript">
1701
//<![CDATA[
1702
var autocomplete_off = ['src', 'srcbeginport_cust', 'srcendport_cust', 'dst', 'dstbeginport_cust', 'dstendport_cust'];
1703
for (var i = 0; i < autocomplete_off.length; i++) {
1704
	var node = document.getElementById(autocomplete_off[i]);
1705
	node.setAttribute("autocomplete",node.style.autocomplete);
1706
}
1707
//]]>
1708
</script>
1709
<script type="text/javascript">
1710
//<![CDATA[
1711
	ext_change();
1712
	typesel_change();
1713
	proto_change();
1714
	<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
1715
	show_source_port_range();
1716
	<?php endif; ?>
1717

    
1718
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1719
	var customarray  = <?= json_encode(get_alias_list("port")) ?>;
1720

    
1721
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1722
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1723
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1724
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1725
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1726
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1727
//]]>
1728
</script>
1729
<?php include("fend.inc"); ?>
1730
</body>
1731
</html>
(70-70/246)