Project

General

Profile

Download (75.8 KB) Statistics
| Branch: | Tag: | Revision:
1 5ba18897 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 bdb7d6e7 Scott Ullrich
	firewall_rules_edit.php
5 e4cabb75 Scott Ullrich
	part of pfSense (http://www.pfsense.com)
6 f8fee2ce Renato Botelho
	Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7 5ba18897 Scott Ullrich
8 e4cabb75 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
9 bdb7d6e7 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11 5ba18897 Scott Ullrich
12 bdb7d6e7 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14 5ba18897 Scott Ullrich
15 bdb7d6e7 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17 5ba18897 Scott Ullrich
18 bdb7d6e7 Scott Ullrich
	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 5ba18897 Scott Ullrich
22 bdb7d6e7 Scott Ullrich
	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 5b237745 Scott Ullrich
*/
33 7ac5a4cb Scott Ullrich
/*
34
	pfSense_MODULE:	filter
35
*/
36 5b237745 Scott Ullrich
37 6b07c15a Matthew Grooms
##|+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 5b237745 Scott Ullrich
require("guiconfig.inc");
45 b6239962 jim-p
require_once("filter.inc");
46 1a03cf69 Scott Ullrich
require("shaper.inc");
47 5b237745 Scott Ullrich
48 e5e5ba51 Vinicius Coque
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
49 3331a640 Ermal Lu?i
$ifdisp = get_configured_interface_with_descr();
50 679d21bb Ermal Lu?i
foreach ($ifdisp as $kif => $kdescr) {
51 3331a640 Ermal Lu?i
	$specialsrcdst[] = "{$kif}";
52
	$specialsrcdst[] = "{$kif}ip";
53 679d21bb Ermal Lu?i
}
54 5b237745 Scott Ullrich
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 5ba18897 Scott Ullrich
65 5b237745 Scott Ullrich
$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 5ba18897 Scott Ullrich
78 b9e28d57 unknown
	if (isset($a_filter[$id]['id']))
79
		$pconfig['ruleid'] = $a_filter[$id]['id'];
80
81 ba1d9714 jim-p
	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 5b237745 Scott Ullrich
	if (!isset($a_filter[$id]['type']))
88
		$pconfig['type'] = "pass";
89
	else
90
		$pconfig['type'] = $a_filter[$id]['type'];
91 5ba18897 Scott Ullrich
92 4633edc2 Ermal Luçi
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
93 661aed33 Ermal Luçi
		$pconfig['floating'] = $a_filter[$id]['floating'];
94 f8fee2ce Renato Botelho
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "")
95 661aed33 Ermal Luçi
			$pconfig['interface'] = $a_filter[$id]['interface'];
96
	}
97 f8fee2ce Renato Botelho
98
	if (isset($a_filter['floating']))
99 661aed33 Ermal Luçi
		$pconfig['floating'] = "yes";
100
101
	if (isset($a_filter[$id]['direction']))
102 f8fee2ce Renato Botelho
		$pconfig['direction'] = $a_filter[$id]['direction'];
103 661aed33 Ermal Luçi
104 1306c7dd Seth Mos
	if (isset($a_filter[$id]['ipprotocol']))
105 f8fee2ce Renato Botelho
		$pconfig['ipprotocol'] = $a_filter[$id]['ipprotocol'];
106 1306c7dd Seth Mos
107 5b237745 Scott Ullrich
	if (isset($a_filter[$id]['protocol']))
108
		$pconfig['proto'] = $a_filter[$id]['protocol'];
109
	else
110
		$pconfig['proto'] = "any";
111 5ba18897 Scott Ullrich
112 5b237745 Scott Ullrich
	if ($a_filter[$id]['protocol'] == "icmp")
113
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
114 5ba18897 Scott Ullrich
115 5b237745 Scott Ullrich
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
116
		$pconfig['srcmask'], $pconfig['srcnot'],
117
		$pconfig['srcbeginport'], $pconfig['srcendport']);
118 5ba18897 Scott Ullrich
119 8be60f21 Scott Ullrich
	if($a_filter[$id]['os'] <> "")
120
		$pconfig['os'] = $a_filter[$id]['os'];
121 e33c8694 Bill Marquette
122 5b237745 Scott Ullrich
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
123
		$pconfig['dstmask'], $pconfig['dstnot'],
124
		$pconfig['dstbeginport'], $pconfig['dstendport']);
125
126 c5fc1b2e Ermal Luçi
	if ($a_filter[$id]['dscp'] <> "")
127
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
128
129 5b237745 Scott Ullrich
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
130
	$pconfig['log'] = isset($a_filter[$id]['log']);
131
	$pconfig['descr'] = $a_filter[$id]['descr'];
132 8c84fe43 Scott Ullrich
133 b8ed2a11 Ermal
	if (isset($a_filter[$id]['tcpflags_any']))
134
		$pconfig['tcpflags_any'] = true;
135
	else {
136 f8fee2ce Renato Botelho
		if (isset($a_filter[$id]['tcpflags1']) && $a_filter[$id]['tcpflags1'] <> "")
137 b8ed2a11 Ermal
			$pconfig['tcpflags1'] = $a_filter[$id]['tcpflags1'];
138 f8fee2ce Renato Botelho
		if (isset($a_filter[$id]['tcpflags2']) && $a_filter[$id]['tcpflags2'] <> "")
139 b8ed2a11 Ermal
			$pconfig['tcpflags2'] = $a_filter[$id]['tcpflags2'];
140
	}
141
142 f8fee2ce Renato Botelho
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "")
143 661aed33 Ermal Luçi
		$pconfig['tag'] = $a_filter[$id]['tag'];
144 b6494651 Ermal Lu?i
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tagged'] <> "")
145 f8fee2ce Renato Botelho
		$pconfig['tagged'] = $a_filter[$id]['tagged'];
146 661aed33 Ermal Luçi
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
147
		$pconfig['quick'] = $a_filter[$id]['quick'];
148 775ccea3 Ermal Luci
	if (isset($a_filter[$id]['allowopts']))
149
		$pconfig['allowopts'] = true;
150 19757916 Ermal Lu?i
	if (isset($a_filter[$id]['disablereplyto']))
151
		$pconfig['disablereplyto'] = true;
152 661aed33 Ermal Luçi
153 ed08ef3e Scott Ullrich
	/* advanced */
154 a56b2fa0 pierrepomes
	$pconfig['max'] = $a_filter[$id]['max'];
155 f1c49ff4 Scott Ullrich
	$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
156 26dd6a54 pierrepomes
	$pconfig['max-src-conn'] = $a_filter[$id]['max-src-conn'];
157 f1c49ff4 Scott Ullrich
	$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
158
	$pconfig['statetype'] = $a_filter[$id]['statetype'];
159 5ba18897 Scott Ullrich
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
160 8c84fe43 Scott Ullrich
161 f1c49ff4 Scott Ullrich
	/* advanced - nosync */
162 8c84fe43 Scott Ullrich
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
163 10f21e70 Scott Ullrich
164 ed08ef3e Scott Ullrich
	/* 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 5ba18897 Scott Ullrich
168 e5980370 Scott Ullrich
	/* Multi-WAN next-hop support */
169 c98ddde2 Bill Marquette
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
170 f8fee2ce Renato Botelho
171 197bfe96 Ermal Luçi
	/* Shaper support */
172 7e2237f6 timdufrane
	$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 197bfe96 Ermal Luçi
178 615b27bc Scott Dale
	//schedule support
179 7e2237f6 timdufrane
	$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 35c9cd44 Erik Fonnesbeck
	if (!isset($_GET['dup']))
183
		$pconfig['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
184 c98ddde2 Bill Marquette
185 5b237745 Scott Ullrich
} else {
186
	/* defaults */
187 a23d7248 Scott Ullrich
	if ($_GET['if'])
188
		$pconfig['interface'] = $_GET['if'];
189 e5e5ba51 Vinicius Coque
	$pconfig['type'] = "pass";
190
	$pconfig['src'] = "any";
191
	$pconfig['dst'] = "any";
192 5b237745 Scott Ullrich
}
193 a133c803 Phil Davis
/* Allow the FloatingRules to work */
194 72320b88 Ermal Luçi
$if = $pconfig['interface'];
195 5b237745 Scott Ullrich
196
if (isset($_GET['dup']))
197
	unset($id);
198
199 85a236e9 Ermal
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 5b237745 Scott Ullrich
if ($_POST) {
207 99bdb17e Seth Mos
	unset($input_errors);
208 87f0be87 Chris Buechler
209 48a27d4f Erik Fonnesbeck
	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 99bdb17e Seth Mos
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
216 ee8c34f4 smos
		$a_gatewaygroups = return_gateway_groups_array();
217 a133c803 Phil Davis
		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 99bdb17e Seth Mos
				}
234
			}
235
		}
236
	}
237 9dfd60db Seth Mos
	if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "") && (is_ipaddr(lookup_gateway_ip_by_name($_POST['gateway'])))) {
238 05a4cebd smos
		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 99bdb17e Seth Mos
		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 05a4cebd smos
	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 5b237745 Scott Ullrich
	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 90f90934 Cristian Feldman
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
266 5b237745 Scott Ullrich
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
267 90f90934 Cristian Feldman
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
268 5b237745 Scott Ullrich
		if ($_POST['srcbeginport'] == "any") {
269
			$_POST['srcbeginport'] = 0;
270
			$_POST['srcendport'] = 0;
271 5ba18897 Scott Ullrich
		} else {
272 5b237745 Scott Ullrich
			if (!$_POST['srcendport'])
273
				$_POST['srcendport'] = $_POST['srcbeginport'];
274
		}
275
		if ($_POST['srcendport'] == "any")
276
			$_POST['srcendport'] = $_POST['srcbeginport'];
277 5ba18897 Scott Ullrich
278 5b237745 Scott Ullrich
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
279 90f90934 Cristian Feldman
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
280 5b237745 Scott Ullrich
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
281 90f90934 Cristian Feldman
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
282 5ba18897 Scott Ullrich
283 5b237745 Scott Ullrich
		if ($_POST['dstbeginport'] == "any") {
284
			$_POST['dstbeginport'] = 0;
285
			$_POST['dstendport'] = 0;
286 5ba18897 Scott Ullrich
		} else {
287 5b237745 Scott Ullrich
			if (!$_POST['dstendport'])
288
				$_POST['dstendport'] = $_POST['dstbeginport'];
289
		}
290
		if ($_POST['dstendport'] == "any")
291 5ba18897 Scott Ullrich
			$_POST['dstendport'] = $_POST['dstbeginport'];
292 5b237745 Scott Ullrich
	}
293 5ba18897 Scott Ullrich
294 5b237745 Scott Ullrich
	if (is_specialnet($_POST['srctype'])) {
295
		$_POST['src'] = $_POST['srctype'];
296
		$_POST['srcmask'] = 0;
297
	} else if ($_POST['srctype'] == "single") {
298 507aa90a Renato Botelho
		if (is_ipaddrv6($_POST['src']))
299
			$_POST['srcmask'] = 128;
300
		else
301
			$_POST['srcmask'] = 32;
302 5b237745 Scott Ullrich
	}
303
	if (is_specialnet($_POST['dsttype'])) {
304
		$_POST['dst'] = $_POST['dsttype'];
305
		$_POST['dstmask'] = 0;
306
	}  else if ($_POST['dsttype'] == "single") {
307 507aa90a Renato Botelho
		if (is_ipaddrv6($_POST['dst']))
308
			$_POST['dstmask'] = 128;
309
		else
310
			$_POST['dstmask'] = 32;
311 5b237745 Scott Ullrich
	}
312 5ba18897 Scott Ullrich
313 5b237745 Scott Ullrich
	$pconfig = $_POST;
314
315
	/* input validation */
316 1122a892 Erik Fonnesbeck
	$reqdfields = explode(" ", "type proto");
317
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
318 48a27d4f Erik Fonnesbeck
		$reqdfields[] = "src";
319
		$reqdfields[] = "dst";
320 1122a892 Erik Fonnesbeck
	}
321
	$reqdfieldsn = explode(",", "Type,Protocol");
322
	if ( isset($a_filter[$id]['associated-rule-id'])===false ) {
323
		$reqdfieldsn[] = "Source";
324 473d0ff0 pierrepomes
		$reqdfieldsn[] = "Destination";
325 1122a892 Erik Fonnesbeck
	}
326 5b237745 Scott Ullrich
327 452ade89 Bill Marquette
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
328 c22767b1 Bill Marquette
		if( $_POST['proto'] != "tcp" )
329 11d2c529 Rafael Lucas
			$input_errors[] = sprintf(gettext("%s is only valid with protocol tcp."),$_POST['statetype']);
330 452ade89 Bill Marquette
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
331 11d2c529 Rafael Lucas
			$input_errors[] = sprintf(gettext("%s is only valid if the gateway is set to 'default'."),$_POST['statetype']);
332 452ade89 Bill Marquette
	}
333 f8fee2ce Renato Botelho
334 1122a892 Erik Fonnesbeck
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
335
	(!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) ) {
336 5b237745 Scott Ullrich
		$reqdfields[] = "srcmask";
337
		$reqdfieldsn[] = "Source bit count";
338
	}
339 9b16b834 Ermal Lu?i
	if ( isset($a_filter[$id]['associated-rule-id'])===false &&
340 473d0ff0 pierrepomes
	(!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) ) {
341 5b237745 Scott Ullrich
		$reqdfields[] = "dstmask";
342 11d2c529 Rafael Lucas
		$reqdfieldsn[] = gettext("Destination bit count");
343 5b237745 Scott Ullrich
	}
344 5ba18897 Scott Ullrich
345 5b237745 Scott Ullrich
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
346 5ba18897 Scott Ullrich
347 5b237745 Scott Ullrich
	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 5ba18897 Scott Ullrich
356 9b45f821 Ermal Lu?i
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
357 f8fee2ce Renato Botelho
		$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 90f90934 Cristian Feldman
	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 5909b520 Evgeny Yurchenko
	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 f8fee2ce Renato Botelho
		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 5909b520 Evgeny Yurchenko
			$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 f8fee2ce Renato Botelho
		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 5909b520 Evgeny Yurchenko
			$input_errors[] = 'You cannot specify numbers and port aliases at the same time in Destination port range from: and to: field';
383
	}
384 5ba18897 Scott Ullrich
385 90f90934 Cristian Feldman
	if ($_POST['src'])
386
		$_POST['src'] = trim($_POST['src']);
387
	if ($_POST['dst'])
388
		$_POST['dst'] = trim($_POST['dst']);
389
390 0e5ddcd9 Scott Ullrich
	/* if user enters an alias and selects "network" then disallow. */
391
	if($_POST['srctype'] == "network") {
392
		if(is_alias($_POST['src']))
393 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
394 0e5ddcd9 Scott Ullrich
	}
395
	if($_POST['dsttype'] == "network") {
396
		if(is_alias($_POST['dst']))
397 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You must specify single host or alias for alias entries.");
398 0e5ddcd9 Scott Ullrich
	}
399
400 5b237745 Scott Ullrich
	if (!is_specialnet($_POST['srctype'])) {
401 1e578a7f Ermal Lu?i
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
402 11d2c529 Rafael Lucas
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."),$_POST['src']);
403 5b237745 Scott Ullrich
		}
404
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
405 11d2c529 Rafael Lucas
			$input_errors[] = gettext("A valid source bit count must be specified.");
406 5b237745 Scott Ullrich
		}
407
	}
408
	if (!is_specialnet($_POST['dsttype'])) {
409 1e578a7f Ermal Lu?i
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
410 11d2c529 Rafael Lucas
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."),$_POST['dst']);
411 5b237745 Scott Ullrich
		}
412
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
413 11d2c529 Rafael Lucas
			$input_errors[] = gettext("A valid destination bit count must be specified.");
414 5b237745 Scott Ullrich
		}
415
	}
416 8c591d01 Seth Mos
	if((is_ipaddr($_POST['src']) && is_ipaddr($_POST['dst']))) {
417 270a2576 Seth Mos
		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 4108dee8 Seth Mos
		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 05a4cebd smos
		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 270a2576 Seth Mos
	}
427 5ba18897 Scott Ullrich
428 5b237745 Scott Ullrich
	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 e33c8694 Bill Marquette
	if ($_POST['os'])
441
		if( $_POST['proto'] != "tcp" )
442 11d2c529 Rafael Lucas
			$input_errors[] = gettext("OS detection is only valid with protocol tcp.");
443 5b237745 Scott Ullrich
444 7e2237f6 timdufrane
	if ($_POST['ackqueue'] != "") {
445
		if ($_POST['defaultqueue'] == "" )
446 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You have to select a queue when you select an acknowledge queue too.");
447 197bfe96 Ermal Luçi
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
448 f8fee2ce Renato Botelho
			$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
449 197bfe96 Ermal Luçi
	}
450 7e2237f6 timdufrane
	if (isset($_POST['floating']) && $_POST['pdnpipe'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
451 02d7e4a4 Ermal
		$input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
452 622bd5e7 Ermal
	if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
453 37d202a3 Ermal
		$input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
454 7e2237f6 timdufrane
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "") {
455
		if ($_POST['dnpipe'] == "" )
456 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
457 a5fd67e1 Ermal Luçi
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
458 11d2c529 Rafael Lucas
			$input_errors[] = gettext("In and Out Queue cannot be the same.");
459 85a236e9 Ermal
		else if ($dnqlist[$_POST['pdnpipe']][0] == "?" && $dnqlist[$_POST['dnpipe']][0] <> "?")
460 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
461 f8fee2ce Renato Botelho
		else if ($dnqlist[$_POST['dnpipe']][0] == "?" && $dnqlist[$_POST['pdnpipe']][0] <> "?")
462 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.");
463 fbc75dd5 Ermal
		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 a5fd67e1 Ermal Luçi
	}
466 b9e28d57 unknown
	if( !empty($_POST['ruleid']) && !ctype_digit($_POST['ruleid']))
467 11d2c529 Rafael Lucas
		$input_errors[] = gettext('ID must be an integer');
468 7e2237f6 timdufrane
	if($_POST['l7container'] && $_POST['l7container'] != "") {
469 7e50413c Ermal Luçi
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
470 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You can only select a layer7 container for TCP and/or UDP protocols");
471 3b184ca5 Ermal Lu?i
		if ($_POST['type'] <> "pass")
472 11d2c529 Rafael Lucas
			$input_errors[] = gettext("You can only select a layer7 container for Pass type rules.");
473 7e50413c Ermal Luçi
	}
474 197bfe96 Ermal Luçi
475 98f4043e Phil Davis
	if (!in_array($_POST['proto'], array("tcp","tcp/udp"))) {
476 69364ab8 Phil Davis
		if (!empty($_POST['max-src-conn']))
477
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for TCP protocol.");
478
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
479
			$input_errors[] = gettext("You can only specify the maximum new connections / per second(s) (advanced option) for TCP protocol.");
480
		if (!empty($_POST['statetimeout']))
481
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for TCP protocol.");
482
	}
483
484
	if ($_POST['type'] <> "pass") {
485
		if (!empty($_POST['max']))
486
			$input_errors[] = gettext("You can only specify the maximum state entries (advanced option) for Pass type rules.");
487
		if (!empty($_POST['max-src-nodes']))
488
			$input_errors[] = gettext("You can only specify the maximum number of unique source hosts (advanced option) for Pass type rules.");
489
		if (!empty($_POST['max-src-conn']))
490
			$input_errors[] = gettext("You can only specify the maximum number of established connections per host (advanced option) for Pass type rules.");
491
		if (!empty($_POST['max-src-states']))
492
			$input_errors[] = gettext("You can only specify the maximum state entries per host (advanced option) for Pass type rules.");
493
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
494
			$input_errors[] = gettext("You can only specify the maximum new connections / per second(s) (advanced option) for Pass type rules.");
495
		if (!empty($_POST['statetimeout']))
496
			$input_errors[] = gettext("You can only specify the state timeout (advanced option) for Pass type rules.");
497
	}
498
499
	if (($_POST['statetype'] == "none") && (empty($_POST['l7container']))) {
500
		if (!empty($_POST['max']))
501
			$input_errors[] = gettext("You cannot specify the maximum state entries (advanced option) if statetype is none and no L7 container is selected.");
502
		if (!empty($_POST['max-src-nodes']))
503
			$input_errors[] = gettext("You cannot specify the maximum number of unique source hosts (advanced option) if statetype is none and no L7 container is selected.");
504
		if (!empty($_POST['max-src-conn']))
505
			$input_errors[] = gettext("You cannot specify the maximum number of established connections per host (advanced option) if statetype is none and no L7 container is selected.");
506
		if (!empty($_POST['max-src-states']))
507
			$input_errors[] = gettext("You cannot specify the maximum state entries per host (advanced option) if statetype is none and no L7 container is selected.");
508
		if (!empty($_POST['max-src-conn-rate']) || !empty($_POST['max-src-conn-rates']))
509
			$input_errors[] = gettext("You cannot specify the maximum new connections / per second(s) (advanced option) if statetype is none and no L7 container is selected.");
510
		if (!empty($_POST['statetimeout']))
511
			$input_errors[] = gettext("You cannot specify the state timeout (advanced option) if statetype is none and no L7 container is selected.");
512
	}
513
514 b8ed2a11 Ermal
	if (!$_POST['tcpflags_any']) {
515
		$settcpflags = array();
516
		$outoftcpflags = array();
517
		foreach ($tcpflags as $tcpflag) {
518
			if ($_POST['tcpflags1_' . $tcpflag] == "on")
519
				$settcpflags[] = $tcpflag;
520
			if ($_POST['tcpflags2_' . $tcpflag] == "on")
521
				$outoftcpflags[] = $tcpflag;
522
		}
523
		if (empty($outoftcpflags) && !empty($settcpflags))
524 11d2c529 Rafael Lucas
			$input_errors[] = gettext("If you specify TCP flags that should be set you should specify out of which flags as well.");
525 b8ed2a11 Ermal
	}
526
527 f8fee2ce Renato Botelho
	// Allow extending of the firewall edit page and include custom input validation
528 d65962a7 Scott Ullrich
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/input_validation");
529
530 5b237745 Scott Ullrich
	if (!$input_errors) {
531
		$filterent = array();
532 b9e28d57 unknown
		$filterent['id'] = $_POST['ruleid']>0?$_POST['ruleid']:'';
533 5b237745 Scott Ullrich
		$filterent['type'] = $_POST['type'];
534 661aed33 Ermal Luçi
		if (isset($_POST['interface'] ))
535
			$filterent['interface'] = $_POST['interface'];
536
537 1306c7dd Seth Mos
		if (isset($_POST['ipprotocol'] ))
538
			$filterent['ipprotocol'] = $_POST['ipprotocol'];
539
540 b8ed2a11 Ermal
		if ($_POST['tcpflags_any']) {
541
			$filterent['tcpflags_any'] = true;
542
		} else {
543
			$settcpflags = array();
544
			$outoftcpflags = array();
545
			foreach ($tcpflags as $tcpflag) {
546
				if ($_POST['tcpflags1_' . $tcpflag] == "on")
547
					$settcpflags[] = $tcpflag;
548
				if ($_POST['tcpflags2_' . $tcpflag] == "on")
549
					$outoftcpflags[] = $tcpflag;
550
			}
551
			if (!empty($outoftcpflags)) {
552
				$filterent['tcpflags2'] = join(",", $outoftcpflags);
553
				if (!empty($settcpflags))
554
					$filterent['tcpflags1'] = join(",", $settcpflags);
555
			}
556
		}
557
558 fd9ba7c0 Ermal
		if (isset($_POST['tag']))
559
			$filterent['tag'] = $_POST['tag'];
560
		if (isset($_POST['tagged']))
561
			$filterent['tagged'] = $_POST['tagged'];
562 661aed33 Ermal Luçi
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
563
			$filterent['direction'] = $_POST['direction'];
564
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
565
				$filterent['quick'] = $_POST['quick'];
566
			$filterent['floating'] = "yes";
567
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
568 f1602cc4 sullrich
				$filterent['interface'] = implode(",", $_POST['interface']);
569 661aed33 Ermal Luçi
			}
570
		}
571 d59874c1 Scott Ullrich
572 bdb7d6e7 Scott Ullrich
		/* Advanced options */
573 775ccea3 Ermal Luci
		if ($_POST['allowopts'] == "yes")
574
			$filterent['allowopts'] = true;
575
		else
576
			unset($filterent['allowopts']);
577 19757916 Ermal Lu?i
		if ($_POST['disablereplyto'] == "yes")
578
			$filterent['disablereplyto'] = true;
579
		else
580
			unset($filterent['disablereplyto']);
581 a56b2fa0 pierrepomes
		$filterent['max'] = $_POST['max'];
582 bdb7d6e7 Scott Ullrich
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
583 26dd6a54 pierrepomes
		$filterent['max-src-conn'] = $_POST['max-src-conn'];
584 bdb7d6e7 Scott Ullrich
		$filterent['max-src-states'] = $_POST['max-src-states'];
585 5ba18897 Scott Ullrich
		$filterent['statetimeout'] = $_POST['statetimeout'];
586 fa9af164 Scott Ullrich
		$filterent['statetype'] = $_POST['statetype'];
587 e33c8694 Bill Marquette
		$filterent['os'] = $_POST['os'];
588 10f21e70 Scott Ullrich
589
		/* Nosync directive - do not xmlrpc sync this item */
590 8c84fe43 Scott Ullrich
		if($_POST['nosync'] <> "")
591 10f21e70 Scott Ullrich
			$filterent['nosync'] = true;
592
		else
593
			unset($filterent['nosync']);
594
595 3f00c1dc Scott Ullrich
		/* unless both values are provided, unset the values - ticket #650 */
596
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
597
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
598
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
599
		} else {
600
			unset($filterent['max-src-conn-rate']);
601
			unset($filterent['max-src-conn-rates']);
602
		}
603 5ba18897 Scott Ullrich
604 5b237745 Scott Ullrich
		if ($_POST['proto'] != "any")
605
			$filterent['protocol'] = $_POST['proto'];
606
		else
607
			unset($filterent['protocol']);
608 5ba18897 Scott Ullrich
609 5b237745 Scott Ullrich
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
610
			$filterent['icmptype'] = $_POST['icmptype'];
611
		else
612
			unset($filterent['icmptype']);
613 5ba18897 Scott Ullrich
614 5b237745 Scott Ullrich
		pconfig_to_address($filterent['source'], $_POST['src'],
615
			$_POST['srcmask'], $_POST['srcnot'],
616
			$_POST['srcbeginport'], $_POST['srcendport']);
617 5ba18897 Scott Ullrich
618 5b237745 Scott Ullrich
		pconfig_to_address($filterent['destination'], $_POST['dst'],
619
			$_POST['dstmask'], $_POST['dstnot'],
620
			$_POST['dstbeginport'], $_POST['dstendport']);
621 5ba18897 Scott Ullrich
622 f1602cc4 sullrich
		if ($_POST['disabled'])
623
			$filterent['disabled'] = true;
624
		else
625
			unset($filterent['disabled']);
626
627 c5fc1b2e Ermal Luçi
		if ($_POST['dscp'])
628
			$filterent['dscp'] = $_POST['dscp'];
629
630 f1602cc4 sullrich
		if ($_POST['log'])
631
			$filterent['log'] = true;
632
		else
633
			unset($filterent['log']);
634 c68fc1e7 Bill Marquette
		strncpy($filterent['descr'], $_POST['descr'], 52);
635 5ba18897 Scott Ullrich
636 c98ddde2 Bill Marquette
		if ($_POST['gateway'] != "") {
637
			$filterent['gateway'] = $_POST['gateway'];
638
		}
639 f8fee2ce Renato Botelho
640 7e2237f6 timdufrane
		if ($_POST['defaultqueue'] != "") {
641 197bfe96 Ermal Luçi
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
642 7e2237f6 timdufrane
			if ($_POST['ackqueue'] != "")
643 197bfe96 Ermal Luçi
				$filterent['ackqueue'] = $_POST['ackqueue'];
644
		}
645 c98ddde2 Bill Marquette
646 7e2237f6 timdufrane
		if ($_POST['dnpipe'] != "") {
647 a5fd67e1 Ermal Luçi
			$filterent['dnpipe'] = $_POST['dnpipe'];
648 7e2237f6 timdufrane
			if ($_POST['pdnpipe'] != "")
649 a5fd67e1 Ermal Luçi
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
650
		}
651
652 7e2237f6 timdufrane
		if ($_POST['l7container'] != "") {
653 7e50413c Ermal Luçi
			$filterent['l7container'] = $_POST['l7container'];
654
		}
655 f8fee2ce Renato Botelho
656 615b27bc Scott Dale
		if ($_POST['sched'] != "") {
657
			$filterent['sched'] = $_POST['sched'];
658
		}
659
660 1346306c Ermal
		if ($_POST['vlanprio'] != "") {
661
			$filterent['vlanprio'] = $_POST['vlanprio'];
662
		}
663
		if ($_POST['vlanprioset'] != "") {
664
			$filterent['vlanprioset'] = $_POST['vlanprioset'];
665
		}
666
667 1122a892 Erik Fonnesbeck
		// If we have an associated nat rule, make sure the source and destination doesn't change
668 9b16b834 Ermal Lu?i
		if( isset($a_filter[$id]['associated-rule-id']) ) {
669 0bfd0f79 Erik Fonnesbeck
			$filterent['interface'] = $a_filter[$id]['interface'];
670 48a27d4f Erik Fonnesbeck
			if (isset($a_filter[$id]['protocol']))
671
				$filterent['protocol'] = $a_filter[$id]['protocol'];
672
			else if (isset($filterent['protocol']))
673
				unset($filterent['protocol']);
674
			if ($a_filter[$id]['protocol'] == "icmp" && $a_filter[$id]['icmptype'])
675
				$filterent['icmptype'] = $a_filter[$id]['icmptype'];
676
			else if (isset($filterent['icmptype']))
677
				unset($filterent['icmptype']);
678 1306c7dd Seth Mos
679 1122a892 Erik Fonnesbeck
			$filterent['source'] = $a_filter[$id]['source'];
680 473d0ff0 pierrepomes
			$filterent['destination'] = $a_filter[$id]['destination'];
681 9b16b834 Ermal Lu?i
			$filterent['associated-rule-id'] = $a_filter[$id]['associated-rule-id'];
682 473d0ff0 pierrepomes
		}
683
684 ba1d9714 jim-p
		if ( isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']) )
685
			$filterent['created'] = $a_filter[$id]['created'];
686
687
		$filterent['updated'] = make_config_revision_entry();
688
689 f8fee2ce Renato Botelho
		// Allow extending of the firewall edit page and include custom input validation
690 2ea00c3e Scott Ullrich
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_write_config");
691
692 5b237745 Scott Ullrich
		if (isset($id) && $a_filter[$id])
693
			$a_filter[$id] = $filterent;
694
		else {
695 ba1d9714 jim-p
			$filterent['created'] = make_config_revision_entry();
696 5b237745 Scott Ullrich
			if (is_numeric($after))
697
				array_splice($a_filter, $after+1, 0, array($filterent));
698
			else
699
				$a_filter[] = $filterent;
700
		}
701 f4e2a352 Scott Ullrich
702 ea57ccb8 Erik Fonnesbeck
		filter_rules_sort();
703 d65962a7 Scott Ullrich
704 3a343d73 jim-p
		if (write_config())
705 bec92ab9 jim-p
			mark_subsystem_dirty('filter');
706 5ba18897 Scott Ullrich
707 661aed33 Ermal Luçi
		if (isset($_POST['floating']))
708
			header("Location: firewall_rules.php?if=FloatingRules");
709
		else
710 bb33a337 jim-p
			header("Location: firewall_rules.php?if=" . htmlspecialchars($_POST['interface']));
711 5b237745 Scott Ullrich
		exit;
712
	}
713 c60824d2 Scott Ullrich
}
714
715 11d2c529 Rafael Lucas
$pgtitle = array(gettext("Firewall"),gettext("Rules"),gettext("Edit"));
716 b32dd0a6 jim-p
$shortcut_section = "firewall";
717 3cceb5d5 jim-p
718 a1357fe0 Bill Marquette
$closehead = false;
719 8ab3e9ed Erik Kristensen
720
$page_filename = "firewall_rules_edit.php";
721 da7ae7ef Bill Marquette
include("head.inc");
722 c60824d2 Scott Ullrich
723 5b237745 Scott Ullrich
?>
724 4bb99603 Scott Ullrich
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
725 5b237745 Scott Ullrich
</head>
726
727
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
728 f51d5d57 Darren Embry
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js"></script>
729 6134cc8f Vinicius Coque
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
730 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
731 48fc39a3 Scott Ullrich
<?php pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_input_errors"); ?>
732 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
733 8ab3e9ed Erik Kristensen
734
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
735 4143e7fb Colin Fleming
<input type='hidden' name="ruleid" value="<?=(isset($pconfig['ruleid'])&&$pconfig['ruleid']>0)?htmlspecialchars($pconfig['ruleid']):''?>" />
736 6eac9b90 Scott Ullrich
737 4143e7fb Colin Fleming
	<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall rules edit">
738 e091cb45 Scott Ullrich
		<tr>
739 11d2c529 Rafael Lucas
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Firewall rule");?></td>
740 f8fee2ce Renato Botelho
		</tr>
741 b4b7bda6 Scott Ullrich
<?php
742 f8fee2ce Renato Botelho
		// Allow extending of the firewall edit page and include custom input validation
743 b4b7bda6 Scott Ullrich
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphpearly");
744
?>
745 f8fee2ce Renato Botelho
		<tr>
746 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Action");?></td>
747 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
748 b5c78501 Seth Mos
				<select name="type" class="formselect">
749 e5e5ba51 Vinicius Coque
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
750 4143e7fb Colin Fleming
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>
751 8ab3e9ed Erik Kristensen
					<?=htmlspecialchars($type);?>
752
					</option>
753
					<?php endforeach; ?>
754 a391d0ab Ermal
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
755 4143e7fb Colin Fleming
					<option value="match" <?php if ("match" == strtolower($pconfig['type'])) echo "selected=\"selected\""; ?>>Match</option>
756 a391d0ab Ermal
<?php endif; ?>
757 8c84fe43 Scott Ullrich
				</select>
758 8ab3e9ed Erik Kristensen
				<br/>
759
				<span class="vexpl">
760 11d2c529 Rafael Lucas
					<?=gettext("Choose what to do with packets that match the criteria specified below.");?> <br/>
761 f8fee2ce Renato Botelho
					<?=gettext("Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded.");?>
762 8ab3e9ed Erik Kristensen
				</span>
763
			</td>
764
		</tr>
765
		<tr>
766 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
767 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
768 4143e7fb Colin Fleming
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
769 11d2c529 Rafael Lucas
				<strong><?=gettext("Disable this rule");?></strong><br />
770
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list.");?></span>
771 8ab3e9ed Erik Kristensen
			</td>
772
		</tr>
773 661aed33 Ermal Luçi
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
774
		<tr>
775 f1602cc4 sullrich
			<td width="22%" valign="top" class="vncellreq">
776
				<?=gettext("Quick");?>
777
			</td>
778
			<td width="78%" class="vtable">
779
				<input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
780
				<strong><?=gettext("Apply the action immediately on match.");?></strong><br />
781
				<span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
782
			</td>
783
		</tr>
784 e73b001e Renato Botelho
<?php endif; ?>
785 48a27d4f Erik Fonnesbeck
<?php $edit_disabled = ""; ?>
786
<?php if( isset($pconfig['associated-rule-id']) ): ?>
787
		<tr>
788
			<td width="22%" valign="top" class="vncell"><?=gettext("Associated filter rule");?></td>
789
			<td width="78%" class="vtable">
790 e4b9d53b Warren Baker
				<span class="red"><strong><?=gettext("Note: ");?></strong></span><?=gettext("This is associated to a NAT rule.");?><br />
791 48a27d4f Erik Fonnesbeck
				<?=gettext("You cannot edit the interface, protocol, source, or destination of associated filter rules.");?><br />
792
				<br />
793
				<?php
794
					$edit_disabled = "disabled";
795
					if (is_array($config['nat']['rule'])) {
796
						foreach( $config['nat']['rule'] as $index => $nat_rule ) {
797
							if( isset($nat_rule['associated-rule-id']) && $nat_rule['associated-rule-id']==$pconfig['associated-rule-id'] ) {
798 4143e7fb Colin Fleming
								echo "<a href=\"firewall_nat_edit.php?id={$index}\">" . gettext("View the NAT rule") . "</a><br/>";
799 48a27d4f Erik Fonnesbeck
								break;
800
							}
801
						}
802
					}
803 4143e7fb Colin Fleming
					echo "<input name='associated-rule-id' id='associated-rule-id' type='hidden' value='{$pconfig['associated-rule-id']}' />";
804 48a27d4f Erik Fonnesbeck
					if (!empty($pconfig['interface']))
805 4143e7fb Colin Fleming
						echo "<input name='interface' id='interface' type='hidden' value='{$pconfig['interface']}' />";
806 48a27d4f Erik Fonnesbeck
				?>
807
				<script type="text/javascript">
808
				editenabled = 0;
809
				</script>
810
			</td>
811
		</tr>
812 ee9933b6 Renato Botelho
<?php endif; ?>
813 8ab3e9ed Erik Kristensen
		<tr>
814 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface");?></td>
815 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
816 48a27d4f Erik Fonnesbeck
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
817 4143e7fb Colin Fleming
				<select name="interface[]" title="Select interfaces..." multiple="multiple" style="width:350px;" class="chzn-select" tabindex="2" <?=$edit_disabled;?>>
818 ee9933b6 Renato Botelho
<?php else: ?>
819 48a27d4f Erik Fonnesbeck
				<select name="interface" class="formselect" <?=$edit_disabled;?>>
820 f8fee2ce Renato Botelho
<?php endif;
821 a7782099 Ermal Lu?i
				/* add group interfaces */
822 f1602cc4 sullrich
				if (is_array($config['ifgroups']['ifgroupentry']))
823 a7782099 Ermal Lu?i
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
824
						if (have_ruleint_access($ifgen['ifname']))
825
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
826 b7391125 Ermal Luçi
				$ifdescs = get_configured_interface_with_descr();
827 f8fee2ce Renato Botelho
				// Allow extending of the firewall edit page and include custom input validation
828 0040bcfa Scott Ullrich
				pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/pre_interfaces_edit");
829 5335811d Ermal Luçi
				foreach ($ifdescs as $ifent => $ifdesc)
830 0040bcfa Scott Ullrich
					if(have_ruleint_access($ifent))
831 f1602cc4 sullrich
							$interfaces[$ifent] = $ifdesc;
832 617f8d25 Ermal Lu?i
					if ($config['l2tp']['mode'] == "server")
833 f1602cc4 sullrich
						if(have_ruleint_access("l2tp"))
834
							$interfaces['l2tp'] = "L2TP VPN";
835 b6742927 Scott Ullrich
					if ($config['pptpd']['mode'] == "server")
836 f8fee2ce Renato Botelho
						if(have_ruleint_access("pptp"))
837 b6742927 Scott Ullrich
							$interfaces['pptp'] = "PPTP VPN";
838 f8fee2ce Renato Botelho
839 93c2c1e6 jim-p
					if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
840
						$interfaces['pppoe'] = "PPPoE VPN";
841 b6742927 Scott Ullrich
					/* add ipsec interfaces */
842 c6dfd289 jim-p
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
843 f8fee2ce Renato Botelho
						if(have_ruleint_access("enc0"))
844 0f266b2e Chris Buechler
							$interfaces["enc0"] = "IPsec";
845 bfb60ac8 Ermal Luçi
					/* add openvpn/tun interfaces */
846 d799787e Matthew Grooms
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
847 d030c9de Erik Fonnesbeck
						$interfaces["openvpn"] = "OpenVPN";
848 43fd29df Erik Fonnesbeck
					if (is_array($pconfig['interface']))
849
						$pconfig['interface'] = implode(",", $pconfig['interface']);
850 d030c9de Erik Fonnesbeck
					$selected_interfaces = explode(",", $pconfig['interface']);
851 8ab3e9ed Erik Kristensen
					foreach ($interfaces as $iface => $ifacename): ?>
852 4143e7fb Colin Fleming
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && ( strcasecmp($pconfig['interface'], $iface) == 0 || in_array($iface, $selected_interfaces) )) echo "selected=\"selected\""; ?>><?=$ifacename?></option>
853 8ab3e9ed Erik Kristensen
<?php 				endforeach; ?>
854 8c84fe43 Scott Ullrich
				</select>
855 8ab3e9ed Erik Kristensen
				<br />
856 11d2c529 Rafael Lucas
				<span class="vexpl"><?=gettext("Choose on which interface packets must come in to match this rule.");?></span>
857 8ab3e9ed Erik Kristensen
			</td>
858
		</tr>
859 661aed33 Ermal Luçi
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
860 f1602cc4 sullrich
		<tr>
861
			<td width="22%" valign="top" class="vncellreq">
862
				<?=gettext("Direction");?>
863
			</td>
864
			<td width="78%" class="vtable">
865
				<select name="direction" class="formselect">
866 e5e5ba51 Vinicius Coque
					<?php      $directions = array('any','in','out');
867 f1602cc4 sullrich
				foreach ($directions as $direction): ?>
868
				<option value="<?=$direction;?>"
869
					<?php if ($direction == $pconfig['direction']): ?>
870 f8fee2ce Renato Botelho
						selected="selected"
871 f1602cc4 sullrich
					<?php endif; ?>
872
					><?=$direction;?></option>
873 f8fee2ce Renato Botelho
				<?php endforeach; ?>
874 f1602cc4 sullrich
				</select>
875 4143e7fb Colin Fleming
				<input type="hidden" id="floating" name="floating" value="floating" />
876 f1602cc4 sullrich
			</td>
877
		<tr>
878 661aed33 Ermal Luçi
<?php endif; ?>
879 1306c7dd Seth Mos
		<tr>
880
			<td width="22%" valign="top" class="vncellreq"><?=gettext("TCP/IP Version");?></td>
881
			<td width="78%" class="vtable">
882
				<select name="ipprotocol" class="formselect">
883 05a4cebd smos
					<?php      $ipproto = array('inet' => 'IPv4','inet6' => 'IPv6', 'inet46' => 'IPv4+IPv6' );
884 1306c7dd Seth Mos
				foreach ($ipproto as $proto => $name): ?>
885
				<option value="<?=$proto;?>"
886
					<?php if ($proto == $pconfig['ipprotocol']): ?>
887 f8fee2ce Renato Botelho
						selected="selected"
888 1306c7dd Seth Mos
					<?php endif; ?>
889
					><?=$name;?></option>
890 f8fee2ce Renato Botelho
				<?php endforeach; ?>
891 1306c7dd Seth Mos
				</select>
892
				<strong><?=gettext("Select the Internet Protocol version this rule applies to");?></strong><br />
893
			</td>
894
		</tr>
895 8ab3e9ed Erik Kristensen
		<tr>
896 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
897 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
898 48a27d4f Erik Fonnesbeck
				<select <?=$edit_disabled;?> name="proto" class="formselect" onchange="proto_change()">
899 8ab3e9ed Erik Kristensen
<?php
900 26f80aff Daniel Becker
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP OSPF any carp pfsync");
901 8ab3e9ed Erik Kristensen
				foreach ($protocols as $proto): ?>
902 4143e7fb Colin Fleming
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
903 8ab3e9ed Erik Kristensen
<?php 			endforeach; ?>
904
				</select>
905
				<br />
906 11d2c529 Rafael Lucas
				<span class="vexpl"><?=gettext("Choose which IP protocol this rule should match.");?> <br /> <?=gettext("Hint: in most cases, you should specify ");?><em>TCP</em> &nbsp;<?=gettext("here.");?></span>
907 8ab3e9ed Erik Kristensen
			</td>
908
		</tr>
909 4143e7fb Colin Fleming
		<tr id="icmpbox">
910 11d2c529 Rafael Lucas
			<td valign="top" class="vncell"><?=gettext("ICMP type");?></td>
911 8ab3e9ed Erik Kristensen
			<td class="vtable">
912 48a27d4f Erik Fonnesbeck
				<select <?=$edit_disabled;?> name="icmptype" class="formselect">
913 8ab3e9ed Erik Kristensen
<?php
914
				$icmptypes = array(
915 abd67a31 Carlos Eduardo Ramos
				"" => gettext("any"),
916 a01ce4c7 jim-p
				"echoreq" => gettext("Echo request"),
917 abd67a31 Carlos Eduardo Ramos
				"echorep" => gettext("Echo reply"),
918
				"unreach" => gettext("Destination unreachable"),
919
				"squench" => gettext("Source quench"),
920
				"redir" => gettext("Redirect"),
921
				"althost" => gettext("Alternate Host"),
922
				"routeradv" => gettext("Router advertisement"),
923
				"routersol" => gettext("Router solicitation"),
924
				"timex" => gettext("Time exceeded"),
925
				"paramprob" => gettext("Invalid IP header"),
926
				"timereq" => gettext("Timestamp"),
927
				"timerep" => gettext("Timestamp reply"),
928
				"inforeq" => gettext("Information request"),
929
				"inforep" => gettext("Information reply"),
930
				"maskreq" => gettext("Address mask request"),
931
				"maskrep" => gettext("Address mask reply")
932 8ab3e9ed Erik Kristensen
				);
933
934
				foreach ($icmptypes as $icmptype => $descr): ?>
935 4143e7fb Colin Fleming
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
936 8ab3e9ed Erik Kristensen
<?php 			endforeach; ?>
937
			</select>
938
			<br />
939 11d2c529 Rafael Lucas
			<span class="vexpl"><?=gettext("If you selected ICMP for the protocol above, you may specify an ICMP type here.");?></span>
940 8ab3e9ed Erik Kristensen
		</td>
941
		</tr>
942
		<tr>
943 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source");?></td>
944 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
945 4143e7fb Colin Fleming
				<input <?=$edit_disabled;?> name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
946 11d2c529 Rafael Lucas
				<strong><?=gettext("not");?></strong>
947 8ab3e9ed Erik Kristensen
				<br />
948 11d2c529 Rafael Lucas
				<?=gettext("Use this option to invert the sense of the match.");?>
949 8ab3e9ed Erik Kristensen
				<br />
950
				<br />
951
				<table border="0" cellspacing="0" cellpadding="0">
952
					<tr>
953 21600ab1 Vinicius Coque
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
954 8ab3e9ed Erik Kristensen
						<td>
955 4143e7fb Colin Fleming
							<select <?=$edit_disabled;?> name="srctype" class="formselect" onchange="typesel_change()">
956 87f0be87 Chris Buechler
<?php
957
								$sel = is_specialnet($pconfig['src']); ?>
958 4143e7fb Colin Fleming
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
959 72f25519 Ermal
								<option value="single"
960
						<?php  if (!$sel &&
961
							    ((is_ipaddrv6($pconfig['src']) && $pconfig['srcmask'] == 128) ||
962
							    (is_ipaddrv4($pconfig['src']) && $pconfig['srcmask'] == 32) || is_alias($pconfig['src'])))
963 f8fee2ce Renato Botelho
								{ echo "selected=\"selected\""; $sel = 1; }
964 72f25519 Ermal
						?>
965
								> <?=gettext("Single host or alias");?></option>
966 4143e7fb Colin Fleming
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
967 99ea4439 Scott Ullrich
								<?php if(have_ruleint_access("pptp")): ?>
968 4143e7fb Colin Fleming
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
969 99ea4439 Scott Ullrich
								<?php endif; ?>
970
								<?php if(have_ruleint_access("pppoe")): ?>
971 4143e7fb Colin Fleming
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
972 f8fee2ce Renato Botelho
								<?php endif; ?>
973
								<?php if(have_ruleint_access("l2tp")): ?>
974
								<option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
975
								<?php endif; ?>
976 8ab3e9ed Erik Kristensen
<?php
977 5335811d Ermal Luçi
								foreach ($ifdisp as $ifent => $ifdesc): ?>
978
								<?php if(have_ruleint_access($ifent)): ?>
979 4143e7fb Colin Fleming
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?><?=gettext(" subnet");?></option>
980
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
981 11d2c529 Rafael Lucas
										<?=$ifdesc?> <?=gettext("address");?>
982 e30a5970 Scott Ullrich
									</option>
983 99ea4439 Scott Ullrich
								<?php endif; ?>
984 b7391125 Ermal Luçi
<?php 							endforeach; ?>
985 8ab3e9ed Erik Kristensen
							</select>
986
						</td>
987
					</tr>
988
					<tr>
989 21600ab1 Vinicius Coque
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
990 8ab3e9ed Erik Kristensen
						<td>
991 4143e7fb Colin Fleming
							<input <?=$edit_disabled;?> autocomplete='off' name="src" type="text" class="formfldalias ipv4v6" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
992 979b179d Darren Embry
							<select <?=$edit_disabled;?> name="srcmask" class="formselect ipv4v6" id="srcmask">
993 15705bc0 Seth Mos
<?php						for ($i = 127; $i > 0; $i--): ?>
994 4143e7fb Colin Fleming
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
995 8ab3e9ed Erik Kristensen
<?php 						endfor; ?>
996
							</select>
997 bdb7d6e7 Scott Ullrich
						</td>
998 8ab3e9ed Erik Kristensen
					</tr>
999
				</table>
1000 22abf2ef Scott Ullrich
				<div id="showadvancedboxspr">
1001
					<p>
1002 4143e7fb Colin Fleming
					<input <?=$edit_disabled;?> type="button" onclick="show_source_port_range()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source port range");?>
1003
					</p>
1004 22abf2ef Scott Ullrich
				</div>
1005 8ab3e9ed Erik Kristensen
			</td>
1006 e33c8694 Bill Marquette
		</tr>
1007 4143e7fb Colin Fleming
		<tr style="display:none" id="sprtable">
1008 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range");?></td>
1009 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1010
				<table border="0" cellspacing="0" cellpadding="0">
1011
					<tr>
1012 21600ab1 Vinicius Coque
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1013 8ab3e9ed Erik Kristensen
						<td>
1014 48a27d4f Erik Fonnesbeck
							<select <?=$edit_disabled;?> name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
1015 abd67a31 Carlos Eduardo Ramos
								<option value="">(<?=gettext("other"); ?>)</option>
1016 4143e7fb Colin Fleming
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1017 8ab3e9ed Erik Kristensen
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1018 4143e7fb Colin Fleming
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1019 8ab3e9ed Erik Kristensen
<?php 							endforeach; ?>
1020 8c84fe43 Scott Ullrich
							</select>
1021 4143e7fb Colin Fleming
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>" />
1022 8ab3e9ed Erik Kristensen
						</td>
1023
					</tr>
1024
					<tr>
1025 21600ab1 Vinicius Coque
						<td><?=gettext("to:");?></td>
1026 8ab3e9ed Erik Kristensen
						<td>
1027 48a27d4f Erik Fonnesbeck
							<select <?=$edit_disabled;?> name="srcendport" class="formselect" onchange="ext_change()">
1028 abd67a31 Carlos Eduardo Ramos
								<option value="">(<?=gettext("other"); ?>)</option>
1029 4143e7fb Colin Fleming
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1030 8ab3e9ed Erik Kristensen
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1031 4143e7fb Colin Fleming
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1032 8ab3e9ed Erik Kristensen
<?php							endforeach; ?>
1033 8c84fe43 Scott Ullrich
							</select>
1034 4143e7fb Colin Fleming
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>" />
1035 8ab3e9ed Erik Kristensen
						</td>
1036
					</tr>
1037
				</table>
1038
				<br />
1039 87000ded Erik Fonnesbeck
				<span class="vexpl"><?=gettext("Specify the source port or port range for this rule."); ?> <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be"); ?> &quot;<?=gettext("any"); ?>&quot;).</b><br /><?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port.");?></span><br/>
1040 8ab3e9ed Erik Kristensen
			</td>
1041 8c84fe43 Scott Ullrich
		</tr>
1042 8ab3e9ed Erik Kristensen
		<tr>
1043 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination");?></td>
1044 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1045 4143e7fb Colin Fleming
				<input <?=$edit_disabled;?> name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
1046 11d2c529 Rafael Lucas
				<strong><?=gettext("not");?></strong>
1047 8ab3e9ed Erik Kristensen
					<br />
1048 11d2c529 Rafael Lucas
				<?=gettext("Use this option to invert the sense of the match.");?>
1049 8ab3e9ed Erik Kristensen
					<br />
1050
					<br />
1051
				<table border="0" cellspacing="0" cellpadding="0">
1052
					<tr>
1053 21600ab1 Vinicius Coque
						<td><?=gettext("Type:");?>&nbsp;&nbsp;</td>
1054 8ab3e9ed Erik Kristensen
						<td>
1055 4143e7fb Colin Fleming
							<select <?=$edit_disabled;?> name="dsttype" class="formselect" onchange="typesel_change()">
1056 87f0be87 Chris Buechler
<?php
1057
								$sel = is_specialnet($pconfig['dst']); ?>
1058 4143e7fb Colin Fleming
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any");?></option>
1059 965c3e23 Renato Botelho
								<option value="single"
1060
								<?php  if (!$sel &&
1061
									    ((is_ipaddrv6($pconfig['dst']) && $pconfig['dstmask'] == 128) ||
1062
									    (is_ipaddrv4($pconfig['dst']) && $pconfig['dstmask'] == 32) || is_alias($pconfig['dst'])))
1063 4143e7fb Colin Fleming
										{ echo "selected=\"selected\""; $sel = 1; }
1064 965c3e23 Renato Botelho
								?>
1065
								><?=gettext("Single host or alias");?></option>
1066 4143e7fb Colin Fleming
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network");?></option>
1067 99ea4439 Scott Ullrich
								<?php if(have_ruleint_access("pptp")): ?>
1068 4143e7fb Colin Fleming
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients");?></option>
1069 99ea4439 Scott Ullrich
								<?php endif; ?>
1070
								<?php if(have_ruleint_access("pppoe")): ?>
1071 4143e7fb Colin Fleming
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients");?></option>
1072 f8fee2ce Renato Botelho
								<?php endif; ?>
1073 3331a640 Ermal Lu?i
								<?php if(have_ruleint_access("l2tp")): ?>
1074 f8fee2ce Renato Botelho
								<option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients");?></option>
1075
								<?php endif; ?>
1076 b7391125 Ermal Luçi
1077
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
1078
								<?php if(have_ruleint_access($if)): ?>
1079 4143e7fb Colin Fleming
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("subnet");?></option>
1080
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected=\"selected\""; } ?>>
1081 11d2c529 Rafael Lucas
										<?=$ifdesc;?> <?=gettext("address");?>
1082 cbff71a1 Scott Ullrich
									</option>
1083 99ea4439 Scott Ullrich
								<?php endif; ?>
1084 b7391125 Ermal Luçi
<?php 							endforeach; ?>
1085 8ab3e9ed Erik Kristensen
							</select>
1086
						</td>
1087
					</tr>
1088
					<tr>
1089 21600ab1 Vinicius Coque
						<td><?=gettext("Address:");?>&nbsp;&nbsp;</td>
1090 8ab3e9ed Erik Kristensen
						<td>
1091 4143e7fb Colin Fleming
							<input <?=$edit_disabled;?> autocomplete='off' name="dst" type="text" class="formfldalias ipv4v6" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>" />
1092 8ab3e9ed Erik Kristensen
							/
1093 979b179d Darren Embry
							<select <?=$edit_disabled;?> name="dstmask" class="formselect ipv4v6" id="dstmask">
1094 8ab3e9ed Erik Kristensen
<?php
1095 f8fee2ce Renato Botelho
							for ($i = 127; $i > 0;
1096 15705bc0 Seth Mos
$i--): ?>
1097 4143e7fb Colin Fleming
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
1098 8ab3e9ed Erik Kristensen
<?php						endfor; ?>
1099
							</select>
1100
						</td>
1101
					</tr>
1102
				</table>
1103
			</td>
1104
		</tr>
1105 4143e7fb Colin Fleming
		<tr id="dprtr">
1106 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range ");?></td>
1107 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1108
				<table border="0" cellspacing="0" cellpadding="0">
1109
					<tr>
1110 21600ab1 Vinicius Coque
						<td><?=gettext("from:");?>&nbsp;&nbsp;</td>
1111 8ab3e9ed Erik Kristensen
						<td>
1112 48a27d4f Erik Fonnesbeck
							<select <?=$edit_disabled;?> name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
1113 abd67a31 Carlos Eduardo Ramos
								<option value="">(<?=gettext("other"); ?>)</option>
1114 4143e7fb Colin Fleming
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1115 8ab3e9ed Erik Kristensen
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
1116 4143e7fb Colin Fleming
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected=\"selected\""; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
1117 3deb92f7 Renato Botelho
<?php 							endforeach; ?>
1118 8ab3e9ed Erik Kristensen
							</select>
1119 4143e7fb Colin Fleming
							<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo htmlspecialchars($pconfig['dstbeginport']); ?>" />
1120 8ab3e9ed Erik Kristensen
						</td>
1121
					</tr>
1122
					<tr>
1123 21600ab1 Vinicius Coque
						<td><?=gettext("to:");?></td>
1124 8ab3e9ed Erik Kristensen
						<td>
1125 48a27d4f Erik Fonnesbeck
							<select <?=$edit_disabled;?> name="dstendport" class="formselect" onchange="ext_change()">
1126 abd67a31 Carlos Eduardo Ramos
								<option value="">(<?=gettext("other"); ?>)</option>
1127 4143e7fb Colin Fleming
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any");?></option>
1128 8ab3e9ed Erik Kristensen
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
1129 4143e7fb Colin Fleming
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
1130 8ab3e9ed Erik Kristensen
<?php 							endforeach; ?>
1131 8c84fe43 Scott Ullrich
							</select>
1132 4143e7fb Colin Fleming
								<input <?=$edit_disabled;?> autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo htmlspecialchars($pconfig['dstendport']); ?>" />
1133 8ab3e9ed Erik Kristensen
						</td>
1134
					</tr>
1135
				</table>
1136
				<br />
1137
				<span class="vexpl">
1138 11d2c529 Rafael Lucas
					<?=gettext("Specify the port or port range for the destination of the packet for this rule.");?>
1139 adb633a0 sullrich
					<br />
1140 345b9715 Carlos Eduardo Ramos
					<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("'to'"); ?></em> <?=gettext("field empty if you only want to filter a single port");?>
1141 8ab3e9ed Erik Kristensen
				</span>
1142
			</td>
1143
		</tr>
1144
		<tr>
1145 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Log");?></td>
1146 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1147 4143e7fb Colin Fleming
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked=\"checked\""; ?> />
1148 11d2c529 Rafael Lucas
				<strong><?=gettext("Log packets that are handled by this rule");?></strong>
1149 adb633a0 sullrich
				<br />
1150 0fb885bc Carlos Eduardo Ramos
				<span class="vexpl"><?=gettext("Hint: the firewall has limited local log space. Don't turn on logging for everything. If you want to do a lot of logging, consider using a remote syslog server"); ?> (<?=gettext("see the"); ?> <a href="diag_logs_settings.php"><?=gettext("Diagnostics: System logs: Settings"); ?></a> <?=gettext("page"); ?>).</span>
1151 8ab3e9ed Erik Kristensen
			</td>
1152
		</tr>
1153 151eb2a9 sullrich
		<tr>
1154 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
1155 151eb2a9 sullrich
			<td width="78%" class="vtable">
1156 4143e7fb Colin Fleming
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>" />
1157 151eb2a9 sullrich
				<br />
1158 11d2c529 Rafael Lucas
				<span class="vexpl"><?=gettext("You may enter a description here for your reference.");?></span>
1159 151eb2a9 sullrich
			</td>
1160
		</tr>
1161 8e0c3760 Ermal
<?php		if (!isset($id) || !($a_filter[$id] && firewall_check_for_advanced_options($a_filter[$id]) <> "")): ?>
1162 151eb2a9 sullrich
		<tr>
1163
			<td width="22%" valign="top">&nbsp;</td>
1164
			<td width="78%">
1165 4143e7fb Colin Fleming
				&nbsp;<br/>&nbsp;
1166
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1167 151eb2a9 sullrich
<?php			if (isset($id) && $a_filter[$id]): ?>
1168 4143e7fb Colin Fleming
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1169 151eb2a9 sullrich
<?php 			endif; ?>
1170 4143e7fb Colin Fleming
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1171 151eb2a9 sullrich
			</td>
1172
		</tr>
1173 8e0c3760 Ermal
<?php		endif; ?>
1174 151eb2a9 sullrich
		<tr>
1175
			<td>&nbsp;</td>
1176
		</tr>
1177
		<tr>
1178 11d2c529 Rafael Lucas
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced features");?></td>
1179 f8fee2ce Renato Botelho
		</tr>
1180 f1602cc4 sullrich
		<tr>
1181 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Source OS");?></td>
1182 e265d9f5 sullrich
			<td width="78%" class="vtable">
1183 ee9933b6 Renato Botelho
				<div id="showadvsourceosbox" <?php if ($pconfig['os']) echo "style='display:none'"; ?>>
1184 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_sourceos()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1185 adb633a0 sullrich
				</div>
1186 ee9933b6 Renato Botelho
				<div id="showsourceosadv" <?php if (empty($pconfig['os'])) echo "style='display:none'"; ?>>
1187 21600ab1 Vinicius Coque
					<?=gettext("OS Type:");?>&nbsp;
1188 adb633a0 sullrich
					<select name="os" id="os" class="formselect">
1189 f1602cc4 sullrich
<?php
1190 adb633a0 sullrich
						$ostypes = array(
1191 f8fee2ce Renato Botelho
							"" => gettext("any"),
1192 adb633a0 sullrich
							"AIX" => "AIX",
1193
							"Linux" => "Linux",
1194
							"FreeBSD" => "FreeBSD",
1195
							"NetBSD" => "NetBSD",
1196
							"OpenBSD" => "OpenBSD",
1197
							"Solaris" => "Solaris",
1198
							"MacOS" => "MacOS",
1199
							"Windows" => "Windows",
1200
							"Novell" => "Novell",
1201
							"NMAP" => "NMAP"
1202 f8fee2ce Renato Botelho
						);
1203 adb633a0 sullrich
						foreach ($ostypes as $ostype => $descr): ?>
1204 4143e7fb Colin Fleming
							<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($descr);?></option>
1205 adb633a0 sullrich
<?php
1206 f8fee2ce Renato Botelho
					endforeach;
1207 adb633a0 sullrich
?>
1208
					</select>
1209
					<br />
1210 11d2c529 Rafael Lucas
					<?=gettext("Note: this only works for TCP rules");?>
1211 adb633a0 sullrich
				</div>
1212 f1602cc4 sullrich
			</td>
1213
		</tr>
1214 30c4ae8a sullrich
		<tr>
1215 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Diffserv Code Point");?></td>
1216 30c4ae8a sullrich
			<td width="78%" class="vtable">
1217 4143e7fb Colin Fleming
				<div id="dsadv" <?php if ($pconfig['dscp']) echo "style='display:none'"; ?>>
1218
					<input type="button" onclick="show_dsdiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1219 30c4ae8a sullrich
				</div>
1220 4143e7fb Colin Fleming
				<div id="dsdivmain" <?php if (empty($pconfig['dscp'])) echo "style='display:none'"; ?>>
1221 30c4ae8a sullrich
					<select name="dscp" id="dscp">
1222
						<option value=""></option>
1223
						<?php foreach($firewall_rules_dscp_types as $frdt): ?>
1224 4143e7fb Colin Fleming
							<option value="<?=$frdt?>"<?php if($pconfig['dscp'] == $frdt) echo " selected=\"selected\""; ?>><?=$frdt?></option>
1225 30c4ae8a sullrich
						<?php endforeach; ?>
1226
					</select>
1227
				</div>
1228
			</td>
1229
		</tr>
1230 661aed33 Ermal Luçi
		<tr>
1231 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Advanced Options");?></td>
1232 e6db3f58 Ermal Luçi
			<td width="78%" class="vtable">
1233 4143e7fb Colin Fleming
			<div id="aoadv">
1234
				<input type="button" onclick="show_aodiv();" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1235 e6db3f58 Ermal Luçi
			</div>
1236 4143e7fb Colin Fleming
			<div id="aodivmain" style="display:none">
1237
				<input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked=\"checked\""; ?> />
1238 a29dc11b Chris Buechler
				<br/><span class="vexpl"><?=gettext("This allows packets with IP options to pass. Otherwise they are blocked by default. This is usually only seen with multicast traffic.");?>
1239 f1602cc4 sullrich
				</span><p>
1240 4143e7fb Colin Fleming
				<input type="checkbox" id="disablereplyto" value="yes" name="disablereplyto"<?php if($pconfig['disablereplyto'] == true) echo " checked=\"checked\""; ?> />
1241 19757916 Ermal Lu?i
				<br/><span class="vexpl"><?=gettext("This will disable auto generated reply-to for this rule.");?>
1242 4143e7fb Colin Fleming
				</span></p><p>
1243
				<input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>" />
1244 345b9715 Carlos Eduardo Ramos
				<br /><span class="vexpl"><?=gettext("You can mark a packet matching this rule and use this mark to match on other NAT/filter rules. It is called"); ?> <b><?=gettext("Policy filtering"); ?></b>
1245 4143e7fb Colin Fleming
				</span></p><p>
1246
				<input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>" />
1247 f1602cc4 sullrich
				<br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
1248 4143e7fb Colin Fleming
				</span></p><p>
1249 ff6e6929 Phil Davis
				<input name="max" id="max" value="<?php echo htmlspecialchars($pconfig['max']) ?>" /><br/><?=gettext(" Maximum state entries this rule can create");?></p><p>
1250
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo htmlspecialchars($pconfig['max-src-nodes']) ?>" /><br/><?=gettext(" Maximum number of unique source hosts");?></p><p>
1251 98f4043e Phil Davis
				<input name="max-src-conn" id="max-src-conn" value="<?php echo htmlspecialchars($pconfig['max-src-conn']) ?>" /><br/><?=gettext(" Maximum number of established connections per host (TCP only)");?></p><p>
1252 ff6e6929 Phil Davis
				<input name="max-src-states" id="max-src-states" value="<?php echo htmlspecialchars($pconfig['max-src-states']) ?>" /><br/><?=gettext(" Maximum state entries per host");?></p><p>
1253 4143e7fb Colin Fleming
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo htmlspecialchars($pconfig['max-src-conn-rate']) ?>" /> /
1254 8ab3e9ed Erik Kristensen
				<select name="max-src-conn-rates" id="max-src-conn-rates">
1255 4143e7fb Colin Fleming
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected=\"selected\""; ?>></option>
1256 8ab3e9ed Erik Kristensen
<?php				for($x=1; $x<255; $x++) {
1257 4143e7fb Colin Fleming
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected=\"selected\""; else $selected = "";
1258 8ab3e9ed Erik Kristensen
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
1259
					} ?>
1260 47042140 Scott Ullrich
				</select><br />
1261 98f4043e Phil Davis
				<?=gettext("Maximum new connections / per second(s) (TCP only)");?>
1262 e4d79ab0 Ermal
				</p><p>
1263 4143e7fb Colin Fleming
				<input name="statetimeout" value="<?php echo htmlspecialchars($pconfig['statetimeout']) ?>" /><br/>
1264 98f4043e Phil Davis
				<?=gettext("State Timeout in seconds (TCP only)");?>
1265 e4d79ab0 Ermal
				</p>
1266 e4b9d53b Warren Baker
				<p><strong><?=gettext("Note: Leave fields blank to disable that feature.");?></strong></p>
1267 f8fee2ce Renato Botelho
			</div>
1268 8ab3e9ed Erik Kristensen
			</td>
1269
		</tr>
1270 f8fee2ce Renato Botelho
		<tr id="tcpflags">
1271 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("TCP flags");?></td>
1272 b8ed2a11 Ermal
			<td width="78%" class="vtable">
1273 ee9933b6 Renato Botelho
			<div id="showtcpflagsbox" <?php if ($pconfig['tcpflags_any'] || $pconfig['tcpflags1'] || $pconfig['tcpflags2']) echo "style='display:none'"; ?>>
1274 f8fee2ce Renato Botelho
				<input type="button" onclick="show_advanced_tcpflags()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1275
			</div>
1276
			<div id="showtcpflagsadv" <?php if (empty($pconfig['tcpflags_any']) && empty($pconfig['tcpflags1']) && empty($pconfig['tcpflags2'])) echo "style='display:none'"; ?>>
1277 4143e7fb Colin Fleming
			<div id="tcpheader" align="center">
1278 b8ed2a11 Ermal
			<table border="0" cellspacing="0" cellpadding="0">
1279 f8fee2ce Renato Botelho
			<?php
1280 b8ed2a11 Ermal
				$setflags = explode(",", $pconfig['tcpflags1']);
1281
				$outofflags = explode(",", $pconfig['tcpflags2']);
1282 4143e7fb Colin Fleming
				$header = "<td width='40' class='nowrap'></td>";
1283
				$tcpflags1 = "<td width='40' class='nowrap'>set</td>";
1284
				$tcpflags2 = "<td width='40' class='nowrap'>out of</td>";
1285 b8ed2a11 Ermal
				foreach ($tcpflags as $tcpflag) {
1286 4143e7fb Colin Fleming
					$header .= "<td  width='40' class='nowrap'><strong>" . strtoupper($tcpflag) . "</strong></td>\n";
1287
					$tcpflags1 .= "<td  width='40' class='nowrap'> <input type='checkbox' name='tcpflags1_{$tcpflag}' value='on' ";
1288 b8ed2a11 Ermal
					if (array_search($tcpflag, $setflags) !== false)
1289 4143e7fb Colin Fleming
						$tcpflags1 .= "checked=\"checked\"";
1290
					$tcpflags1 .= " /></td>\n";
1291
					$tcpflags2 .= "<td  width='40' class='nowrap'> <input type='checkbox' name='tcpflags2_{$tcpflag}' value='on' ";
1292 b8ed2a11 Ermal
					if (array_search($tcpflag, $outofflags) !== false)
1293 4143e7fb Colin Fleming
						$tcpflags2 .= "checked=\"checked\"";
1294
					$tcpflags2 .= " /></td>\n";
1295 b8ed2a11 Ermal
				}
1296 4143e7fb Colin Fleming
				echo "<tr id='tcpheader'>{$header}</tr>\n";
1297
				echo "<tr id='tcpflags1'>{$tcpflags1}</tr>\n";
1298
				echo "<tr id='tcpflags2'>{$tcpflags2}</tr>\n";
1299 b8ed2a11 Ermal
			?>
1300
			</table>
1301
			</div>
1302
			<br/><center>
1303 4143e7fb Colin Fleming
			<input onclick='tcpflags_anyclick(this);' type='checkbox' name='tcpflags_any' value='on' <?php if ($pconfig['tcpflags_any']) echo "checked=\"checked\""; ?> /><strong><?=gettext("Any flags.");?></strong><br/></center>
1304 b8ed2a11 Ermal
			<br/>
1305 f8fee2ce Renato Botelho
			<span class="vexpl"><?=gettext("Use this to choose TCP flags that must ".
1306 11d2c529 Rafael Lucas
			"be set or cleared for this rule to match.");?></span>
1307 b8ed2a11 Ermal
			</div>
1308
			</td>
1309
		</tr>
1310 8ab3e9ed Erik Kristensen
		<tr>
1311 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("State Type");?></td>
1312 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1313 ee9933b6 Renato Botelho
				<div id="showadvstatebox" <?php if (!empty($pconfig['statetype']) && $pconfig['statetype'] != "keep state") echo "style='display:none'"; ?>>
1314 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_state()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1315 f6970b2f Scott Ullrich
				</div>
1316 ee9933b6 Renato Botelho
				<div id="showstateadv" <?php if (empty($pconfig['statetype']) || $pconfig['statetype'] == "keep state") echo "style='display:none'"; ?>>
1317 f6970b2f Scott Ullrich
					<select name="statetype">
1318 4143e7fb Colin Fleming
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected=\"selected\""; ?>><?=gettext("keep state");?></option>
1319
						<option value="sloppy state" <?php if($pconfig['statetype'] == "sloppy state") echo "selected=\"selected\""; ?>><?=gettext("sloppy state");?></option>
1320
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected=\"selected\""; ?>><?=gettext("synproxy state");?></option>
1321
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected=\"selected\""; ?>><?=gettext("none");?></option>
1322
					</select><br/><?=gettext("Hint: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.");?>
1323 f6970b2f Scott Ullrich
					<table width="90%">
1324 67300ce5 Ermal
						<tr><td width="25%"><ul><li><?=gettext("keep state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1325
						<tr><td width="25%"><ul><li><?=gettext("sloppy state");?></li></ul></td><td><?=gettext("Works with all IP protocols.");?></td></tr>
1326
						<tr><td width="25%"><ul><li><?=gettext("synproxy state");?></li></ul></td><td><?=gettext("Proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined.");?></td></tr>
1327
						<tr><td width="25%"><ul><li><?=gettext("none");?></li></ul></td><td><?=gettext("Do not use state mechanisms to keep track.  This is only useful if you're doing advanced queueing in certain situations.  Please check the documentation.");?></td></tr>
1328 f6970b2f Scott Ullrich
					</table>
1329 f8fee2ce Renato Botelho
				</div>
1330 8ab3e9ed Erik Kristensen
			</td>
1331
		</tr>
1332 10f21e70 Scott Ullrich
		<tr>
1333 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync");?></td>
1334 10f21e70 Scott Ullrich
			<td width="78%" class="vtable">
1335 ee9933b6 Renato Botelho
				<div id="showadvnoxmlrpcsyncbox" <?php if ($pconfig['nosync']) echo "style='display:none'"; ?>>
1336 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_noxmlrpc()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1337 0239d8ee sullrich
				</div>
1338 ee9933b6 Renato Botelho
				<div id="shownoxmlrpcadv" <?php if (empty($pconfig['nosync'])) echo "style='display:none'"; ?>>
1339 4143e7fb Colin Fleming
					<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br/>
1340 72711980 Renato Botelho
					<?=gettext("Hint: This prevents the rule on Master from automatically syncing to other CARP members. This does NOT prevent the rule from being overwritten on Slave.");?>
1341 0239d8ee sullrich
				</div>
1342 10f21e70 Scott Ullrich
			</td>
1343 8c84fe43 Scott Ullrich
		</tr>
1344 1346306c Ermal
		<tr>
1345
			<td width="22%" valign="top" class="vncell"><?=gettext("802.1p");?></td>
1346
			<td width="78%" class="vtable">
1347
				<div id="showadvvlanpriobox" <?php if (!empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
1348 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_vlanprio()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1349 1346306c Ermal
				</div>
1350
				<div id="showvlanprioadv" <?php if (empty($pconfig['vlanprio'])) echo "style='display:none'"; ?>>
1351
					<?php $vlanprio = array("none", "be", "bk", "ee", "ca", "vi", "vo", "ic", "nc"); ?>
1352
<?php
1353
					$opts = "";
1354
					foreach($vlanprio as $vprio) {
1355
						if ($vprio == $pconfig['vlanprio'])
1356 4143e7fb Colin Fleming
							$selected = " selected=\"selected\"";
1357 1346306c Ermal
						else
1358
							$selected = "";
1359
						if ($vprio == "none")
1360 f4567834 timdufrane
							$opts .= "<option value=\"\">{$vprio}</option>\n";
1361 1346306c Ermal
						else
1362
							$opts .= "<option value=\"{$vprio}\" {$selected}>" . strtoupper($vprio) . "</option>\n";
1363
					}
1364 9411d6ab timdufrane
1365
					$optsset = "";
1366
					foreach($vlanprio as $vprioset) {
1367
						if ($vprioset == $pconfig['vlanprioset'])
1368
							$selected = " selected=\"selected\"";
1369
						else
1370
							$selected = "";
1371
						if ($vprioset == "none")
1372
							$optsset .= "<option value=\"\">{$vprioset}</option>\n";
1373
						else
1374
							$optsset .= "<option value=\"{$vprioset}\" {$selected}>" . strtoupper($vprioset) . "</option>\n";
1375
					}
1376 1346306c Ermal
?>
1377
					<select name='vlanprio'>
1378
					<?php echo $opts; ?>
1379
					</select>
1380
					<p><?=gettext("Choose 802.1p priority to match on");?></p>
1381
					<select name='vlanprioset'>
1382 9411d6ab timdufrane
					<?php echo $optsset; ?>
1383 1346306c Ermal
					</select>
1384
					<p><?=gettext("Choose 802.1p priority to apply");?></p>
1385
				</div>
1386
			</td>
1387
		</tr>
1388 615b27bc Scott Dale
		<?php
1389
			//build list of schedules
1390
			$schedules = array();
1391
			$schedules[] = "none";//leave none to leave rule enabled all the time
1392 a60fd0cb Scott Ullrich
			if(is_array($config['schedules']['schedule'])) {
1393
				foreach ($config['schedules']['schedule'] as $schedule) {
1394
					if ($schedule['name'] <> "")
1395
						$schedules[] = $schedule['name'];
1396
				}
1397
			}
1398 615b27bc Scott Dale
		?>
1399
		<tr>
1400 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Schedule");?></td>
1401 615b27bc Scott Dale
			<td width="78%" class="vtable">
1402 ee9933b6 Renato Botelho
				<div id="showadvschedulebox" <?php if (!empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1403 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_schedule()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1404 0239d8ee sullrich
				</div>
1405 ee9933b6 Renato Botelho
				<div id="showscheduleadv" <?php if (empty($pconfig['sched'])) echo "style='display:none'"; ?>>
1406 0239d8ee sullrich
					<select name='sched'>
1407 615b27bc Scott Dale
<?php
1408 0239d8ee sullrich
					foreach($schedules as $schedule) {
1409
						if($schedule == $pconfig['sched']) {
1410 4143e7fb Colin Fleming
							$selected = " selected=\"selected\"";
1411 0239d8ee sullrich
						} else {
1412
							$selected = "";
1413
						}
1414
						if ($schedule == "none") {
1415
							echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
1416
						} else {
1417
							echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
1418
						}
1419 615b27bc Scott Dale
					}
1420 0239d8ee sullrich
?>
1421
					</select>
1422 11d2c529 Rafael Lucas
					<p><?=gettext("Leave as 'none' to leave the rule enabled all the time.");?></p>
1423 0239d8ee sullrich
				</div>
1424 615b27bc Scott Dale
			</td>
1425
		</tr>
1426 82628210 Scott Ullrich
		<tr>
1427 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Gateway");?></td>
1428 8ab3e9ed Erik Kristensen
			<td width="78%" class="vtable">
1429 ee9933b6 Renato Botelho
				<div id="showadvgatewaybox" <?php if (!empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1430 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_gateway()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1431 0239d8ee sullrich
				</div>
1432 ee9933b6 Renato Botelho
				<div id="showgatewayadv" <?php if (empty($pconfig['gateway'])) echo "style='display:none'"; ?>>
1433 0239d8ee sullrich
					<select name='gateway'>
1434 11d2c529 Rafael Lucas
					<option value="" ><?=gettext("default");?></option>
1435 8ab3e9ed Erik Kristensen
<?php
1436 1b38ac36 Ermal
					/* build a list of gateways */
1437
					$gateways = return_gateways_array();
1438 106804a2 Chris Buechler
					// add statically configured gateways to list
1439 1b38ac36 Ermal
					foreach($gateways as $gwname => $gw) {
1440 05a4cebd smos
						if(($pconfig['ipprotocol'] == "inet46"))
1441
							continue;
1442 889cbaef Phil Davis
						if(($pconfig['ipprotocol'] == "inet6") && !(($gw['ipprotocol'] == "inet6") || (is_ipaddrv6($gw['gateway']))))
1443 270a2576 Seth Mos
							continue;
1444 889cbaef Phil Davis
						if(($pconfig['ipprotocol'] == "inet") && !(($gw['ipprotocol'] == "inet") || (is_ipaddrv4($gw['gateway']))))
1445 270a2576 Seth Mos
							continue;
1446 f8fee2ce Renato Botelho
						if($gw == "")
1447 0581660c Scott Ullrich
							continue;
1448 1b38ac36 Ermal
						if($gwname == $pconfig['gateway']) {
1449 4143e7fb Colin Fleming
							$selected = " selected=\"selected\"";
1450 1fda0968 Scott Ullrich
						} else {
1451
							$selected = "";
1452
						}
1453 1b38ac36 Ermal
						echo "<option value=\"{$gwname}\" {$selected}>{$gw['name']} - {$gw['gateway']}</option>\n";
1454 106804a2 Chris Buechler
					}
1455 0239d8ee sullrich
					/* add gateway groups to the list */
1456
					if (is_array($config['gateways']['gateway_group'])) {
1457
						foreach($config['gateways']['gateway_group'] as $gw_group) {
1458 a1c10b7f Seth Mos
							$af = explode("|", $gw_group['item'][0]);
1459 05a4cebd smos
							if(($pconfig['ipprotocol'] == "inet46"))
1460
								continue;
1461 a1c10b7f Seth Mos
							if(($pconfig['ipprotocol'] == "inet6") && !is_ipaddrv6(lookup_gateway_ip_by_name($af[0])))
1462 270a2576 Seth Mos
								continue;
1463 a1c10b7f Seth Mos
							if(($pconfig['ipprotocol'] == "inet") && !is_ipaddrv4(lookup_gateway_ip_by_name($af[0])))
1464 270a2576 Seth Mos
								continue;
1465 0239d8ee sullrich
							if($gw_group['name'] == "")
1466
								continue;
1467
							if($pconfig['gateway'] == $gw_group['name']) {
1468 4143e7fb Colin Fleming
								$selected = " selected=\"selected\"";
1469 0239d8ee sullrich
							} else {
1470 270a2576 Seth Mos
								$selected = "";
1471 0239d8ee sullrich
							}
1472 270a2576 Seth Mos
							echo "<option value=\"{$gw_group['name']}\" $selected>{$gw_group['name']}</option>\n";
1473 0239d8ee sullrich
						}
1474
					}
1475 8ab3e9ed Erik Kristensen
?>
1476 0239d8ee sullrich
					</select>
1477 e85604b8 Chris Buechler
					<p><?=gettext("Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.");?></p>
1478 0239d8ee sullrich
				</div>
1479 8ab3e9ed Erik Kristensen
			</td>
1480
		</tr>
1481 a5fd67e1 Ermal Luçi
		<tr>
1482 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("In/Out");?></td>
1483 a5fd67e1 Ermal Luçi
			<td width="78%" class="vtable">
1484 ee9933b6 Renato Botelho
				<div id="showadvinoutbox" <?php if (!empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1485 4143e7fb Colin Fleming
					<input type="button" onclick="show_advanced_inout()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1486 4c263f57 sullrich
				</div>
1487 ee9933b6 Renato Botelho
				<div id="showinoutadv" <?php if (empty($pconfig['dnpipe'])) echo "style='display:none'"; ?>>
1488 4c263f57 sullrich
					<select name="dnpipe">
1489 a5fd67e1 Ermal Luçi
<?php
1490
		if (!is_array($dnqlist))
1491
			$dnqlist = array();
1492 7e2237f6 timdufrane
		echo "<option value=\"\"";
1493 4143e7fb Colin Fleming
		if (!$dnqselected) echo " selected=\"selected\"";
1494 a5fd67e1 Ermal Luçi
		echo " >none</option>";
1495
		foreach ($dnqlist as $dnq => $dnqkey) {
1496
			if($dnq == "")
1497
				continue;
1498 85a236e9 Ermal
			echo "<option value=\"$dnq\"";
1499
			if ($dnq == $pconfig['dnpipe']) {
1500 a5fd67e1 Ermal Luçi
				$dnqselected = 1;
1501 4143e7fb Colin Fleming
				echo " selected=\"selected\"";
1502 a5fd67e1 Ermal Luçi
			}
1503 f8fee2ce Renato Botelho
			echo ">{$dnq}</option>";
1504 a5fd67e1 Ermal Luçi
		}
1505
?>
1506 f8fee2ce Renato Botelho
			</select> /
1507 a5fd67e1 Ermal Luçi
			<select name="pdnpipe">
1508
<?php
1509
		$dnqselected = 0;
1510 7e2237f6 timdufrane
		echo "<option value=\"\"";
1511 4143e7fb Colin Fleming
		if (!$dnqselected) echo " selected=\"selected\"";
1512 a5fd67e1 Ermal Luçi
		echo " >none</option>";
1513
		foreach ($dnqlist as $dnq => $dnqkey) {
1514
			if($dnq == "")
1515
				continue;
1516 85a236e9 Ermal
			echo "<option value=\"$dnq\"";
1517
			if ($dnq == $pconfig['pdnpipe']) {
1518 a5fd67e1 Ermal Luçi
				$dnqselected = 1;
1519 4143e7fb Colin Fleming
				echo " selected=\"selected\"";
1520 a5fd67e1 Ermal Luçi
			}
1521 f8fee2ce Renato Botelho
			echo ">{$dnq}</option>";
1522 a5fd67e1 Ermal Luçi
		}
1523
?>
1524 4c263f57 sullrich
				</select>
1525 a5fd67e1 Ermal Luçi
				<br />
1526 bb8f186e Chris Buechler
				<span class="vexpl"><?=gettext("Choose the Out queue/Virtual interface only if you have also selected In.")."<br/>".gettext("The Out selection is applied to traffic leaving the interface where the rule is created, In is applied to traffic coming into the chosen interface.")."<br/>".gettext("If you are creating a floating rule, if the direction is In then the same rules apply, if the direction is out the selections are reverted Out is for incoming and In is for outgoing.");?></span>
1527 4c263f57 sullrich
				</div>
1528 a5fd67e1 Ermal Luçi
			</td>
1529
		</tr>
1530
1531 197bfe96 Ermal Luçi
		<tr>
1532 11d2c529 Rafael Lucas
			<td width="22%" valign="top" class="vncell"><?=gettext("Ackqueue/Queue");?></td>
1533 197bfe96 Ermal Luçi
			<td width="78%" class="vtable">
1534 ee9933b6 Renato Botelho
			<div id="showadvackqueuebox" <?php if (!empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1535 4143e7fb Colin Fleming
				<input type="button" onclick="show_advanced_ackqueue()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1536 0239d8ee sullrich
			</div>
1537 ee9933b6 Renato Botelho
			<div id="showackqueueadv" <?php if (empty($pconfig['defaultqueue'])) echo "style='display:none'"; ?>>
1538 0239d8ee sullrich
				<select name="ackqueue">
1539 197bfe96 Ermal Luçi
<?php
1540 0239d8ee sullrich
			if (!is_array($qlist))
1541
				$qlist = array();
1542 7e2237f6 timdufrane
			echo "<option value=\"\"";
1543 4143e7fb Colin Fleming
			if (!$qselected) echo " selected=\"selected\"";
1544 0239d8ee sullrich
			echo " >none</option>";
1545
			foreach ($qlist as $q => $qkey) {
1546
				if($q == "")
1547
					continue;
1548
				echo "<option value=\"$q\"";
1549
				if ($q == $pconfig['ackqueue']) {
1550
					$qselected = 1;
1551 4143e7fb Colin Fleming
					echo " selected=\"selected\"";
1552 0239d8ee sullrich
				}
1553 199791f9 Ermal
				if (isset($ifdisp[$q]))
1554
					echo ">{$ifdisp[$q]}</option>";
1555
				else
1556 f8fee2ce Renato Botelho
					echo ">{$q}</option>";
1557 197bfe96 Ermal Luçi
			}
1558
?>
1559 f8fee2ce Renato Botelho
				</select> /
1560 0239d8ee sullrich
				<select name="defaultqueue">
1561 197bfe96 Ermal Luçi
<?php
1562 0239d8ee sullrich
			$qselected = 0;
1563 7e2237f6 timdufrane
			echo "<option value=\"\"";
1564 4143e7fb Colin Fleming
			if (!$qselected) echo " selected=\"selected\"";
1565 0239d8ee sullrich
			echo " >none</option>";
1566
			foreach ($qlist as $q => $qkey) {
1567
				if($q == "")
1568
					continue;
1569
				echo "<option value=\"$q\"";
1570
				if ($q == $pconfig['defaultqueue']) {
1571
					$qselected = 1;
1572 4143e7fb Colin Fleming
					echo " selected=\"selected\"";
1573 0239d8ee sullrich
				}
1574 199791f9 Ermal
				if (isset($ifdisp[$q]))
1575
					echo ">{$ifdisp[$q]}</option>";
1576
				else
1577 f8fee2ce Renato Botelho
					echo ">{$q}</option>";
1578 197bfe96 Ermal Luçi
			}
1579
?>
1580 0239d8ee sullrich
				</select>
1581
					<br />
1582 11d2c529 Rafael Lucas
					<span class="vexpl"><?=gettext("Choose the Acknowledge Queue only if you have selected Queue.");?></span>
1583 4143e7fb Colin Fleming
					</div>
1584 0239d8ee sullrich
				</td>
1585
			</tr>
1586
			<tr>
1587 11d2c529 Rafael Lucas
				<td width="22%" valign="top" class="vncell"><?=gettext("Layer7");?></td>
1588 0239d8ee sullrich
				<td width="78%" class="vtable">
1589 ee9933b6 Renato Botelho
					<div id="showadvlayer7box" <?php if (!empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1590 4143e7fb Colin Fleming
						<input type="button" onclick="show_advanced_layer7()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show advanced option");?>
1591 4c263f57 sullrich
					</div>
1592 ee9933b6 Renato Botelho
					<div id="showlayer7adv" <?php if (empty($pconfig['l7container'])) echo "style='display:none'"; ?>>
1593 f8fee2ce Renato Botelho
						<select name="l7container">
1594 7e50413c Ermal Luçi
<?php
1595 f8fee2ce Renato Botelho
						if (!is_array($l7clist))
1596
							$l7clist = array();
1597
						echo "<option value=\"\"";
1598
						echo " >none</option>";
1599
						foreach ($l7clist as $l7ckey) {
1600
							echo "<option value=\"{$l7ckey}\"";
1601
							if ($l7ckey == $pconfig['l7container']) {
1602
								echo " selected=\"selected\"";
1603
							}
1604
							echo ">{$l7ckey}</option>";
1605 0239d8ee sullrich
						}
1606 7e50413c Ermal Luçi
?>
1607 f8fee2ce Renato Botelho
						</select>
1608
						<br/>
1609
						<span class="vexpl">
1610
							<?=gettext("Choose a Layer7 container to apply application protocol inspection rules. " .
1611
							"These are valid for TCP and UDP protocols only.");?>
1612
						</span>
1613
					</div>
1614
				</td>
1615
			</tr>
1616 d65962a7 Scott Ullrich
<?php
1617 f8fee2ce Renato Botelho
		// Allow extending of the firewall edit page and include custom input validation
1618 d65962a7 Scott Ullrich
		pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/htmlphplate");
1619
?>
1620 ba1d9714 jim-p
<?php
1621
$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
1622
$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
1623
?>
1624
		<?php if ($has_created_time || $has_updated_time): ?>
1625
		<tr>
1626
			<td>&nbsp;</td>
1627
		</tr>
1628
		<tr>
1629
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
1630
		</tr>
1631
		<?php if ($has_created_time): ?>
1632
		<tr>
1633
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
1634
			<td width="78%" class="vtable">
1635
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['created']['username'] ?></strong>
1636
			</td>
1637
		</tr>
1638
		<?php endif; ?>
1639
		<?php if ($has_updated_time): ?>
1640
		<tr>
1641
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
1642
			<td width="78%" class="vtable">
1643
				<?= date(gettext("n/j/y H:i:s"), $a_filter[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_filter[$id]['updated']['username'] ?></strong>
1644
			</td>
1645
		</tr>
1646
		<?php endif; ?>
1647
		<?php endif; ?>
1648 8ab3e9ed Erik Kristensen
		<tr>
1649
			<td width="22%" valign="top">&nbsp;</td>
1650
			<td width="78%">
1651 4143e7fb Colin Fleming
				&nbsp;<br/>&nbsp;
1652
				<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />  <input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
1653 8ab3e9ed Erik Kristensen
<?php			if (isset($id) && $a_filter[$id]): ?>
1654 4143e7fb Colin Fleming
					<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1655 8ab3e9ed Erik Kristensen
<?php 			endif; ?>
1656 4143e7fb Colin Fleming
				<input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
1657 8ab3e9ed Erik Kristensen
			</td>
1658 82628210 Scott Ullrich
		</tr>
1659 8ab3e9ed Erik Kristensen
	</table>
1660 5b237745 Scott Ullrich
</form>
1661 4143e7fb Colin Fleming
<script type="text/javascript">
1662 4dfd930e Darren Embry
//<![CDATA[
1663 8ab3e9ed Erik Kristensen
	ext_change();
1664
	typesel_change();
1665
	proto_change();
1666 3e74107e Erik Fonnesbeck
	<?php if ( (!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any") ): ?>
1667
	show_source_port_range();
1668
	<?php endif; ?>
1669 19757279 Scott Ullrich
1670 4dfd930e Darren Embry
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
1671
	var customarray  = <?= json_encode(get_alias_list("port")) ?>;
1672 19757279 Scott Ullrich
1673 9eb60dcc Ermal Lu?i
	var oTextbox1 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
1674 f8fee2ce Renato Botelho
	var oTextbox2 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
1675
	var oTextbox3 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
1676
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
1677
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
1678
	var oTextbox6 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
1679 4dfd930e Darren Embry
//]]>
1680 5b237745 Scott Ullrich
</script>
1681
<?php include("fend.inc"); ?>
1682
</body>
1683 9b45f821 Ermal Lu?i
</html>