Project

General

Profile

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