Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
81
	if ( isset($a_filter[$id]['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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
313
	$pconfig = $_POST;
314

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

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

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

    
345
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
346

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

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

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

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

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

    
426
	}
427

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

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

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

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

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

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

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

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

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

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

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

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

    
589
		/* Nosync directive - do not xmlrpc sync this item */
590
		if($_POST['nosync'] <> "")
591
			$filterent['nosync'] = true;
592
		else
593
			unset($filterent['nosync']);
594

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

    
604
		if ($_POST['proto'] != "any")
605
			$filterent['protocol'] = $_POST['proto'];
606
		else
607
			unset($filterent['protocol']);
608

    
609
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
610
			$filterent['icmptype'] = $_POST['icmptype'];
611
		else
612
			unset($filterent['icmptype']);
613

    
614
		pconfig_to_address($filterent['source'], $_POST['src'],
615
			$_POST['srcmask'], $_POST['srcnot'],
616
			$_POST['srcbeginport'], $_POST['srcendport']);
617

    
618
		pconfig_to_address($filterent['destination'], $_POST['dst'],
619
			$_POST['dstmask'], $_POST['dstnot'],
620
			$_POST['dstbeginport'], $_POST['dstendport']);
621

    
622
		if ($_POST['disabled'])
623
			$filterent['disabled'] = true;
624
		else
625
			unset($filterent['disabled']);
626

    
627
		if ($_POST['dscp'])
628
			$filterent['dscp'] = $_POST['dscp'];
629

    
630
		if ($_POST['log'])
631
			$filterent['log'] = true;
632
		else
633
			unset($filterent['log']);
634
		strncpy($filterent['descr'], $_POST['descr'], 52);
635

    
636
		if ($_POST['gateway'] != "") {
637
			$filterent['gateway'] = $_POST['gateway'];
638
		}
639

    
640
		if ($_POST['defaultqueue'] != "") {
641
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
642
			if ($_POST['ackqueue'] != "")
643
				$filterent['ackqueue'] = $_POST['ackqueue'];
644
		}
645

    
646
		if ($_POST['dnpipe'] != "") {
647
			$filterent['dnpipe'] = $_POST['dnpipe'];
648
			if ($_POST['pdnpipe'] != "")
649
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
650
		}
651

    
652
		if ($_POST['l7container'] != "") {
653
			$filterent['l7container'] = $_POST['l7container'];
654
		}
655

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

    
660
		if ($_POST['vlanprio'] != "") {
661
			$filterent['vlanprio'] = $_POST['vlanprio'];
662
		}
663
		if ($_POST['vlanprioset'] != "") {
664
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
665
		}
666

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

    
679
			$filterent['source'] = $a_filter[$id]['source'];
680
			$filterent['destination'] = $a_filter[$id]['destination'];
681
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
682
		}
683

    
684
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
685
			$filterent['created'] = $a_filter[$id]['created'];
686

    
687
		$filterent['updated'] = make_config_revision_entry();
688

    
689
		// Allow extending of the firewall edit page and include custom input validation
690
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
691

    
692
		if (isset($id) && $a_filter[$id])
693
			$a_filter[$id] = $filterent;
694
		else {
695
			$filterent['created'] = make_config_revision_entry();
696
			if (is_numeric($after))
697
				array_splice($a_filter, $after+1, 0, array($filterent));
698
			else
699
				$a_filter[] = $filterent;
700
		}
701

    
702
		filter_rules_sort();
703

    
704
		if (write_config())
705
			mark_subsystem_dirty('filter');
706

    
707
		if (isset($_POST['floating']))
708
			header("Location: firewall_rules.php?if=FloatingRules");
709
		else
710
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
711
		exit;
712
	}
713
}
714

    
715
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
716
$shortcut_section = "firewall";
717

    
718
$closehead = false;
719

    
720
$page_filename = "firewall_rules_edit.php";
721
include("head.inc");
722

    
723
?>
724
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
725
</head>
726

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

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

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

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

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

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

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

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

    
1670
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1671
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
1672

    
1673
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1674
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1675
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1676
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1677
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1678
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1679
//]]>
1680
</script>
1681
<?php include("fend.inc"); ?>
1682
</body>
1683
</html>
(70-70/246)