Project

General

Profile

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