Project

General

Profile

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