Project

General

Profile

Download (76.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
$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
} else {
187
	/* defaults */
188
	if ($_GET['if'])
189
		$pconfig['interface'] = $_GET['if'];
190
	$pconfig['type'] = "pass";
191
	$pconfig['src'] = "any";
192
	$pconfig['dst'] = "any";
193
}
194
/* Allow the FloatingRules to work */
195
$if = $pconfig['interface'];
196

    
197
if (isset($_GET['dup']))
198
	unset($id);
199

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

    
207
if ($_POST) {
208
	unset($input_errors);
209

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

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

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

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

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

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

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

    
314
	$pconfig = $_POST;
315

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

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

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

    
346
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
347

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

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

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

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

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

    
427
	}
428

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

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

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

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

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

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

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

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

    
538
		if (isset($_POST['ipprotocol'] ))
539
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
540

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

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

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

    
594
		/* Nosync directive - do not xmlrpc sync this item */
595
		if($_POST['nosync'] <> "")
596
			$filterent['nosync'] = true;
597
		else
598
			unset($filterent['nosync']);
599

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

    
609
		if ($_POST['proto'] != "any")
610
			$filterent['protocol'] = $_POST['proto'];
611
		else
612
			unset($filterent['protocol']);
613

    
614
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
615
			$filterent['icmptype'] = $_POST['icmptype'];
616
		else
617
			unset($filterent['icmptype']);
618

    
619
		pconfig_to_address($filterent['source'], $_POST['src'],
620
			$_POST['srcmask'], $_POST['srcnot'],
621
			$_POST['srcbeginport'], $_POST['srcendport']);
622

    
623
		pconfig_to_address($filterent['destination'], $_POST['dst'],
624
			$_POST['dstmask'], $_POST['dstnot'],
625
			$_POST['dstbeginport'], $_POST['dstendport']);
626

    
627
		if ($_POST['disabled'])
628
			$filterent['disabled'] = true;
629
		else
630
			unset($filterent['disabled']);
631

    
632
		if ($_POST['dscp'])
633
			$filterent['dscp'] = $_POST['dscp'];
634

    
635
		if ($_POST['log'])
636
			$filterent['log'] = true;
637
		else
638
			unset($filterent['log']);
639
		strncpy($filterent['descr'], $_POST['descr'], 52);
640

    
641
		if ($_POST['gateway'] != "") {
642
			$filterent['gateway'] = $_POST['gateway'];
643
		}
644

    
645
		if ($_POST['defaultqueue'] != "") {
646
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
647
			if ($_POST['ackqueue'] != "")
648
				$filterent['ackqueue'] = $_POST['ackqueue'];
649
		}
650

    
651
		if ($_POST['dnpipe'] != "") {
652
			$filterent['dnpipe'] = $_POST['dnpipe'];
653
			if ($_POST['pdnpipe'] != "")
654
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
655
		}
656

    
657
		if ($_POST['l7container'] != "") {
658
			$filterent['l7container'] = $_POST['l7container'];
659
		}
660

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

    
665
		if ($_POST['vlanprio'] != "") {
666
			$filterent['vlanprio'] = $_POST['vlanprio'];
667
		}
668
		if ($_POST['vlanprioset'] != "") {
669
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
670
		}
671

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

    
684
			$filterent['source'] = $a_filter[$id]['source'];
685
			$filterent['destination'] = $a_filter[$id]['destination'];
686
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
687
		}
688

    
689
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
690
			$filterent['created'] = $a_filter[$id]['created'];
691

    
692
		$filterent['updated'] = make_config_revision_entry();
693

    
694
		// Allow extending of the firewall edit page and include custom input validation
695
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
696

    
697
		if (isset($id) && $a_filter[$id])
698
			$a_filter[$id] = $filterent;
699
		else {
700
			$filterent['created'] = make_config_revision_entry();
701
			if (is_numeric($after))
702
				array_splice($a_filter, $after+1, 0, array($filterent));
703
			else
704
				$a_filter[] = $filterent;
705
		}
706

    
707
		filter_rules_sort();
708

    
709
		if (write_config())
710
			mark_subsystem_dirty('filter');
711

    
712
		if (isset($_POST['floating']))
713
			header("Location: firewall_rules.php?if=FloatingRules");
714
		else
715
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
716
		exit;
717
	}
718
}
719

    
720
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
721
$shortcut_section = "firewall";
722

    
723
$closehead = false;
724

    
725
$page_filename = "firewall_rules_edit.php";
726
include("head.inc");
727

    
728
?>
729
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
730
</head>
731

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

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

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

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

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

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

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

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

    
1683
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1684
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
1685

    
1686
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1687
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1688
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1689
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1690
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1691
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1692
//]]>
1693
</script>
1694
<?php include("fend.inc"); ?>
1695
</body>
1696
</html>
(70-70/246)