Project

General

Profile

Download (46.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_rules_edit.php
5
	part of pfSense (http://www.pfsense.com)
6
        Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	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

    
22
	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
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-firewall-rules-edit
36
##|*NAME=Firewall: Rules: Edit page
37
##|*DESCR=Allow access to the 'Firewall: Rules: Edit' page.
38
##|*MATCH=firewall_rules_edit.php*
39
##|-PRIV
40

    
41

    
42
require("guiconfig.inc");
43

    
44
$specialsrcdst = explode(" ", "any wanip lanip lan pptp pppoe");
45

    
46
if (!is_array($config['filter']['rule'])) {
47
	$config['filter']['rule'] = array();
48
}
49
filter_rules_sort();
50
$a_filter = &$config['filter']['rule'];
51

    
52
$id = $_GET['id'];
53
if (is_numeric($_POST['id']))
54
	$id = $_POST['id'];
55

    
56
$after = $_GET['after'];
57

    
58
if (isset($_POST['after']))
59
	$after = $_POST['after'];
60

    
61
if (isset($_GET['dup'])) {
62
	$id = $_GET['dup'];
63
	$after = $_GET['dup'];
64
}
65

    
66
if (isset($id) && $a_filter[$id]) {
67
	$pconfig['interface'] = $a_filter[$id]['interface'];
68

    
69
	if (!isset($a_filter[$id]['type']))
70
		$pconfig['type'] = "pass";
71
	else
72
		$pconfig['type'] = $a_filter[$id]['type'];
73

    
74
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
75
		$pconfig['floating'] = $a_filter[$id]['floating'];
76
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "") 
77
			$pconfig['interface'] = $a_filter[$id]['interface'];
78
	}
79
	
80
	if (isset($a_filter['floating'])) 
81
		$pconfig['floating'] = "yes";
82

    
83
	if (isset($a_filter[$id]['direction']))
84
                $pconfig['direction'] = $a_filter[$id]['direction'];
85

    
86
	if (isset($a_filter[$id]['protocol']))
87
		$pconfig['proto'] = $a_filter[$id]['protocol'];
88
	else
89
		$pconfig['proto'] = "any";
90

    
91
	if ($a_filter[$id]['protocol'] == "icmp")
92
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
93

    
94
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
95
		$pconfig['srcmask'], $pconfig['srcnot'],
96
		$pconfig['srcbeginport'], $pconfig['srcendport']);
97

    
98
	if($a_filter[$id]['os'] <> "")
99
		$pconfig['os'] = $a_filter[$id]['os'];
100

    
101
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
102
		$pconfig['dstmask'], $pconfig['dstnot'],
103
		$pconfig['dstbeginport'], $pconfig['dstendport']);
104

    
105
	if ($a_filter[$id]['dscp'] <> "")
106
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
107

    
108
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
109
	$pconfig['log'] = isset($a_filter[$id]['log']);
110
	$pconfig['descr'] = $a_filter[$id]['descr'];
111

    
112
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "") 
113
		$pconfig['tag'] = $a_filter[$id]['tag'];
114
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tag'] <> "")
115
        	$pconfig['tagged'] = $a_filter[$id]['tagged'];
116
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
117
		$pconfig['quick'] = $a_filter[$id]['quick'];
118
	if (isset($a_filter[$id]['allowopts']))
119
		$pconfig['allowopts'] = true;
120

    
121
	/* advanced */
122
        $pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
123
        $pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
124
        $pconfig['statetype'] = $a_filter[$id]['statetype'];
125
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
126

    
127
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
128

    
129
	/* advanced - new connection per second banning*/
130
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
131
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
132

    
133
	/* Multi-WAN next-hop support */
134
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
135
	
136
	/* Shaper support */
137
	$pconfig['defaultqueue'] = $a_filter[$id]['defaultqueue'];
138
	$pconfig['ackqueue'] = $a_filter[$id]['ackqueue'];
139
	$pconfig['dnpipe'] = $a_filter[$id]['dnpipe'];
140
	$pconfig['pdnpipe'] = $a_filter[$id]['pdnpipe'];
141
	$pconfig['l7container'] = $a_filter[$id]['l7container'];
142

    
143
	//schedule support
144
	$pconfig['sched'] = $a_filter[$id]['sched'];
145

    
146
} else {
147
	/* defaults */
148
	if ($_GET['if'])
149
		$pconfig['interface'] = $_GET['if'];
150
	$pconfig['type'] = "pass";
151
	$pconfig['src'] = "any";
152
	$pconfig['dst'] = "any";
153
}
154
/* Allow the FlotingRules to work */
155
$if = $pconfig['interface'];
156

    
157
if (isset($_GET['dup']))
158
	unset($id);
159

    
160
if ($_POST) {
161

    
162
	if ($_POST['type'] == "reject" && $_POST['proto'] <> "tcp")
163
		$input_errors[] = "Reject type rules only works when the protocol is set to TCP.";
164

    
165
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
166
		$_POST['srcbeginport'] = 0;
167
		$_POST['srcendport'] = 0;
168
		$_POST['dstbeginport'] = 0;
169
		$_POST['dstendport'] = 0;
170
	} else {
171

    
172
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
173
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
174
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
175
			$_POST['srcendport'] = $_POST['srcendport_cust'];
176

    
177
		if ($_POST['srcbeginport'] == "any") {
178
			$_POST['srcbeginport'] = 0;
179
			$_POST['srcendport'] = 0;
180
		} else {
181
			if (!$_POST['srcendport'])
182
				$_POST['srcendport'] = $_POST['srcbeginport'];
183
		}
184
		if ($_POST['srcendport'] == "any")
185
			$_POST['srcendport'] = $_POST['srcbeginport'];
186

    
187
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
188
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
189
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
190
			$_POST['dstendport'] = $_POST['dstendport_cust'];
191

    
192
		if ($_POST['dstbeginport'] == "any") {
193
			$_POST['dstbeginport'] = 0;
194
			$_POST['dstendport'] = 0;
195
		} else {
196
			if (!$_POST['dstendport'])
197
				$_POST['dstendport'] = $_POST['dstbeginport'];
198
		}
199
		if ($_POST['dstendport'] == "any")
200
			$_POST['dstendport'] = $_POST['dstbeginport'];
201
	}
202

    
203
	if (is_specialnet($_POST['srctype'])) {
204
		$_POST['src'] = $_POST['srctype'];
205
		$_POST['srcmask'] = 0;
206
	} else if ($_POST['srctype'] == "single") {
207
		$_POST['srcmask'] = 32;
208
	}
209
	if (is_specialnet($_POST['dsttype'])) {
210
		$_POST['dst'] = $_POST['dsttype'];
211
		$_POST['dstmask'] = 0;
212
	}  else if ($_POST['dsttype'] == "single") {
213
		$_POST['dstmask'] = 32;
214
	}
215

    
216
	unset($input_errors);
217
	$pconfig = $_POST;
218

    
219
	/*  run through $_POST items encoding HTML entties so that the user
220
	 *  cannot think he is slick and perform a XSS attack on the unwilling 
221
	 */
222
	foreach ($_POST as $key => $value) {
223
		$temp = $value;
224
		if (isset($_POST['floating']) && $key == "interface")
225
			continue;
226
		$newpost = htmlentities($temp);
227
		if($newpost <> $temp)   	 
228
			$input_errors[] = "Invalid characters detected ($temp).  Please remove invalid characters and save again.";		
229
	}
230

    
231
	/* input validation */
232
	$reqdfields = explode(" ", "type proto src dst");
233
	$reqdfieldsn = explode(",", "Type,Protocol,Source,Destination");
234

    
235
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
236
		if( $_POST['proto'] != "tcp" )
237
			$input_errors[] = "{$_POST['statetype']} is only valid with protocol tcp.";
238
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
239
			$input_errors[] = "{$_POST['statetype']} is only valid if the gateway is set to 'default'.";
240
	}
241
        
242
	if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
243
		$reqdfields[] = "srcmask";
244
		$reqdfieldsn[] = "Source bit count";
245
	}
246
	if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
247
		$reqdfields[] = "dstmask";
248
		$reqdfieldsn[] = "Destination bit count";
249
	}
250

    
251
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
252

    
253
	if (!$_POST['srcbeginport']) {
254
		$_POST['srcbeginport'] = 0;
255
		$_POST['srcendport'] = 0;
256
	}
257
	if (!$_POST['dstbeginport']) {
258
		$_POST['dstbeginport'] = 0;
259
		$_POST['dstendport'] = 0;
260
	}
261

    
262
	if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
263
		$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
264
	}
265
	if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
266
		$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
267
	}
268
	if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
269
		$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
270
	}
271
	if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
272
		$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
273
	}
274

    
275
	/* if user enters an alias and selects "network" then disallow. */
276
	if($_POST['srctype'] == "network") {
277
		if(is_alias($_POST['src']))
278
			$input_errors[] = "You must specify single host or alias for alias entries.";
279
	}
280
	if($_POST['dsttype'] == "network") {
281
		if(is_alias($_POST['dst']))
282
			$input_errors[] = "You must specify single host or alias for alias entries.";
283
	}
284

    
285
	if (!is_specialnet($_POST['srctype'])) {
286
		if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
287
			$input_errors[] = "A valid source IP address or alias must be specified.";
288
		}
289
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
290
			$input_errors[] = "A valid source bit count must be specified.";
291
		}
292
	}
293
	if (!is_specialnet($_POST['dsttype'])) {
294
		if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
295
			$input_errors[] = "A valid destination IP address or alias must be specified.";
296
		}
297
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
298
			$input_errors[] = "A valid destination bit count must be specified.";
299
		}
300
	}
301

    
302
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
303
		/* swap */
304
		$tmp = $_POST['srcendport'];
305
		$_POST['srcendport'] = $_POST['srcbeginport'];
306
		$_POST['srcbeginport'] = $tmp;
307
	}
308
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
309
		/* swap */
310
		$tmp = $_POST['dstendport'];
311
		$_POST['dstendport'] = $_POST['dstbeginport'];
312
		$_POST['dstbeginport'] = $tmp;
313
	}
314
	if ($_POST['os'])
315
		if( $_POST['proto'] != "tcp" )
316
			$input_errors[] = "OS detection is only valid with protocol tcp.";
317

    
318
	if ($_POST['ackqueue'] && $_POST['ackqueue'] != "none") {
319
		if ($_POST['defaultqueue'] == "none" )
320
			$input_errors[] = "You have to select a queue when you select an acknowledge queue too.";
321
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
322
			$input_errors[] = "Acknowledge queue and Queue cannot be the same.";		
323
	}
324
	if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "none") {
325
		if ($_POST['dnpipe'] == "none" )
326
			$input_errors[] = "You must select a queue for the In direction before selecting one for Out too.";
327
		else if ($_POST['pdnpipe'] == $_POST['dnpipe'])
328
			$input_errors[] = "In and Out Queue cannot be the same.";
329
		else if ($pdnpipe[0] == "?" && $dnpipe[0] <> "?")
330
			$input_errors[] = "You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.";
331
		else if ($dnpipe[0] == "?" && $pdnpipe[0] <> "?")
332
			$input_errors[] = "You cannot select one queue and one virtual interface for IN and Out. both must be from the same type.";
333
	}
334
	if($_POST['l7container'] && $_POST['l7container'] != "none") {
335
		if(!($_POST['proto'] == "tcp" || $_POST['proto'] == "udp" || $_POST['proto'] == "tcp/udp"))
336
			$input_errors[] = "You can only select a layer7 container for tcp and/or udp protocols";
337
	}
338

    
339
	if (!$input_errors) {
340
		$filterent = array();
341
		$filterent['type'] = $_POST['type'];
342
		if (isset($_POST['interface'] ))
343
			$filterent['interface'] = $_POST['interface'];
344

    
345
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
346
			if (isset($_POST['tag']))
347
				$filterent['tag'] = $_POST['tag'];
348
			if (isset($_POST['tagged']))
349
            			$filterent['tagged'] = $_POST['tagged'];
350
			$filterent['direction'] = $_POST['direction'];
351
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
352
				$filterent['quick'] = $_POST['quick'];
353
			$filterent['floating'] = "yes";
354
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
355
					$filterent['interface'] = implode(",", $_POST['interface']);
356
			}
357
		}
358

    
359
		/* Advanced options */
360
		if ($_POST['allowopts'] == "yes")
361
			$filterent['allowopts'] = true;
362
		else
363
			unset($filterent['allowopts']);
364
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
365
		$filterent['max-src-states'] = $_POST['max-src-states'];
366
		$filterent['statetimeout'] = $_POST['statetimeout'];
367
		$filterent['statetype'] = $_POST['statetype'];
368
		$filterent['os'] = $_POST['os'];
369

    
370
		/* Nosync directive - do not xmlrpc sync this item */
371
		if($_POST['nosync'] <> "")
372
			$filterent['nosync'] = true;
373
		else
374
			unset($filterent['nosync']);
375

    
376
		/* unless both values are provided, unset the values - ticket #650 */
377
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
378
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
379
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
380
		} else {
381
			unset($filterent['max-src-conn-rate']);
382
			unset($filterent['max-src-conn-rates']);
383
		}
384

    
385
		if ($_POST['proto'] != "any")
386
			$filterent['protocol'] = $_POST['proto'];
387
		else
388
			unset($filterent['protocol']);
389

    
390
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
391
			$filterent['icmptype'] = $_POST['icmptype'];
392
		else
393
			unset($filterent['icmptype']);
394

    
395
		pconfig_to_address($filterent['source'], $_POST['src'],
396
			$_POST['srcmask'], $_POST['srcnot'],
397
			$_POST['srcbeginport'], $_POST['srcendport']);
398

    
399
		pconfig_to_address($filterent['destination'], $_POST['dst'],
400
			$_POST['dstmask'], $_POST['dstnot'],
401
			$_POST['dstbeginport'], $_POST['dstendport']);
402

    
403
                if ($_POST['disabled'])
404
                        $filterent['disabled'] = true;
405
                else
406
                        unset($filterent['disabled']);
407
		
408
		if ($_POST['dscp'])
409
			$filterent['dscp'] = $_POST['dscp'];
410

    
411
                if ($_POST['log'])
412
                        $filterent['log'] = true;
413
                else
414
                        unset($filterent['log']);
415
		strncpy($filterent['descr'], $_POST['descr'], 52);
416

    
417
		if ($_POST['gateway'] != "") {
418
			$filterent['gateway'] = $_POST['gateway'];
419
		}
420
		
421
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
422
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
423
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
424
				$filterent['ackqueue'] = $_POST['ackqueue'];
425
		}
426

    
427
		if (isset($_POST['dnpipe']) && $_POST['dnpipe'] != "none") {
428
			$filterent['dnpipe'] = $_POST['dnpipe'];
429
			if (isset($_POST['pdnpipe']) && $_POST['pdnpipe'] != "none")
430
				$filterent['pdnpipe'] = $_POST['pdnpipe'];
431
		}
432

    
433
		if (isset($_POST['l7container']) && $_POST['l7container'] != "none") {
434
			$filterent['l7container'] = $_POST['l7container'];
435
		}
436
		
437
		if ($_POST['sched'] != "") {
438
			$filterent['sched'] = $_POST['sched'];
439
		}
440

    
441
		if (isset($id) && $a_filter[$id])
442
			$a_filter[$id] = $filterent;
443
		else {
444
			if (is_numeric($after))
445
				array_splice($a_filter, $after+1, 0, array($filterent));
446
			else
447
				$a_filter[] = $filterent;
448
		}
449

    
450
		write_config();
451
		mark_subsystem_dirty('filter');
452

    
453
		if (isset($_POST['floating']))
454
			header("Location: firewall_rules.php?if=FloatingRules");
455
		else
456
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
457
		exit;
458
	}
459
}
460

    
461
read_altq_config(); /* XXX: */
462
$qlist =& get_unique_queue_list();
463
read_dummynet_config(); /* XXX: */
464
$dnqlist =& get_unique_dnqueue_list();
465
read_layer7_config();
466
$l7clist =& get_l7_unique_list();
467

    
468
$pgtitle = array("Firewall","Rules","Edit");
469
$closehead = false;
470

    
471
$page_filename = "firewall_rules_edit.php";
472
include("head.inc");
473

    
474
?>
475

    
476
</head>
477

    
478
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
479
<?php include("fbegin.inc"); ?>
480
<?php if ($input_errors) print_input_errors($input_errors); ?>
481

    
482
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
483
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
484
		<tr>
485
			<td colspan="2" valign="top" class="listtopic">Edit Firewall rule</td>
486
		</tr>	
487
    	<tr>
488
			<td width="22%" valign="top" class="vncellreq">Action</td>
489
			<td width="78%" class="vtable">
490
				<select name="type" class="formselect">
491
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
492
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
493
					<?=htmlspecialchars($type);?>
494
					</option>
495
					<?php endforeach; ?>
496
				</select>
497
				<br/>
498
				<span class="vexpl">
499
					Choose what to do with packets that match the criteria specified below. <br/>
500
					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. Reject only works when the protocol is set to either TCP or UDP (but not &quot;TCP/UDP&quot;) below.
501
				</span>
502
			</td>
503
		</tr>
504
		<tr>
505
			<td width="22%" valign="top" class="vncellreq">Disabled</td>
506
			<td width="78%" class="vtable">
507
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
508
				<strong>Disable this rule</strong><br />
509
				<span class="vexpl">Set this option to disable this rule without removing it from the list.</span>
510
			</td>
511
		</tr>
512
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
513
		<tr>
514
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Quick");?></td>
515
                        <td width="78%" class="vtable">
516
                                <input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
517
                                <strong><?=gettext("Apply the action immediately on match.");?></strong><br />
518
                                <span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
519
                        </td>
520
                </tr>
521
<? endif; ?>
522
		<tr>
523
			<td width="22%" valign="top" class="vncellreq">Interface</td>
524
			<td width="78%" class="vtable">
525
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
526
				<select name="interface[]" multiple="true" class="formselect" size="3">
527
<? else: ?>
528
				<select name="interface" class="formselect">
529
<?php
530
   endif;
531
				/* add group interfaces */
532
                                if (is_array($config['ifgroups']['ifgroupentry']))
533
					foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
534
						if (have_ruleint_access($ifgen['ifname']))
535
							$interfaces[$ifgen['ifname']] = $ifgen['ifname'];
536

    
537
				$ifdescs = get_configured_interface_with_descr();
538

    
539
				foreach ($ifdescs as $ifent => $ifdesc)
540
        				if(have_ruleint_access($ifent))
541
                				$interfaces[$ifent] = $ifdesc;
542

    
543
					if ($config['l2tp']['mode'] == "server")
544
                                                if(have_ruleint_access("l2tp"))
545
                                                        $interfaces['l2tp'] = "L2TP VPN";
546

    
547
					if ($config['pptpd']['mode'] == "server")
548
						if(have_ruleint_access("pptp")) 
549
							$interfaces['pptp'] = "PPTP VPN";
550
					
551
					if ($config['pppoe']['mode'] == "server")
552
						if(have_ruleint_access("pppoe")) 
553
							$interfaces['pppoe'] = "PPPoE VPN";
554
					
555
					/* add ipsec interfaces */
556
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
557
						if(have_ruleint_access("enc0")) 
558
							$interfaces["enc0"] = "IPsec";
559
		
560
					/* add openvpn/tun interfaces */
561
					if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
562
       					$interfaces["openvpn"] = "OpenVPN";
563

    
564
					foreach ($interfaces as $iface => $ifacename): ?>
565
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && stristr($pconfig['interface'], $iface)) echo "selected"; ?>><?=gettext($ifacename);?></option>
566
<?php 				endforeach; ?>
567
				</select>
568
				<br />
569
				<span class="vexpl">Choose on which interface packets must come in to match this rule.</span>
570
			</td>
571
		</tr>
572
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
573
                <tr>
574
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Direction");?></td>
575
                        <td width="78%" class="vtable">
576
                                 <select name="direction" class="formselect">
577
                                  <?php      $directions = array('any', 'in', 'out');
578
                                        foreach ($directions as $direction): ?>
579
                                                <option value="<?=$direction;?>"
580
                                                <?php if ($direction == $pconfig['direction']): ?>
581
                                                        selected="selected" 
582
						<?php endif; ?>
583
                                                ><?=$direction;?></option>
584
                  	                <?php endforeach; ?>      
585
                                </select>
586
                		<input type="hidden" id="floating" name="floating" value="floating">
587
                        </td>
588
                <tr>
589
<?php endif; ?>
590
		<tr>
591
			<td width="22%" valign="top" class="vncellreq">Protocol</td>
592
			<td width="78%" class="vtable">
593
				<select name="proto" class="formselect" onchange="proto_change()">
594
<?php
595
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IGMP any carp pfsync");
596
				foreach ($protocols as $proto): ?>
597
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
598
<?php 			endforeach; ?>
599
				</select>
600
				<br />
601
				<span class="vexpl">Choose which IP protocol this rule should match. <br /> Hint: in most cases, you should specify <em>TCP</em> &nbsp;here.</span>
602
			</td>
603
		</tr>
604
		<tr id="icmpbox" name="icmpbox">
605
			<td valign="top" class="vncell">ICMP type</td>
606
			<td class="vtable">
607
				<select name="icmptype" class="formselect">
608
<?php
609
				$icmptypes = array(
610
				"" => "any",
611
				"echorep" => "Echo reply",
612
				"unreach" => "Destination unreachable",
613
				"squench" => "Source quench",
614
				"redir" => "Redirect",
615
				"althost" => "Alternate Host",
616
				"echoreq" => "Echo",
617
				"routeradv" => "Router advertisement",
618
				"routersol" => "Router solicitation",
619
				"timex" => "Time exceeded",
620
				"paramprob" => "Invalid IP header",
621
				"timereq" => "Timestamp",
622
				"timerep" => "Timestamp reply",
623
				"inforeq" => "Information request",
624
				"inforep" => "Information reply",
625
				"maskreq" => "Address mask request",
626
				"maskrep" => "Address mask reply"
627
				);
628

    
629
				foreach ($icmptypes as $icmptype => $descr): ?>
630
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
631
<?php 			endforeach; ?>
632
			</select>
633
			<br />
634
			<span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span>
635
		</td>
636
		</tr>
637
		<tr>
638
			<td width="22%" valign="top" class="vncellreq">Source</td>
639
			<td width="78%" class="vtable">
640
				<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
641
				<strong>not</strong>
642
				<br />
643
				Use this option to invert the sense of the match.
644
				<br />
645
				<br />
646
				<table border="0" cellspacing="0" cellpadding="0">
647
					<tr>
648
						<td>Type:&nbsp;&nbsp;</td>
649
						<td>
650
							<select name="srctype" class="formselect" onChange="typesel_change()">
651
<?php
652
								$sel = is_specialnet($pconfig['src']); ?>
653
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>any</option>
654
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
655
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
656
								<?php if(have_ruleint_access("pptp")): ?>
657
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
658
								<?php endif; ?>
659
								<?php if(have_ruleint_access("pppoe")): ?>
660
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
661
								<?php endif; ?>								
662
<?php
663
								$ifdisp = get_configured_interface_with_descr();
664
								foreach ($ifdisp as $ifent => $ifdesc): ?>
665
								<?php if(have_ruleint_access($ifent)): ?>
666
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> subnet</option>
667
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected"; } ?>>
668
										<?=$ifdesc?> address
669
									</option>
670
								<?php endif; ?>
671
<?php 							endforeach; ?>
672
							</select>
673
						</td>
674
					</tr>
675
					<tr>
676
						<td>Address:&nbsp;&nbsp;</td>
677
						<td>
678
							<input autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>"> /
679
							<select name="srcmask" class="formselect" id="srcmask">
680
<?php						for ($i = 31; $i > 0; $i--): ?>
681
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
682
<?php 						endfor; ?>
683
							</select>
684
						</td>
685
					</tr>
686
				</table>
687
				<div id="showadvancedboxspr">
688
					<p>
689
					<input type="button" onClick="show_source_port_range()" value="Advanced"></input> - Show source port range</a>
690
				</div>
691
			</td>
692
		</tr>
693
		<tr style="display:none" id="sprtable" name="sprtable">
694
			<td width="22%" valign="top" class="vncellreq">Source port range</td>
695
			<td width="78%" class="vtable">
696
				<table border="0" cellspacing="0" cellpadding="0">
697
					<tr>
698
						<td>from:&nbsp;&nbsp;</td>
699
						<td>
700
							<select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
701
								<option value="">(other)</option>
702
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
703
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
704
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
705
<?php 							endforeach; ?>
706
							</select>
707
							<input autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>">
708
						</td>
709
					</tr>
710
					<tr>
711
						<td>to:</td>
712
						<td>
713
							<select name="srcendport" class="formselect" onchange="ext_change()">
714
								<option value="">(other)</option>
715
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
716
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
717
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
718
<?php							endforeach; ?>
719
							</select>
720
							<input autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>">
721
						</td>
722
					</tr>
723
				</table>
724
				<br />
725
				<span class="vexpl">Specify the port or port range for the source of the packet for this rule. This is usually not equal to the destination port range (and is often &quot;any&quot;). <br /> Hint: you can leave the <em>'to'</em> field empty if you only want to filter a single port</span><br/>
726
				<span class="vexpl"><B>NOTE:</B> You will not need to enter anything here in 99.99999% of the circumstances.  If you're unsure, do not enter anything here!</span>
727
			</td>
728
		</tr>
729
		<tr>
730
			<td width="22%" valign="top" class="vncell">Source OS</td>
731
			<td width="78%" class="vtable">OS Type:&nbsp;
732
				<select name="os" id="os" class="formselect">
733
<?php
734
		           $ostypes = array(
735
						 "" => "any",
736
		                 "AIX" => "AIX",
737
		                 "Linux" => "Linux",
738
		                 "FreeBSD" => "FreeBSD",
739
		                 "NetBSD" => "NetBSD",
740
		                 "OpenBSD" => "OpenBSD",
741
		                 "Solaris" => "Solaris",
742
		                 "MacOS" => "MacOS",
743
		                 "Windows" => "Windows",
744
		                 "Novell" => "Novell",
745
		                 "NMAP" => "NMAP"
746
		           );
747

    
748
					foreach ($ostypes as $ostype => $descr): ?>
749
						<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
750
<?php				endforeach; ?>
751
				</select>
752
				<br />
753
				Note: this only works for TCP rules
754
			</td>
755
		</tr>
756
		<tr>
757
			<td width="22%" valign="top" class="vncellreq">Destination</td>
758
			<td width="78%" class="vtable">
759
				<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
760
				<strong>not</strong>
761
					<br />
762
				Use this option to invert the sense of the match.
763
					<br />
764
					<br />
765
				<table border="0" cellspacing="0" cellpadding="0">
766
					<tr>
767
						<td>Type:&nbsp;&nbsp;</td>
768
						<td>
769
							<select name="dsttype" class="formselect" onChange="typesel_change()">
770
<?php
771
								$sel = is_specialnet($pconfig['dst']); ?>
772
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>any</option>
773
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
774
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
775
								<?php if(have_ruleint_access("wan")): ?>
776
								<option value="wanip" <?php if ($pconfig['dst'] == "wanip") { echo "selected"; } ?>>WAN address</option>
777
								<?php endif; ?>
778
								<?php if(have_ruleint_access("lan")): ?>
779
								<option value="lanip" <?php if ($pconfig['dst'] == "lanip") { echo "selected"; } ?>>LAN address</option>
780
								<?php endif; ?>
781
								<?php if(have_ruleint_access("lan")): ?>
782
								<option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>LAN subnet</option>
783
								<?php endif; ?>
784
								<?php if(have_ruleint_access("pptp")): ?>
785
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
786
								<?php endif; ?>
787
								<?php if(have_ruleint_access("pppoe")): ?>
788
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
789
								<?php endif; ?>								
790
								
791

    
792
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
793
								<?php if(have_ruleint_access($if)): ?>
794
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> subnet</option>
795
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
796
										<?=$ifdesc;?> address
797
									</option>
798
								<?php endif; ?>
799
<?php 							endforeach; ?>
800
							</select>
801
						</td>
802
					</tr>
803
					<tr>
804
						<td>Address:&nbsp;&nbsp;</td>
805
						<td>
806
							<input name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
807
							/
808
							<select name="dstmask" class="formselect" id="dstmask">
809
<?php
810
							for ($i = 31; $i > 0; $i--): ?>
811
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
812
<?php						endfor; ?>
813
							</select>
814
						</td>
815
					</tr>
816
				</table>
817

    
818
			</td>
819
		</tr>
820
		<tr id="dprtr" name="dprtr">
821
			<td width="22%" valign="top" class="vncellreq">Destination port range </td>
822
			<td width="78%" class="vtable">
823
				<table border="0" cellspacing="0" cellpadding="0">
824
					<tr>
825
						<td>from:&nbsp;&nbsp;</td>
826
						<td>
827
							<select name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
828
								<option value="">(other)</option>
829
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
830
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
831
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected"; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
832
<?php 							endforeach; ?>
833
							</select>
834
							<input autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>">
835
						</td>
836
					</tr>
837
					<tr>
838
						<td>to:</td>
839
						<td>
840
							<select name="dstendport" class="formselect" onchange="ext_change()">
841
								<option value="">(other)</option>
842
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
843
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
844
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
845
<?php 							endforeach; ?>
846
							</select>
847
							<input autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>">
848
						</td>
849
					</tr>
850
				</table>
851
				<br />
852
				<span class="vexpl">
853
					Specify the port or port range for the destination of the packet for this rule.
854
						<br />
855
					Hint: you can leave the <em>'to'</em> field empty if you only want to filter a single port
856
				</span>
857
			</td>
858
		</tr>
859
                <tr>
860
                        <td width="22%" valign="top" class="vncellreq">Diffserv Code Point</td>
861
                        <td width="78%" class="vtable">
862
                                <input name="dscp" id="dscp" value="<?=htmlspecialchars($pconfig['dscp']);?>">
863
                                        <br />
864
                                <span class="vexpl">Valid values are: af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, EF, 1-64, 0x04-0xfc.</span>
865
                        </td>
866
                </tr>
867
		<tr>
868
			<td width="22%" valign="top" class="vncellreq">Log</td>
869
			<td width="78%" class="vtable">
870
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
871
				<strong>Log packets that are handled by this rule</strong>
872
					<br />
873
				<span class="vexpl">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 (see the <a href="diag_logs_settings.php">Diagnostics: System logs: Settings</a> page).</span>
874
			</td>
875
		</tr>
876
		<tr>
877
			<td width="22%" valign="top" class="vncell">Advanced Options</td>
878
			<td width="78%" class="vtable">
879
			<div id="aoadv" name="aoadv">
880
				<input type="button" onClick="show_aodiv();" value="Advanced"> - Show advanced options
881
			</div>
882
			<div id="aodivmain" name="aodivmain" style="display:none">
883

    
884
                                <input type="checkbox" id="allowopts" value="yes" name="allowopts"<?php if($pconfig['allowopts'] == true) echo " checked"; ?>>
885
                                <br/><span class="vexpl"><?=gettext("This allows packets with ip options to pass otherwise they are blocked by default i.e. with multicast routing/proxing.");?>
886
				</span><p>
887
                                <input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
888
                                <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>Policy filtering</b>");?>
889
                                </span><p>
890
                                <input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>">
891
                                <br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before on another rule.")?>
892
                                </span> <p>
893
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
894
				<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
895
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
896
				<select name="max-src-conn-rates" id="max-src-conn-rates">
897
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
898
<?php				for($x=1; $x<255; $x++) {
899
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
900
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
901
					} ?>
902
				</select><br />
903
				Maximum new connections / per second
904
				<p>
905

    
906
				<input name="statetimeout" value="<?php echo $pconfig['statetimeout'] ?>"><br>
907
				State Timeout in seconds
908
				<p />
909

    
910
				<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
911
			  </div>
912
			</td>
913
		</tr>
914
		<tr>
915
			<td width="22%" valign="top" class="vncell">State Type</td>
916
			<td width="78%" class="vtable">
917
				<div id="showadvstatebox">
918
					<input type="button" onClick="show_advanced_state()" value="Advanced"></input> - Show state</a>
919
				</div>
920
				<div id="showstateadv" style="display:none">
921
					<select name="statetype">
922
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
923
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>>synproxy state</option>
924
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
925
					</select><br>HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.
926
					<p>
927
					<table width="90%">
928
						<tr><td width="25%"><ul><li>keep state</li></td><td>Works with all IP protocols.</ul></td></tr>
929
						<tr><td width="25%"><ul><li>synproxy state</li></td><td>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.</ul></td></tr>
930
						<tr><td width="25%"><ul><li>none</li></td><td>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.</ul></td></tr>
931
					</table>
932
					</p>
933
			  </div>
934
			</td>
935
		</tr>
936
		<tr>
937
			<td width="22%" valign="top" class="vncell">No XMLRPC Sync</td>
938
			<td width="78%" class="vtable">
939
				<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
940
				HINT: This prevents the rule from automatically syncing to other carp members.
941
			</td>
942
		</tr>
943
		<?php
944
			//build list of schedules
945
			$schedules = array();
946
			$schedules[] = "none";//leave none to leave rule enabled all the time
947
			if(is_array($config['schedules']['schedule'])) {
948
				foreach ($config['schedules']['schedule'] as $schedule) {
949
					if ($schedule['name'] <> "")
950
						$schedules[] = $schedule['name'];
951
				}
952
			}
953
		?>
954
		<tr>
955
			<td width="22%" valign="top" class="vncell">Schedule</td>
956
			<td width="78%" class="vtable">
957
				<select name='sched'>
958
<?php
959
				foreach($schedules as $schedule) {
960
					if($schedule == $pconfig['sched']) {
961
						$selected = " SELECTED";
962
					} else {
963
						$selected = "";
964
					}
965
					if ($schedule == "none") {
966
						echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
967
					} else {
968
						echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
969
					}
970
				}?>
971
				</select>
972
				<p>Leave as 'none' to leave the rule enabled all the time.</p>
973
			</td>
974
		</tr>
975
		
976
<?php
977
			/* build a list of gateways */
978
			$gateways = array();
979
			$gateways[] = "default"; // default to don't use this feature :)
980
			if (is_array($config['gateways']['gateway_item'])) {
981
				foreach($config['gateways']['gateway_item'] as $gw_item) {
982
				if($gw_item['gateway'] <> "")
983
					$gateways[] = $gw_item['name'];
984
				}
985
			}
986
			
987
?>
988
		<tr>
989
			<td width="22%" valign="top" class="vncell">Gateway</td>
990
			<td width="78%" class="vtable">
991
				<select name='gateway'>
992
<?php
993
				foreach($gateways as $gw) {
994
					if($gw == "") 
995
						continue;
996
					if($gw == $pconfig['gateway']) {
997
						$selected = " SELECTED";
998
					} else {
999
						$selected = "";
1000
					}
1001
					if ($gw == "default") {
1002
						echo "<option value=\"\" {$selected}>{$gw}</option>\n";
1003
					} else {
1004
						$gwip = lookup_gateway_ip_by_name($gw);
1005
						echo "<option value=\"{$gw}\" {$selected}>{$gw} - {$gwip}</option>\n";
1006
					}
1007
				}
1008
				/* add gateway groups to the list */
1009
				if (is_array($config['gateways']['gateway_group'])) {
1010
					foreach($config['gateways']['gateway_group'] as $gw_group) {
1011
						if($gw_group['name'] == "")
1012
							continue;
1013
						if($pconfig['gateway'] == $gw_group['name']) {
1014
							echo "<option value=\"{$gw_group['name']}\" SELECTED>{$gw_group['name']}</option>\n";
1015
						} else {
1016
							echo "<option value=\"{$gw_group['name']}\">{$gw_group['name']}</option>\n";
1017
						}
1018
					}
1019
				}
1020
				$iflist = get_configured_interface_with_descr();
1021
				foreach ($iflist as $ifent => $ifdesc) {
1022
					if (in_array($config['interfaces'][$ifent]['ipaddr'],
1023
						 array("dhcp", "pppoe", "pptp"))) {
1024
						if ($pconfig['gateway'] == $ifent) {
1025
							$selected = " SELECTED";
1026
						} else {
1027
							$selected = "";
1028
						}
1029
						if($ifdesc <> "") 
1030
							echo "<option value=\"{$ifent}\" {$selected}>".strtoupper($if)." - {$ifdesc}</option>\n";
1031
					}
1032
				}
1033
?>
1034
				</select>
1035
				<p><strong>Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.</strong></p>
1036
			</td>
1037
		</tr>
1038
		<tr>
1039
			<td width="22%" valign="top" class="vncell">In/Out</td>
1040
			<td width="78%" class="vtable">
1041
			<select name="dnpipe">
1042
<?php
1043
		if (!is_array($dnqlist))
1044
			$dnqlist = array();
1045
		echo "<option value=\"none\"";
1046
		if (!$dnqselected) echo " SELECTED";
1047
		echo " >none</option>";
1048
		foreach ($dnqlist as $dnq => $dnqkey) {
1049
			if($dnq == "")
1050
				continue;
1051
			echo "<option value=\"$dnqkey\"";
1052
			if ($dnqkey == $pconfig['dnpipe']) {
1053
				$dnqselected = 1;
1054
				echo " SELECTED";
1055
			}
1056
			echo ">{$dnq}</option>"; 
1057
		}
1058
?>
1059
			</select> / 			
1060
			<select name="pdnpipe">
1061
<?php
1062
		$dnqselected = 0;
1063
		echo "<option value=\"none\"";
1064
		if (!$dnqselected) echo " SELECTED";
1065
		echo " >none</option>";
1066
		foreach ($dnqlist as $dnq => $dnqkey) {
1067
			if($dnq == "")
1068
				continue;
1069
			echo "<option value=\"$dnqkey\"";
1070
			if ($dnqkey == $pconfig['pdnpipe']) {
1071
				$dnqselected = 1;
1072
				echo " SELECTED";
1073
			}
1074
			echo ">{$dnq}</option>"; 
1075
		}
1076
?>
1077
			</select>
1078
				<br />
1079
				<span class="vexpl">Choose the Out queue/Virtual interface only if you have selected In too. <br/> The Out selection is applied to traffic going out the interface the rule is created, In is the incoming one. <br/> If you are creating a rule on the Floating tab 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 and if you do not select any direction use only the In since the Out selection does not make sense in there to prevent oddities.</span>
1080
			</td>
1081
		</tr>
1082

    
1083
		<tr>
1084
			<td width="22%" valign="top" class="vncell">Ackqueue/Queue</td>
1085
			<td width="78%" class="vtable">
1086
			<select name="ackqueue">
1087
<?php
1088
		if (!is_array($qlist))
1089
			$qlist = array();
1090
		echo "<option value=\"none\"";
1091
		if (!$qselected) echo " SELECTED";
1092
		echo " >none</option>";
1093
		foreach ($qlist as $q => $qkey) {
1094
			if($q == "")
1095
				continue;
1096
			echo "<option value=\"$q\"";
1097
			if ($q == $pconfig['ackqueue']) {
1098
				$qselected = 1;
1099
				echo " SELECTED";
1100
			}
1101
			echo ">{$q}</option>"; 
1102
		}
1103
?>
1104
			</select> / 			
1105
			<select name="defaultqueue">
1106
<?php
1107
		$qselected = 0;
1108
		echo "<option value=\"none\"";
1109
		if (!$qselected) echo " SELECTED";
1110
		echo " >none</option>";
1111
		foreach ($qlist as $q => $qkey) {
1112
			if($q == "")
1113
				continue;
1114
			echo "<option value=\"$q\"";
1115
			if ($q == $pconfig['defaultqueue']) {
1116
				$qselected = 1;
1117
				echo " SELECTED";
1118
			}
1119
			echo ">{$q}</option>"; 
1120
		}
1121
?>
1122
			</select>
1123
				<br />
1124
				<span class="vexpl">Choose the Acknowledge Queue only if you have selected Queue.</span>
1125
			</td>
1126
		</tr>
1127
		<tr>
1128
			<td width="22%" valign="top" class="vncell">Layer7</td>
1129
			<td width="78%" class="vtable">
1130
			<select name="l7container">
1131
<?php
1132
		if (!is_array($l7clist))
1133
			$dnqlist = array();
1134
		echo "<option value=\"none\"";
1135
		echo " >none</option>";
1136
		foreach ($l7clist as $l7ckey) {
1137
			echo "<option value=\"{$l7ckey}\"";
1138
			if ($l7ckey == $pconfig['l7container']) {
1139
				echo " SELECTED";
1140
			}
1141
			echo ">{$l7ckey}</option>"; 
1142
		}
1143
?>
1144
			</select>			
1145
				<br/>
1146
				<span class="vexpl">Choose a Layer7 container to apply application protocol inspection rules.
1147
				This rule are valid for tcp and udp protocols for now.</span>
1148
			</td>
1149
		</tr>
1150
		<tr>
1151
			<td width="22%" valign="top" class="vncell">Description</td>
1152
			<td width="78%" class="vtable">
1153
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
1154
				<br />
1155
				<span class="vexpl">You may enter a description here for your reference.</span>
1156
			</td>
1157
		</tr>
1158
		<tr>
1159
			<td width="22%" valign="top">&nbsp;</td>
1160
			<td width="78%">
1161
				<input name="Submit" type="submit" class="formbtn" value="Save">  <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
1162
<?php			if (isset($id) && $a_filter[$id]): ?>
1163
					<input name="id" type="hidden" value="<?=$id;?>">
1164
<?php 			endif; ?>
1165
				<input name="after" type="hidden" value="<?=$after;?>">
1166
			</td>
1167
		</tr>
1168
	</table>
1169
</form>
1170
<script language="JavaScript">
1171
<!--
1172
	ext_change();
1173
	typesel_change();
1174
	proto_change();
1175

    
1176
<?php
1177
	$isfirst = 0;
1178
	$aliases = "";
1179
	$addrisfirst = 0;
1180
	$aliasesaddr = "";
1181
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1182
		foreach($config['aliases']['alias'] as $alias_name) {
1183
			if(!stristr($alias_name['address'], ".")) {
1184
				if($isfirst == 1) $aliases .= ",";
1185
				$aliases .= "'" . $alias_name['name'] . "'";
1186
				$isfirst = 1;
1187
			} else {
1188
				if($addrisfirst == 1) $aliasesaddr .= ",";
1189
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1190
				$addrisfirst = 1;
1191
			}
1192
		}
1193
?>
1194

    
1195
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1196
	var customarray=new Array(<?php echo $aliases; ?>);
1197

    
1198
//-->
1199
</script>
1200

    
1201

    
1202
<?php include("fend.inc"); ?>
1203
</body>
1204
</html>
1205

    
(58-58/217)