Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
81
	if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
82
		$pconfig['created'] = $a_filter[$id]['created'];
83

    
84
	if ( isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']) )
85
		$pconfig['updated'] = $a_filter[$id]['updated'];
86

    
87
	if (!isset($a_filter[$id]['type']))
88
		$pconfig['type'] = "pass";
89
	else
90
		$pconfig['type'] = $a_filter[$id]['type'];
91

    
92
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
93
		$pconfig['floating'] = $a_filter[$id]['floating'];
94
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "")
95
			$pconfig['interface'] = $a_filter[$id]['interface'];
96
	}
97

    
98
	if (isset($a_filter['floating']))
99
		$pconfig['floating'] = "yes";
100

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

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

    
107
	if (isset($a_filter[$id]['protocol']))
108
		$pconfig['proto'] = $a_filter[$id]['protocol'];
109
	else
110
		$pconfig['proto'] = "any";
111

    
112
	if ($a_filter[$id]['protocol'] == "icmp")
113
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
114

    
115
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
116
		$pconfig['srcmask'], $pconfig['srcnot'],
117
		$pconfig['srcbeginport'], $pconfig['srcendport']);
118

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

    
122
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
123
		$pconfig['dstmask'], $pconfig['dstnot'],
124
		$pconfig['dstbeginport'], $pconfig['dstendport']);
125

    
126
	if ($a_filter[$id]['dscp'] <> "")
127
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
128

    
129
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
130
	$pconfig['log'] = isset($a_filter[$id]['log']);
131
	$pconfig['descr'] = $a_filter[$id]['descr'];
132

    
133
	if (isset($a_filter[$id]['tcpflags_any']))
134
		$pconfig['tcpflags_any'] = true;
135
	else {
136
		if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "")
137
			$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
138
		if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "")
139
			$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
140
	}
141

    
142
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "")
143
		$pconfig['tag'] = $a_filter[$id]['tag'];
144
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
145
		$pconfig['tagged'] = $a_filter[$id]['tagged'];
146
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
147
		$pconfig['quick'] = $a_filter[$id]['quick'];
148
	if (isset($a_filter[$id]['allowopts']))
149
		$pconfig['allowopts'] = true;
150
	if (isset($a_filter[$id]['disablereplyto']))
151
		$pconfig['disablereplyto'] = true;
152

    
153
	/* advanced */
154
	$pconfig['max'] = $a_filter[$id]['max'];
155
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
156
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
157
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
158
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
159
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
160
	$pconfig['nopfsync'] = isset($a_filter[$id]['nopfsync']);
161

    
162
	/* advanced - nosync */
163
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
164

    
165
	/* advanced - new connection per second banning*/
166
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
167
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
168

    
169
	/* Multi-WAN next-hop support */
170
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
171

    
172
	/* Shaper support */
173
	$pconfig['defaultqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['defaultqueue']);
174
	$pconfig['ackqueue'] = (($a_filter[$id]['ackqueue'] == "none") ? '' : $a_filter[$id]['ackqueue']);
175
	$pconfig['dnpipe'] = (($a_filter[$id]['dnpipe'] == "none") ? '' : $a_filter[$id]['dnpipe']);
176
	$pconfig['pdnpipe'] = (($a_filter[$id]['pdnpipe'] == "none") ? '' : $a_filter[$id]['pdnpipe']);
177
	$pconfig['l7container'] = (($a_filter[$id]['l7container'] == "none") ? '' : $a_filter[$id]['l7container']);
178

    
179
	//schedule support
180
	$pconfig['sched'] = (($a_filter[$id]['sched'] == "none") ? '' : $a_filter[$id]['sched']);
181
	$pconfig['vlanprio'] = (($a_filter[$id]['vlanprio'] == "none") ? '' : $a_filter[$id]['vlanprio']);
182
	$pconfig['vlanprioset'] = (($a_filter[$id]['vlanprioset'] == "none") ? '' : $a_filter[$id]['vlanprioset']);
183
	if (!isset($_GET['dup']))
184
		$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
185

    
186
	$pconfig['tracker'] = $a_filter[$id]['tracker'];
187

    
188
} else {
189
	/* defaults */
190
	if ($_GET['if'])
191
		$pconfig['interface'] = $_GET['if'];
192
	$pconfig['type'] = "pass";
193
	$pconfig['src'] = "any";
194
	$pconfig['dst'] = "any";
195
}
196
/* Allow the FloatingRules to work */
197
$if = $pconfig['interface'];
198

    
199
if (isset($_GET['dup']))
200
	unset($id);
201

    
202
read_altq_config(); /* XXX: */
203
$qlist =& get_unique_queue_list();
204
read_dummynet_config(); /* XXX: */
205
$dnqlist =& get_unique_dnqueue_list();
206
read_layer7_config();
207
$l7clist =& get_l7_unique_list();
208

    
209
if ($_POST) {
210
	unset($input_errors);
211

    
212
	if( isset($a_filter[$id]['associated-rule-id']) ) {
213
		$_POST['proto'] = $pconfig['proto'];
214
		if ($pconfig['proto'] == "icmp")
215
			$_POST['icmptype'] = $pconfig['icmptype'];
216
	}
217

    
218
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
219
		$a_gatewaygroups = return_gateway_groups_array();
220
		if(is_array($config['gateways']['gateway_group'])) {
221
			foreach($config['gateways']['gateway_group'] as $gw_group) {
222
				if($gw_group['name'] == $_POST['gateway']) {
223
					$family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol'];
224
					if($_POST['ipprotocol'] == $family) {
225
						continue;
226
					}
227
					if(($_POST['ipprotocol'] == "inet46") && ($_POST['ipprotocol'] != $family)) {
228
						$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
229
					}
230
					if(($_POST['ipprotocol'] == "inet6") && ($_POST['ipprotocol'] != $family)) {
231
						$input_errors[] = gettext("You can not assign a IPv4 gateway group on IPv6 Address Family rule");
232
					}
233
					if(($_POST['ipprotocol'] == "inet") && ($_POST['ipprotocol'] != $family)) {
234
						$input_errors[] = gettext("You can not assign a IPv6 gateway group on IPv4 Address Family rule");
235
					}
236
				}
237
			}
238
		}
239
	}
240
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "") && (is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway'])))) {
241
		if(($_POST['ipprotocol'] == "inet46") && ($_POST['gateway'] <> "")) {
242
			$input_errors[] = gettext("You can not assign a gateway to a rule that applies to IPv4 and IPv6");
243
		}
244
		if(($_POST['ipprotocol'] == "inet6") && (!is_ipaddrv6(lookup_gateway_ip_by_name($_POST['gateway'])))) {
245
			$input_errors[] = gettext("You can not assign the IPv4 Gateway to a IPv6 Filter rule");
246
		}
247
		if(($_POST['ipprotocol'] == "inet") && (!is_ipaddrv4(lookup_gateway_ip_by_name($_POST['gateway'])))) {
248
			$input_errors[] = gettext("You can not assign the IPv6 Gateway to a IPv4 Filter rule");
249
		}
250
	}
251

    
252
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp") && ($_POST['proto'] != "icmp")) {
253
		if($_POST['ipprotocol'] == "inet46")
254
			$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");
255
	}
256
	if (($_POST['proto'] == "icmp") && ($_POST['icmptype'] <> "")){
257
		if($_POST['ipprotocol'] == "inet46")
258
			$input_errors[] =  gettext("You can not assign a ICMP type to a rule that applies to IPv4 and IPv6");
259
	}
260

    
261
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
262
		$_POST['srcbeginport'] = 0;
263
		$_POST['srcendport'] = 0;
264
		$_POST['dstbeginport'] = 0;
265
		$_POST['dstendport'] = 0;
266
	} else {
267
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
268
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
269
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
270
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
271
		if ($_POST['srcbeginport'] == "any") {
272
			$_POST['srcbeginport'] = 0;
273
			$_POST['srcendport'] = 0;
274
		} else {
275
			if (!$_POST['srcendport'])
276
				$_POST['srcendport'] = $_POST['srcbeginport'];
277
		}
278
		if ($_POST['srcendport'] == "any")
279
			$_POST['srcendport'] = $_POST['srcbeginport'];
280

    
281
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
282
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
283
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
284
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
285

    
286
		if ($_POST['dstbeginport'] == "any") {
287
			$_POST['dstbeginport'] = 0;
288
			$_POST['dstendport'] = 0;
289
		} else {
290
			if (!$_POST['dstendport'])
291
				$_POST['dstendport'] = $_POST['dstbeginport'];
292
		}
293
		if ($_POST['dstendport'] == "any")
294
			$_POST['dstendport'] = $_POST['dstbeginport'];
295
	}
296

    
297
	if (is_specialnet($_POST['srctype'])) {
298
		$_POST['src'] = $_POST['srctype'];
299
		$_POST['srcmask'] = 0;
300
	} else if ($_POST['srctype'] == "single") {
301
		if (is_ipaddrv6($_POST['src']))
302
			$_POST['srcmask'] = 128;
303
		else
304
			$_POST['srcmask'] = 32;
305
	}
306
	if (is_specialnet($_POST['dsttype'])) {
307
		$_POST['dst'] = $_POST['dsttype'];
308
		$_POST['dstmask'] = 0;
309
	}  else if ($_POST['dsttype'] == "single") {
310
		if (is_ipaddrv6($_POST['dst']))
311
			$_POST['dstmask'] = 128;
312
		else
313
			$_POST['dstmask'] = 32;
314
	}
315

    
316
	$pconfig = $_POST;
317

    
318
	/* input validation */
319
	$reqdfields = explode(" ", "type proto");
320
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
321
		$reqdfields[] = "src";
322
		$reqdfields[] = "dst";
323
	}
324
	$reqdfieldsn = explode(",", "Type,Protocol");
325
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
326
		$reqdfieldsn[] = "Source";
327
		$reqdfieldsn[] = "Destination";
328
	}
329

    
330
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
331
		if( $_POST['proto'] != "tcp" )
332
			$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
333
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
334
			$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
335
	}
336

    
337
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
338
	(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
339
		$reqdfields[] = "srcmask";
340
		$reqdfieldsn[] = "Source bit count";
341
	}
342
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
343
	(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
344
		$reqdfields[] = "dstmask";
345
		$reqdfieldsn[] = gettext("Destination bit count");
346
	}
347

    
348
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
349

    
350
	if (!$_POST['srcbeginport']) {
351
		$_POST['srcbeginport'] = 0;
352
		$_POST['srcendport'] = 0;
353
	}
354
	if (!$_POST['dstbeginport']) {
355
		$_POST['dstbeginport'] = 0;
356
		$_POST['dstendport'] = 0;
357
	}
358

    
359
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
360
		$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']);
361
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
362
			$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']);
363
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
364
			$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']);
365
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
366
			$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']);
367
	if ( !$_POST['srcbeginport_cust'] && $_POST['srcendport_cust'])
368
		if (is_alias($_POST['srcendport_cust']))
369
			$input_errors[] = 'If you put port alias in Source port range to: field you must put the same port alias in from: field';
370
	if ( $_POST['srcbeginport_cust'] && $_POST['srcendport_cust']){
371
		if (is_alias($_POST['srcendport_cust']) && is_alias($_POST['srcendport_cust']) && $_POST['srcbeginport_cust'] != $_POST['srcendport_cust'])
372
			$input_errors[] = 'The same port alias must be used in Source port range from: and to: fields';
373
		if ((is_alias($_POST['srcbeginport_cust']) && (!is_alias($_POST['srcendport_cust']) && $_POST['srcendport_cust']!='')) ||
374
		    ((!is_alias($_POST['srcbeginport_cust']) && $_POST['srcbeginport_cust']!='') && is_alias($_POST['srcendport_cust'])))
375
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Source port range from: and to: field';
376
	}
377
	if ( !$_POST['dstbeginport_cust'] && $_POST['dstendport_cust'])
378
		if (is_alias($_POST['dstendport_cust']))
379
			$input_errors[] = 'If you put port alias in Destination port range to: field you must put the same port alias in from: field';
380
	if ( $_POST['dstbeginport_cust'] && $_POST['dstendport_cust']){
381
		if (is_alias($_POST['dstendport_cust']) && is_alias($_POST['dstendport_cust']) && $_POST['dstbeginport_cust'] != $_POST['dstendport_cust'])
382
			$input_errors[] = 'The same port alias must be used in Destination port range from: and to: fields';
383
		if ((is_alias($_POST['dstbeginport_cust']) && (!is_alias($_POST['dstendport_cust']) && $_POST['dstendport_cust']!='')) ||
384
		    ((!is_alias($_POST['dstbeginport_cust']) && $_POST['dstbeginport_cust']!='') && is_alias($_POST['dstendport_cust'])))
385
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field';
386
	}
387

    
388
	if ($_POST['src'])
389
		$_POST['src'] = trim($_POST['src']);
390
	if ($_POST['dst'])
391
		$_POST['dst'] = trim($_POST['dst']);
392

    
393
	/* if user enters an alias and selects "network" then disallow. */
394
	if($_POST['srctype'] == "network") {
395
		if(is_alias($_POST['src']))
396
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
397
	}
398
	if($_POST['dsttype'] == "network") {
399
		if(is_alias($_POST['dst']))
400
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
401
	}
402

    
403
	if (!is_specialnet($_POST['srctype'])) {
404
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
405
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
406
		}
407
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
408
			$input_errors[] = gettext("A valid source bit count must be specified.");
409
		}
410
	}
411
	if (!is_specialnet($_POST['dsttype'])) {
412
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
413
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
414
		}
415
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
416
			$input_errors[] = gettext("A valid destination bit count must be specified.");
417
		}
418
	}
419
	if((is_ipaddr($_POST['src']) && is_ipaddr($_POST['dst']))) {
420
		if(!validate_address_family($_POST['src'], $_POST['dst']))
421
			$input_errors[] = sprintf(gettext("The Source IP address %s Address Family differs from the destination %s."), $_POST['src'], $_POST['dst']);
422
		if((is_ipaddrv6($_POST['src']) || is_ipaddrv6($_POST['dst'])) && ($_POST['ipprotocol'] == "inet"))
423
			$input_errors[] = gettext("You can not use IPv6 addresses in IPv4 rules.");
424
		if((is_ipaddrv4($_POST['src']) || is_ipaddrv4($_POST['dst'])) && ($_POST['ipprotocol'] == "inet6"))
425
			$input_errors[] = gettext("You can not use IPv4 addresses in IPv6 rules.");
426
		if((is_ipaddr($_POST['src']) || is_ipaddr($_POST['dst'])) && ($_POST['ipprotocol'] == "inet46"))
427
			$input_errors[] = gettext("You can not use a IPv4 or IPv6 address in combined IPv4 + IPv6 rules.");
428

    
429
	}
430

    
431
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
432
		/* swap */
433
		$tmp = $_POST['srcendport'];
434
		$_POST['srcendport'] = $_POST['srcbeginport'];
435
		$_POST['srcbeginport'] = $tmp;
436
	}
437
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
438
		/* swap */
439
		$tmp = $_POST['dstendport'];
440
		$_POST['dstendport'] = $_POST['dstbeginport'];
441
		$_POST['dstbeginport'] = $tmp;
442
	}
443
	if ($_POST['os'])
444
		if( $_POST['proto'] != "tcp" )
445
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
446

    
447
	if ($_POST['ackqueue'] != "") {
448
		if ($_POST['defaultqueue'] == "" )
449
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
450
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
451
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
452
	}
453
	if (isset($_POST['floating']) && $_POST['pdnpipe'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
454
		$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
455
	if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
456
		$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
457
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "") {
458
		if ($_POST['dnpipe'] == "" )
459
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
460
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
461
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
462
		else if ($dnqlist[$_POST['pdnpipe']][0] == "?" && $dnqlist[$_POST['dnpipe']][0] <> "?")
463
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
464
		else if ($dnqlist[$_POST['dnpipe']][0] == "?" && $dnqlist[$_POST['pdnpipe']][0] <> "?")
465
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
466
		if ($_POST['direction'] == "out" && empty($_POST['gateway']))
467
			$input_errors[] = gettext("Please select a gateway, normaly the interface selected gateway, so the limiters work correctly");
468
	}
469
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
470
		$input_errors[] = gettext('ID must be an integer');
471
	if($_POST['l7container'] && $_POST['l7container'] != "") {
472
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
473
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
474
		if ($_POST['type'] <> "pass")
475
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
476
	}
477

    
478
	if (!in_array($_POST['proto'], array("tcp","tcp/udp"))) {
479
		if (!empty($_POST['max-src-conn']))
480
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
481
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
482
			$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for TCP protocol.");
483
		if (!empty($_POST['statetimeout']))
484
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
485
	}
486

    
487
	if ($_POST['type'] <> "pass") {
488
		if (!empty($_POST['max']))
489
			$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for Pass type rules.");
490
		if (!empty($_POST['max-src-nodes']))
491
			$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for Pass type rules.");
492
		if (!empty($_POST['max-src-conn']))
493
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for Pass type rules.");
494
		if (!empty($_POST['max-src-states']))
495
			$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for Pass type rules.");
496
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
497
			$input_errors[] = gettext("You can only specify the maximum new connections per host / per second(s) (advanced option) for Pass type rules.");
498
		if (!empty($_POST['statetimeout']))
499
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for Pass type rules.");
500
	}
501

    
502
	if (($_POST['statetype'] == "none") && (empty($_POST['l7container']))) {
503
		if (!empty($_POST['max']))
504
			$input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected.");
505
		if (!empty($_POST['max-src-nodes']))
506
			$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.");
507
		if (!empty($_POST['max-src-conn']))
508
			$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.");
509
		if (!empty($_POST['max-src-states']))
510
			$input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected.");
511
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
512
			$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.");
513
		if (!empty($_POST['statetimeout']))
514
			$input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected.");
515
	}
516

    
517
	if (!$_POST['tcpflags_any']) {
518
		$settcpflags = array();
519
		$outoftcpflags = array();
520
		foreach ($tcpflags as $tcpflag) {
521
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
522
				$settcpflags[] = $tcpflag;
523
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
524
				$outoftcpflags[] = $tcpflag;
525
		}
526
		if (empty($outoftcpflags) && !empty($settcpflags))
527
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
528
	}
529

    
530
	// Allow extending of the firewall edit page and include custom input validation
531
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
532

    
533
	if (!$input_errors) {
534
		$filterent = array();
535
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
536

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

    
539
		$filterent['type'] = $_POST['type'];
540
		if (isset($_POST['interface'] ))
541
			$filterent['interface'] = $_POST['interface'];
542

    
543
		if (isset($_POST['ipprotocol'] ))
544
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
545

    
546
		if ($_POST['tcpflags_any']) {
547
			$filterent['tcpflags_any'] = true;
548
		} else {
549
			$settcpflags = array();
550
			$outoftcpflags = array();
551
			foreach ($tcpflags as $tcpflag) {
552
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
553
					$settcpflags[] = $tcpflag;
554
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
555
					$outoftcpflags[] = $tcpflag;
556
			}
557
			if (!empty($outoftcpflags)) {
558
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
559
				if (!empty($settcpflags))
560
					$filterent['tcpflags1'] = join(",", $settcpflags);
561
			}
562
		}
563

    
564
		if (isset($_POST['tag']))
565
			$filterent['tag'] = $_POST['tag'];
566
		if (isset($_POST['tagged']))
567
			$filterent['tagged'] = $_POST['tagged'];
568
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
569
			$filterent['direction'] = $_POST['direction'];
570
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
571
				$filterent['quick'] = $_POST['quick'];
572
			$filterent['floating'] = "yes";
573
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
574
				$filterent['interface'] = implode(",", $_POST['interface']);
575
			}
576
		}
577

    
578
		/* Advanced options */
579
		if ($_POST['allowopts'] == "yes")
580
			$filterent['allowopts'] = true;
581
		else
582
			unset($filterent['allowopts']);
583
		if ($_POST['disablereplyto'] == "yes")
584
			$filterent['disablereplyto'] = true;
585
		else
586
			unset($filterent['disablereplyto']);
587
		$filterent['max'] = $_POST['max'];
588
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
589
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
590
		$filterent['max-src-states'] = $_POST['max-src-states'];
591
		$filterent['statetimeout'] = $_POST['statetimeout'];
592
		$filterent['statetype'] = $_POST['statetype'];
593
		$filterent['os'] = $_POST['os'];
594
		if($_POST['nopfsync'] <> "")
595
			$filterent['nopfsync'] = true;
596
		else
597
			unset($filterent['nopfsync']);
598

    
599
		/* Nosync directive - do not xmlrpc sync this item */
600
		if($_POST['nosync'] <> "")
601
			$filterent['nosync'] = true;
602
		else
603
			unset($filterent['nosync']);
604

    
605
		/* unless both values are provided, unset the values - ticket #650 */
606
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
607
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
608
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
609
		} else {
610
			unset($filterent['max-src-conn-rate']);
611
			unset($filterent['max-src-conn-rates']);
612
		}
613

    
614
		if ($_POST['proto'] != "any")
615
			$filterent['protocol'] = $_POST['proto'];
616
		else
617
			unset($filterent['protocol']);
618

    
619
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
620
			$filterent['icmptype'] = $_POST['icmptype'];
621
		else
622
			unset($filterent['icmptype']);
623

    
624
		pconfig_to_address($filterent['source'], $_POST['src'],
625
			$_POST['srcmask'], $_POST['srcnot'],
626
			$_POST['srcbeginport'], $_POST['srcendport']);
627

    
628
		pconfig_to_address($filterent['destination'], $_POST['dst'],
629
			$_POST['dstmask'], $_POST['dstnot'],
630
			$_POST['dstbeginport'], $_POST['dstendport']);
631

    
632
		if ($_POST['disabled'])
633
			$filterent['disabled'] = true;
634
		else
635
			unset($filterent['disabled']);
636

    
637
		if ($_POST['dscp'])
638
			$filterent['dscp'] = $_POST['dscp'];
639

    
640
		if ($_POST['log'])
641
			$filterent['log'] = true;
642
		else
643
			unset($filterent['log']);
644
		strncpy($filterent['descr'], $_POST['descr'], 52);
645

    
646
		if ($_POST['gateway'] != "") {
647
			$filterent['gateway'] = $_POST['gateway'];
648
		}
649

    
650
		if ($_POST['defaultqueue'] != "") {
651
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
652
			if ($_POST['ackqueue'] != "")
653
				$filterent['ackqueue'] = $_POST['ackqueue'];
654
		}
655

    
656
		if ($_POST['dnpipe'] != "") {
657
			$filterent['dnpipe'] = $_POST['dnpipe'];
658
			if ($_POST['pdnpipe'] != "")
659
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
660
		}
661

    
662
		if ($_POST['l7container'] != "") {
663
			$filterent['l7container'] = $_POST['l7container'];
664
		}
665

    
666
		if ($_POST['sched'] != "") {
667
			$filterent['sched'] = $_POST['sched'];
668
		}
669

    
670
		if ($_POST['vlanprio'] != "") {
671
			$filterent['vlanprio'] = $_POST['vlanprio'];
672
		}
673
		if ($_POST['vlanprioset'] != "") {
674
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
675
		}
676

    
677
		// If we have an associated nat rule, make sure the source and destination doesn't change
678
		if( isset($a_filter[$id]['associated-rule-id']) ) {
679
			$filterent['interface'] = $a_filter[$id]['interface'];
680
			if (isset($a_filter[$id]['protocol']))
681
				$filterent['protocol'] = $a_filter[$id]['protocol'];
682
			else if (isset($filterent['protocol']))
683
				unset($filterent['protocol']);
684
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
685
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
686
			else if (isset($filterent['icmptype']))
687
				unset($filterent['icmptype']);
688

    
689
			$filterent['source'] = $a_filter[$id]['source'];
690
			$filterent['destination'] = $a_filter[$id]['destination'];
691
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
692
		}
693

    
694
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
695
			$filterent['created'] = $a_filter[$id]['created'];
696

    
697
		$filterent['updated'] = make_config_revision_entry();
698

    
699
		// Allow extending of the firewall edit page and include custom input validation
700
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
701

    
702
		if (isset($id) && $a_filter[$id])
703
			$a_filter[$id] = $filterent;
704
		else {
705
			$filterent['created'] = make_config_revision_entry();
706
			if (is_numeric($after))
707
				array_splice($a_filter, $after+1, 0, array($filterent));
708
			else
709
				$a_filter[] = $filterent;
710
		}
711

    
712
		filter_rules_sort();
713

    
714
		if (write_config())
715
			mark_subsystem_dirty('filter');
716

    
717
		if (isset($_POST['floating']))
718
			header("Location: firewall_rules.php?if=FloatingRules");
719
		else
720
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
721
		exit;
722
	}
723
}
724

    
725
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
726
$shortcut_section = "firewall";
727

    
728
$closehead = false;
729

    
730
$page_filename = "firewall_rules_edit.php";
731
include("head.inc");
732

    
733
?>
734
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
735
</head>
736

    
737
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
738
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
739
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
740
<?php include("fbegin.inc"); ?>
741
<?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_input_errors"); ?>
742
<?php if ($input_errors) print_input_errors($input_errors); ?>
743

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

    
747
	<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall rules edit">
748
		<tr>
749
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
750
		</tr>
751
<?php
752
		// Allow extending of the firewall edit page and include custom input validation
753
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
754
?>
755
		<tr>
756
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
757
			<td width="78%" class="vtable">
758
				<select name="type" class="formselect">
759
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
760
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>
761
					<?=htmlspecialchars($type);?>
762
					</option>
763
					<?php endforeach; ?>
764
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
765
					<option value="match" <?php if ("match" == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>Match</option>
766
<?php endif; ?>
767
				</select>
768
				<br/>
769
				<span class="vexpl">
770
					<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br/>
771
					<?=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.");?>
772
				</span>
773
			</td>
774
		</tr>
775
		<tr>
776
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
777
			<td width="78%" class="vtable">
778
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
779
				<strong><?=gettext("Disable this rule");?></strong><br />
780
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
781
			</td>
782
		</tr>
783
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
784
		<tr>
785
			<td width="22%" valign="top" class="vncellreq">
786
				<?=gettext("Quick");?>
787
			</td>
788
			<td width="78%" class="vtable">
789
				<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
790
				<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
791
				<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
792
			</td>
793
		</tr>
794
<?php endif; ?>
795
<?php $edit_disabled = ""; ?>
796
<?php if( isset($pconfig['associated-rule-id']) ): ?>
797
		<tr>
798
			<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
799
			<td width="78%" class="vtable">
800
				<span class="red"><strong><?=gettext("Note: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
801
				<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
802
				<br />
803
				<?php
804
					$edit_disabled = "disabled";
805
					if (is_array($config['nat']['rule'])) {
806
						foreach( $config['nat']['rule'] as $index => $nat_rule ) {
807
							if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
808
								echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br/>";
809
								break;
810
							}
811
						}
812
					}
813
					echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' />";
814
					if (!empty($pconfig['interface']))
815
						echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' />";
816
				?>
817
				<script type="text/javascript">
818
				editenabled = 0;
819
				</script>
820
			</td>
821
		</tr>
822
<?php endif; ?>
823
		<tr>
824
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
825
			<td width="78%" class="vtable">
826
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
827
				<select name="interface[]" title="Select interfaces..." multiple="multiple" style="width:350px;" class="chzn-select" tabindex="2" <?=$edit_disabled;?>>
828
<?php else: ?>
829
				<select name="interface" class="formselect" <?=$edit_disabled;?>>
830
<?php endif;
831
				/* add group interfaces */
832
				if (is_array($config['ifgroups']['ifgroupentry']))
833
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
834
						if (have_ruleint_access($ifgen['ifname']))
835
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
836
				$ifdescs = get_configured_interface_with_descr();
837
				// Allow extending of the firewall edit page and include custom input validation
838
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
839
				foreach ($ifdescs as $ifent => $ifdesc)
840
					if(have_ruleint_access($ifent))
841
							$interfaces[$ifent] = $ifdesc;
842
					if ($config['l2tp']['mode'] == "server")
843
						if(have_ruleint_access("l2tp"))
844
							$interfaces['l2tp'] = "L2TP VPN";
845
					if ($config['pptpd']['mode'] == "server")
846
						if(have_ruleint_access("pptp"))
847
							$interfaces['pptp'] = "PPTP VPN";
848

    
849
					if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
850
						$interfaces['pppoe'] = "PPPoE VPN";
851
					/* add ipsec interfaces */
852
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
853
						if(have_ruleint_access("enc0"))
854
							$interfaces["enc0"] = "IPsec";
855
					/* add openvpn/tun interfaces */
856
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
857
						$interfaces["openvpn"] = "OpenVPN";
858
					if (is_array($pconfig['interface']))
859
						$pconfig['interface'] = implode(",", $pconfig['interface']);
860
					$selected_interfaces = explode(",", $pconfig['interface']);
861
					foreach ($interfaces as $iface => $ifacename): ?>
862
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected=\"selected\""; ?>><?=$ifacename?></option>
863
<?php 				endforeach; ?>
864
				</select>
865
				<br />
866
				<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
867
			</td>
868
		</tr>
869
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
870
		<tr>
871
			<td width="22%" valign="top" class="vncellreq">
872
				<?=gettext("Direction");?>
873
			</td>
874
			<td width="78%" class="vtable">
875
				<select name="direction" class="formselect">
876
					<?php      $directions = array('any','in','out');
877
				foreach ($directions as $direction): ?>
878
				<option value="<?=$direction;?>"
879
					<?php if ($direction == $pconfig['direction']): ?>
880
						selected="selected"
881
					<?php endif; ?>
882
					><?=$direction;?></option>
883
				<?php endforeach; ?>
884
				</select>
885
				<input type="hidden" id="floating" name="floating" value="floating" />
886
			</td>
887
		<tr>
888
<?php endif; ?>
889
		<tr>
890
			<td width="22%" valign="top" class="vncellreq"><?=gettext("TCP/IP Version");?></td>
891
			<td width="78%" class="vtable">
892
				<select name="ipprotocol" class="formselect">
893
					<?php      $ipproto = array('inet' => 'IPv4','inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6' );
894
				foreach ($ipproto as $proto => $name): ?>
895
				<option value="<?=$proto;?>"
896
					<?php if ($proto == $pconfig['ipprotocol']): ?>
897
						selected="selected"
898
					<?php endif; ?>
899
					><?=$name;?></option>
900
				<?php endforeach; ?>
901
				</select>
902
				<strong><?=gettext("Select the Internet Protocol version this rule applies to");?></strong><br />
903
			</td>
904
		</tr>
905
		<tr>
906
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
907
			<td width="78%" class="vtable">
908
				<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
909
<?php
910
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP OSPF any carp pfsync");
911
				foreach ($protocols as $proto): ?>
912
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
913
<?php 			endforeach; ?>
914
				</select>
915
				<br />
916
				<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>
917
			</td>
918
		</tr>
919
		<tr id="icmpbox">
920
			<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
921
			<td class="vtable">
922
				<select <?=$edit_disabled;?> name="icmptype" class="formselect">
923
<?php
924
				$icmptypes = array(
925
				"" => gettext("any"),
926
				"echoreq" => gettext("Echo request"),
927
				"echorep" => gettext("Echo reply"),
928
				"unreach" => gettext("Destination unreachable"),
929
				"squench" => gettext("Source quench"),
930
				"redir" => gettext("Redirect"),
931
				"althost" => gettext("Alternate Host"),
932
				"routeradv" => gettext("Router advertisement"),
933
				"routersol" => gettext("Router solicitation"),
934
				"timex" => gettext("Time exceeded"),
935
				"paramprob" => gettext("Invalid IP header"),
936
				"timereq" => gettext("Timestamp"),
937
				"timerep" => gettext("Timestamp reply"),
938
				"inforeq" => gettext("Information request"),
939
				"inforep" => gettext("Information reply"),
940
				"maskreq" => gettext("Address mask request"),
941
				"maskrep" => gettext("Address mask reply")
942
				);
943

    
944
				foreach ($icmptypes as $icmptype => $descr): ?>
945
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
946
<?php 			endforeach; ?>
947
			</select>
948
			<br />
949
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
950
		</td>
951
		</tr>
952
		<tr>
953
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
954
			<td width="78%" class="vtable">
955
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
956
				<strong><?=gettext("not");?></strong>
957
				<br />
958
				<?=gettext("Use this option to invert the sense of the match.");?>
959
				<br />
960
				<br />
961
				<table border="0" cellspacing="0" cellpadding="0">
962
					<tr>
963
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
964
						<td>
965
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onchange="typesel_change()">
966
<?php
967
								$sel = is_specialnet($pconfig['src']); ?>
968
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
969
								<option value="single"
970
						<?php  if (!$sel &&
971
							    ((is_ipaddrv6($pconfig['src']) && $pconfig['srcmask'] == 128) ||
972
							    (is_ipaddrv4($pconfig['src']) && $pconfig['srcmask'] == 32) || is_alias($pconfig['src'])))
973
								{ echo "selected=\"selected\""; $sel = 1; }
974
						?>
975
								> <?=gettext("Single host or alias");?></option>
976
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
977
								<?php if(have_ruleint_access("pptp")): ?>
978
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
979
								<?php endif; ?>
980
								<?php if(have_ruleint_access("pppoe")): ?>
981
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
982
								<?php endif; ?>
983
								<?php if(have_ruleint_access("l2tp")): ?>
984
								<option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
985
								<?php endif; ?>
986
<?php
987
								foreach ($ifdisp as $ifent => $ifdesc): ?>
988
								<?php if(have_ruleint_access($ifent)): ?>
989
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net");?></option>
990
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
991
										<?=$ifdesc?> <?=gettext("address");?>
992
									</option>
993
								<?php endif; ?>
994
<?php 							endforeach; ?>
995
							</select>
996
						</td>
997
					</tr>
998
					<tr>
999
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
1000
						<td>
1001
							<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']);?>" /> /
1002
							<select <?=$edit_disabled;?> name="srcmask" class="formselect ipv4v6" id="srcmask">
1003
<?php						for ($i = 127; $i > 0; $i--): ?>
1004
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
1005
<?php 						endfor; ?>
1006
							</select>
1007
						</td>
1008
					</tr>
1009
				</table>
1010
				<div id="showadvancedboxspr">
1011
					<p>
1012
					<input <?=$edit_disabled;?> type="button" onclick="show_source_port_range()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source port range");?>
1013
					</p>
1014
				</div>
1015
			</td>
1016
		</tr>
1017
		<tr style="display:none" id="sprtable">
1018
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
1019
			<td width="78%" class="vtable">
1020
				<table border="0" cellspacing="0" cellpadding="0">
1021
					<tr>
1022
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1023
						<td>
1024
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
1025
								<option value="">(<?=gettext("other"); ?>)</option>
1026
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1027
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1028
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1029
<?php 							endforeach; ?>
1030
							</select>
1031
							<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']); ?>" />
1032
						</td>
1033
					</tr>
1034
					<tr>
1035
						<td><?=gettext("to:");?></td>
1036
						<td>
1037
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
1038
								<option value="">(<?=gettext("other"); ?>)</option>
1039
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1040
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1041
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1042
<?php							endforeach; ?>
1043
							</select>
1044
							<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']); ?>" />
1045
						</td>
1046
					</tr>
1047
				</table>
1048
				<br />
1049
				<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/>
1050
			</td>
1051
		</tr>
1052
		<tr>
1053
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
1054
			<td width="78%" class="vtable">
1055
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
1056
				<strong><?=gettext("not");?></strong>
1057
					<br />
1058
				<?=gettext("Use this option to invert the sense of the match.");?>
1059
					<br />
1060
					<br />
1061
				<table border="0" cellspacing="0" cellpadding="0">
1062
					<tr>
1063
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
1064
						<td>
1065
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onchange="typesel_change()">
1066
<?php
1067
								$sel = is_specialnet($pconfig['dst']); ?>
1068
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1069
								<option value="single"
1070
								<?php  if (!$sel &&
1071
									    ((is_ipaddrv6($pconfig['dst']) && $pconfig['dstmask'] == 128) ||
1072
									    (is_ipaddrv4($pconfig['dst']) && $pconfig['dstmask'] == 32) || is_alias($pconfig['dst'])))
1073
										{ echo "selected=\"selected\""; $sel = 1; }
1074
								?>
1075
								><?=gettext("Single host or alias");?></option>
1076
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1077
								<?php if(have_ruleint_access("pptp")): ?>
1078
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1079
								<?php endif; ?>
1080
								<?php if(have_ruleint_access("pppoe")): ?>
1081
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1082
								<?php endif; ?>
1083
								<?php if(have_ruleint_access("l2tp")): ?>
1084
								<option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1085
								<?php endif; ?>
1086

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

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

    
1549
		<tr>
1550
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1551
			<td width="78%" class="vtable">
1552
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1553
				<input type="button" onclick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1554
			</div>
1555
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1556
				<select name="ackqueue">
1557
<?php
1558
			if (!is_array($qlist))
1559
				$qlist = array();
1560
			echo "<option value=\"\"";
1561
			if (!$qselected) echo " selected=\"selected\"";
1562
			echo " >none</option>";
1563
			foreach ($qlist as $q => $qkey) {
1564
				if($q == "")
1565
					continue;
1566
				echo "<option value=\"$q\"";
1567
				if ($q == $pconfig['ackqueue']) {
1568
					$qselected = 1;
1569
					echo " selected=\"selected\"";
1570
				}
1571
				if (isset($ifdisp[$q]))
1572
					echo ">{$ifdisp[$q]}</option>";
1573
				else
1574
					echo ">{$q}</option>";
1575
			}
1576
?>
1577
				</select> /
1578
				<select name="defaultqueue">
1579
<?php
1580
			$qselected = 0;
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['defaultqueue']) {
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
					<br />
1600
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1601
					</div>
1602
				</td>
1603
			</tr>
1604
			<tr>
1605
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1606
				<td width="78%" class="vtable">
1607
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1608
						<input type="button" onclick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1609
					</div>
1610
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1611
						<select name="l7container">
1612
<?php
1613
						if (!is_array($l7clist))
1614
							$l7clist = array();
1615
						echo "<option value=\"\"";
1616
						echo " >none</option>";
1617
						foreach ($l7clist as $l7ckey) {
1618
							echo "<option value=\"{$l7ckey}\"";
1619
							if ($l7ckey == $pconfig['l7container']) {
1620
								echo " selected=\"selected\"";
1621
							}
1622
							echo ">{$l7ckey}</option>";
1623
						}
1624
?>
1625
						</select>
1626
						<br/>
1627
						<span class="vexpl">
1628
							<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1629
							"These are valid for TCP and UDP protocols only.");?>
1630
						</span>
1631
					</div>
1632
				</td>
1633
			</tr>
1634
<?php
1635
		// Allow extending of the firewall edit page and include custom input validation
1636
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphplate");
1637
?>
1638
<?php
1639
$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
1640
$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
1641
?>
1642
		<?php if ($has_created_time || $has_updated_time): ?>
1643
		<tr>
1644
			<td>&nbsp;</td>
1645
		</tr>
1646
		<tr>
1647
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
1648
		</tr>
1649
		<?php if ($has_created_time): ?>
1650
		<tr>
1651
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
1652
			<td width="78%" class="vtable">
1653
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['created']['username'] ?></strong>
1654
			</td>
1655
		</tr>
1656
		<?php endif; ?>
1657
		<?php if ($has_updated_time): ?>
1658
		<tr>
1659
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
1660
			<td width="78%" class="vtable">
1661
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['updated']['username'] ?></strong>
1662
			</td>
1663
		</tr>
1664
		<?php endif; ?>
1665
		<?php endif; ?>
1666
		<tr>
1667
			<td width="22%" valign="top">&nbsp;</td>
1668
			<td width="78%">
1669
				&nbsp;<br/>&nbsp;
1670
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1671
<?php			if (isset($id) && $a_filter[$id]): ?>
1672
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1673
					<input name="tracker" type="hidden" value="<?=htmlspecialchars($pconfig['tracker']);?>">
1674
<?php 			endif; ?>
1675
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1676
			</td>
1677
		</tr>
1678
	</table>
1679
</form>
1680
<script type="text/javascript">
1681
//<![CDATA[
1682
	ext_change();
1683
	typesel_change();
1684
	proto_change();
1685
	<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
1686
	show_source_port_range();
1687
	<?php endif; ?>
1688

    
1689
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1690
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
1691

    
1692
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1693
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1694
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1695
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1696
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1697
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1698
//]]>
1699
</script>
1700
<?php include("fend.inc"); ?>
1701
</body>
1702
</html>
(70-70/249)