Project

General

Profile

Download (76.3 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 ($_POST['proto'] <> "tcp") {
476
		if (!empty($_POST['max']))
477
			$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for TCP protocol.");
478
		if (!empty($_POST['max-src-nodes']))
479
			$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for TCP protocol.");
480
		if (!empty($_POST['max-src-conn']))
481
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
482
		if (!empty($_POST['max-src-states']))
483
			$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for TCP protocol.");
484
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
485
			$input_errors[] = gettext("You can only specify the maximum new connections / per second(s) (advanced option) for TCP protocol.");
486
		if (!empty($_POST['statetimeout']))
487
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
488
	}
489

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

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

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

    
533
	// Allow extending of the firewall edit page and include custom input validation
534
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
535

    
536
	if (!$input_errors) {
537
		$filterent = array();
538
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
539
		$filterent['type'] = $_POST['type'];
540
		if (isset($_POST['interface'] ))
541
			$filterent['interface'] = $_POST['interface'];
542

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
708
		filter_rules_sort();
709

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

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

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

    
724
$closehead = false;
725

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

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

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

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

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

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

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

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

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

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

    
1676
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1677
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
1678

    
1679
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1680
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1681
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1682
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1683
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1684
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1685
//]]>
1686
</script>
1687
<?php include("fend.inc"); ?>
1688
</body>
1689
</html>
(70-70/246)