Project

General

Profile

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