Projet

Général

Profil

Télécharger (78,7 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_rules_edit.php @ 2d1e985d

1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules_edit.php
5
	part of pfSense (https://www.pfsense.org)
6
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

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

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

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

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

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

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

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

    
48
function is_posnumericint($arg) {
49
	// Note that to be safe we do not allow any leading zero - "01", "007"
50
	return (is_numericint($arg) && $arg[0] != '0' && $arg > 0);
51
}
52

    
53
function is_aoadv_used($rule_config) {
54
	// Note that the user could set "tag" or "tagged" to the string "0", which is valid but empty().
55
	// And if the user enters "0" in other fields, we want to present an error message, and keep the Advanced Options section open.
56
	if ((isset($rule_config['allowopts'])) ||
57
	    (isset($rule_config['disablereplyto'])) ||
58
	    ($rule_config['tag'] != "") ||
59
	    ($rule_config['tagged'] != "") ||
60
	    ($rule_config['max'] != "") ||
61
	    ($rule_config['max-src-nodes'] != "") ||
62
	    ($rule_config['max-src-conn'] != "") ||
63
	    ($rule_config['max-src-states'] != "") ||
64
	    ($rule_config['max-src-conn-rate'] != "") ||
65
	    ($rule_config['max-src-conn-rates'] != "") ||
66
	    ($rule_config['statetimeout'] != ""))
67
		return true;
68
	return false;
69
}
70

    
71
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
72
$ifdisp = get_configured_interface_with_descr();
73
foreach ($ifdisp as $kif => $kdescr) {
74
	$specialsrcdst[] = "{$kif}";
75
	$specialsrcdst[] = "{$kif}ip";
76
}
77

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

    
84
if (is_numericint($_GET['id']))
85
	$id = $_GET['id'];
86
if (isset($_POST['id']) && is_numericint($_POST['id']))
87
	$id = $_POST['id'];
88

    
89
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
90
	$after = $_GET['after'];
91
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
92
	$after = $_POST['after'];
93

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
220
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
221
	unset($id);
222

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

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

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

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

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

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

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

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

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

    
337
	$pconfig = $_POST;
338

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
748
		filter_rules_sort();
749

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

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

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

    
764
$closehead = false;
765

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

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

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

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

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

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

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

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

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

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

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

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