Project

General

Profile

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