Project

General

Profile

Download (44 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
require("guiconfig.inc");
35

    
36
$specialsrcdst = explode(" ", "any wanip lanip lan pptp pppoe");
37

    
38
if (!is_array($config['filter']['rule'])) {
39
	$config['filter']['rule'] = array();
40
}
41
filter_rules_sort();
42
$a_filter = &$config['filter']['rule'];
43

    
44
$id = $_GET['id'];
45
if (is_numeric($_POST['id']))
46
	$id = $_POST['id'];
47

    
48
$after = $_GET['after'];
49

    
50
if (isset($_POST['after']))
51
	$after = $_POST['after'];
52

    
53
if (isset($_GET['dup'])) {
54
	$id = $_GET['dup'];
55
	$after = $_GET['dup'];
56
}
57

    
58
if($id > -1) {
59
	$if = $a_filter[$id]['interface'];
60
	$security_url = "firewall_rules_edit.php?if=". strtolower($if);
61
	if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
62
		log_error("Checking for {$security_url}");
63
		if(!in_array($security_url, $allowed)) {
64
			// User does not have access
65
	//		echo "displaying error {$security_url}"; print_r($allowed);
66
			echo display_error_form("401", "Unauthorized. You do not have access to edit rules on the interface {$if}");
67
			exit;
68
		}
69
	}
70
}
71

    
72
if (isset($id) && $a_filter[$id]) {
73
	$pconfig['interface'] = $a_filter[$id]['interface'];
74

    
75
	if (!isset($a_filter[$id]['type']))
76
		$pconfig['type'] = "pass";
77
	else
78
		$pconfig['type'] = $a_filter[$id]['type'];
79

    
80
	if (isset($a_filter[$id]['floating']) || $if == "FloatingRules") {
81
		$pconfig['floating'] = $a_filter[$id]['floating'];
82
		if (isset($a_filter[$id]['interface']) && $a_filter[$id]['interface'] <> "") 
83
			$pconfig['interface'] = $a_filter[$id]['interface'];
84
	}
85
	
86
	if (isset($a_filter['floating'])) 
87
		$pconfig['floating'] = "yes";
88

    
89
	if (isset($a_filter[$id]['direction']))
90
                $pconfig['direction'] = $a_filter[$id]['direction'];
91

    
92
	if (isset($a_filter[$id]['protocol']))
93
		$pconfig['proto'] = $a_filter[$id]['protocol'];
94
	else
95
		$pconfig['proto'] = "any";
96

    
97
	if ($a_filter[$id]['protocol'] == "icmp")
98
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
99

    
100
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
101
		$pconfig['srcmask'], $pconfig['srcnot'],
102
		$pconfig['srcbeginport'], $pconfig['srcendport']);
103

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

    
107
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
108
		$pconfig['dstmask'], $pconfig['dstnot'],
109
		$pconfig['dstbeginport'], $pconfig['dstendport']);
110

    
111
	if ($a_filter[$id]['dscp'] <> "")
112
		$pconfig['dscp'] = $a_filter[$id]['dscp'];
113

    
114
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
115
	$pconfig['log'] = isset($a_filter[$id]['log']);
116
	$pconfig['descr'] = $a_filter[$id]['descr'];
117

    
118
	if (isset($a_filter[$id]['tag']) && $a_filter[$id]['tag'] <> "") 
119
		$pconfig['tag'] = $a_filter[$id]['tag'];
120
	if (isset($a_filter[$id]['tagged']) && $a_filter[$id]['tag'] <> "")
121
        	$pconfig['tagged'] = $a_filter[$id]['tagged'];
122
	if (isset($a_filter[$id]['quick']) && $a_filter[$id]['quick'])
123
		$pconfig['quick'] = $a_filter[$id]['quick'];
124

    
125
	/* advanced */
126
        $pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
127
        $pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
128
        $pconfig['statetype'] = $a_filter[$id]['statetype'];
129
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
130

    
131
	$pconfig['nosync'] = isset($a_filter[$id]['nosync']);
132

    
133
	/* advanced - new connection per second banning*/
134
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
135
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
136

    
137
	/* Multi-WAN next-hop support */
138
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
139
	
140
	/* Shaper support */
141
	$pconfig['defaultqueue'] = $a_filter[$id]['defaultqueue'];
142
	$pconfig['ackqueue'] = $a_filter[$id]['ackqueue'];
143

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

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

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

    
161
if ($_POST) {
162

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

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

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

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

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

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

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

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

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

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

    
236

    
237
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state") {
238
		if( $_POST['proto'] != "tcp" )
239
			$input_errors[] = "{$_POST['statetype']} is only valid with protocol tcp.";
240
		if(($_POST['statetype'] == "synproxy state") && ($_POST['gateway'] != ""))
241
			$input_errors[] = "{$_POST['statetype']} is only valid if the gateway is set to 'default'.";
242
	}
243

    
244

    
245
	if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
246
		$reqdfields[] = "srcmask";
247
		$reqdfieldsn[] = "Source bit count";
248
	}
249
	if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
250
		$reqdfields[] = "dstmask";
251
		$reqdfieldsn[] = "Destination bit count";
252
	}
253

    
254
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
255

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

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

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

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

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

    
321
	if ($_POST['ackqueue'] && $_POST['ackqueue'] != "none") {
322
		if ($_POST['defaultqueue'] == "none" )
323
			$input_errors[] = "You have to select a queue when you select an acknowledge queue too.";
324
		else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
325
			$input_errors[] = "Acknokledge queue and Queue cannot be the same.";		
326
	}
327

    
328
	if (!$input_errors) {
329
		$filterent = array();
330
		$filterent['type'] = $_POST['type'];
331
		if (isset($_POST['interface'] ))
332
			$filterent['interface'] = $_POST['interface'];
333

    
334
		if ($if == "FloatingRules" || isset($_POST['floating'])) {
335
			if (isset($_POST['tag']))
336
				$filterent['tag'] = $_POST['tag'];
337
			if (isset($_POST['tagged']))
338
            			$filterent['tagged'] = $_POST['tagged'];
339
			$filterent['direction'] = $_POST['direction'];
340
			if (isset($_POST['quick']) && $_POST['quick'] <> "")
341
				$filterent['quick'] = $_POST['quick'];
342
			$filterent['floating'] = "yes";
343
			if (isset($_POST['interface']) && count($_POST['interface']) > 0)  {
344
					$filterent['interface'] = implode(",", $_POST['interface']);
345
			}
346
		}
347

    
348
		/* Advanced options */
349
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
350
		$filterent['max-src-states'] = $_POST['max-src-states'];
351
		$filterent['statetimeout'] = $_POST['statetimeout'];
352
		$filterent['statetype'] = $_POST['statetype'];
353
		$filterent['os'] = $_POST['os'];
354

    
355
		/* Nosync directive - do not xmlrpc sync this item */
356
		if($_POST['nosync'] <> "")
357
			$filterent['nosync'] = true;
358
		else
359
			unset($filterent['nosync']);
360

    
361
		/* unless both values are provided, unset the values - ticket #650 */
362
		if($_POST['max-src-conn-rate'] <> "" and $_POST['max-src-conn-rates'] <> "") {
363
			$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
364
			$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
365
		} else {
366
			unset($filterent['max-src-conn-rate']);
367
			unset($filterent['max-src-conn-rates']);
368
		}
369

    
370
		if ($_POST['proto'] != "any")
371
			$filterent['protocol'] = $_POST['proto'];
372
		else
373
			unset($filterent['protocol']);
374

    
375
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
376
			$filterent['icmptype'] = $_POST['icmptype'];
377
		else
378
			unset($filterent['icmptype']);
379

    
380
		pconfig_to_address($filterent['source'], $_POST['src'],
381
			$_POST['srcmask'], $_POST['srcnot'],
382
			$_POST['srcbeginport'], $_POST['srcendport']);
383

    
384
		pconfig_to_address($filterent['destination'], $_POST['dst'],
385
			$_POST['dstmask'], $_POST['dstnot'],
386
			$_POST['dstbeginport'], $_POST['dstendport']);
387

    
388
                if ($_POST['disabled'])
389
                        $filterent['disabled'] = true;
390
                else
391
                        unset($filterent['disabled']);
392
		
393
		if ($_POST['dscp'])
394
			$filterent['dscp'] = $_POST['dscp'];
395

    
396
                if ($_POST['log'])
397
                        $filterent['log'] = true;
398
                else
399
                        unset($filterent['log']);
400
		strncpy($filterent['descr'], $_POST['descr'], 52);
401

    
402
		if ($_POST['gateway'] != "") {
403
			$filterent['gateway'] = $_POST['gateway'];
404
		}
405
		
406
		if (isset($_POST['defaultqueue']) && $_POST['defaultqueue'] != "none") {
407
			$filterent['defaultqueue'] = $_POST['defaultqueue'];
408
			if (isset($_POST['ackqueue']) && $_POST['ackqueue'] != "none")
409
				$filterent['ackqueue'] = $_POST['ackqueue'];
410
		}
411

    
412
		if ($_POST['sched'] != "") {
413
			$filterent['sched'] = $_POST['sched'];
414
		}
415

    
416
		if (isset($id) && $a_filter[$id])
417
			$a_filter[$id] = $filterent;
418
		else {
419
			if (is_numeric($after))
420
				array_splice($a_filter, $after+1, 0, array($filterent));
421
			else
422
				$a_filter[] = $filterent;
423
		}
424

    
425
		write_config();
426
		touch($d_filterconfdirty_path);
427

    
428
		if (isset($_POST['floating']))
429
			header("Location: firewall_rules.php?if=FloatingRules");
430
		else
431
			header("Location: firewall_rules.php?if=" . $_POST['interface']);
432
		exit;
433
	}
434
}
435

    
436
$pgtitle = array("Firewall","Rules","Edit");
437
$closehead = false;
438

    
439
$page_filename = "firewall_rules_edit.php";
440
include("head.inc");
441

    
442
?>
443

    
444
</head>
445

    
446
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
447
<?php include("fbegin.inc"); ?>
448
<?php if ($input_errors) print_input_errors($input_errors); ?>
449

    
450
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
451
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
452
    	<tr>
453
			<td width="22%" valign="top" class="vncellreq">Action</td>
454
			<td width="78%" class="vtable">
455
				<select name="type" class="formselect">
456
					<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
457
					<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
458
					<?=htmlspecialchars($type);?>
459
					</option>
460
					<?php endforeach; ?>
461
				</select>
462
				<br/>
463
				<span class="vexpl">
464
					Choose what to do with packets that match the criteria specified below. <br/>
465
					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.
466
				</span>
467
			</td>
468
		</tr>
469
		<tr>
470
			<td width="22%" valign="top" class="vncellreq">Disabled</td>
471
			<td width="78%" class="vtable">
472
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
473
				<strong>Disable this rule</strong><br />
474
				<span class="vexpl">Set this option to disable this rule without removing it from the list.</span>
475
			</td>
476
		</tr>
477
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
478
		<tr>
479
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Quick");?></td>
480
                        <td width="78%" class="vtable">
481
                                <input name="quick" type="checkbox" id="quick" value="yes" <?php if ($pconfig['quick']) echo "checked=\"checked\""; ?> />
482
                                <strong><?=gettext("Apply the action immediately on match.");?></strong><br />
483
                                <span class="vexpl"><?=gettext("Set this option if you need to apply this action to traffic that matches this rule immediately.");?></span>
484
                        </td>
485
                </tr>
486
<? endif; ?>
487
		<tr>
488
			<td width="22%" valign="top" class="vncellreq">Interface</td>
489
			<td width="78%" class="vtable">
490
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
491
				<select name="interface[]" multiple="true" class="formselect" size="3">
492
<? else: ?>
493
				<select name="interface" class="formselect">
494
<?php
495
   endif;
496

    
497
					$interfaces = array();
498
					if($config['interfaces']['lan']) {
499
                                                /* only add LAN if it exists */
500
        					if(have_ruleint_access("lan")) 
501
        						$interfaces['lan'] = "LAN";                                                
502
                                        }
503
					if(have_ruleint_access("wan")) 
504
						$interfaces['wan'] = "WAN";
505
						
506
					for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) 
507
						if(have_ruleint_access("opt{$i}")) 
508
							$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
509
					
510
					if ($config['pptpd']['mode'] == "server")
511
						if(have_ruleint_access("pptp")) 
512
							$interfaces['pptp'] = "PPTP VPN";
513
					
514
					if ($config['pppoe']['mode'] == "server")
515
						if(have_ruleint_access("pppoe")) 
516
							$interfaces['pppoe'] = "PPPoE VPN";
517
					
518
					/* add ipsec interfaces */
519
					if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
520
						if(have_ruleint_access("enc0")) 
521
							$interfaces["enc0"] = "IPsec";
522
		
523
					/* add openvpn/tun interfaces */
524
					if  ($config['installedpackages']["openvpnserver"] || $config['installedpackages']["openvpnclient"]) {
525
					        if (is_array($config['installedpackages']["openvpnserver"]['config']) ||
526
                					is_array($config['installedpackages']["openvpnclient"]['config']))
527
        					$interfaces["openvpn"] = "OpenVPN";
528
					}
529

    
530

    
531
					foreach ($interfaces as $iface => $ifacename): ?>
532
						<option value="<?=$iface;?>" <?php if ($pconfig['interface'] <> "" && stristr($pconfig['interface'], $iface)) echo "selected"; ?>><?=gettext($ifacename);?></option>
533
<?php 				endforeach; ?>
534
				</select>
535
				<br />
536
				<span class="vexpl">Choose on which interface packets must come in to match this rule.</span>
537
			</td>
538
		</tr>
539
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
540
                <tr>
541
                        <td width="22%" valign="top" class="vncellreq"><?=gettext("Direction");?></td>
542
                        <td width="78%" class="vtable">
543
                                 <select name="direction" class="formselect">
544
                                  <?php      $directions = array('any', 'in', 'out');
545
                                        foreach ($directions as $direction): ?>
546
                                                <option value="<?=$direction;?>"
547
                                                <?php if ($direction == $pconfig['direction']): ?>
548
                                                        selected="selected" 
549
						<?php endif; ?>
550
                                                ><?=$direction;?></option>
551
                  	                <?php endforeach; ?>      
552
                                </select>
553
                        </td>
554
                <tr>
555
<?php endif; ?>
556
		<tr>
557
			<td width="22%" valign="top" class="vncellreq">Protocol</td>
558
			<td width="78%" class="vtable">
559
				<select name="proto" class="formselect" onchange="proto_change()">
560
<?php
561
				$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IGMP any carp pfsync");
562
				foreach ($protocols as $proto): ?>
563
					<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>><?=htmlspecialchars($proto);?></option>
564
<?php 			endforeach; ?>
565
				</select>
566
				<br />
567
				<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>
568
			</td>
569
		</tr>
570
		<tr id="icmpbox" name="icmpbox">
571
			<td valign="top" class="vncell">ICMP type</td>
572
			<td class="vtable">
573
				<select name="icmptype" class="formselect">
574
<?php
575
				$icmptypes = array(
576
				"" => "any",
577
				"echorep" => "Echo reply",
578
				"unreach" => "Destination unreachable",
579
				"squench" => "Source quench",
580
				"redir" => "Redirect",
581
				"althost" => "Alternate Host",
582
				"echoreq" => "Echo",
583
				"routeradv" => "Router advertisement",
584
				"routersol" => "Router solicitation",
585
				"timex" => "Time exceeded",
586
				"paramprob" => "Invalid IP header",
587
				"timereq" => "Timestamp",
588
				"timerep" => "Timestamp reply",
589
				"inforeq" => "Information request",
590
				"inforep" => "Information reply",
591
				"maskreq" => "Address mask request",
592
				"maskrep" => "Address mask reply"
593
				);
594

    
595
				foreach ($icmptypes as $icmptype => $descr): ?>
596
					<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
597
<?php 			endforeach; ?>
598
			</select>
599
			<br />
600
			<span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span>
601
		</td>
602
		</tr>
603
		<tr>
604
			<td width="22%" valign="top" class="vncellreq">Source</td>
605
			<td width="78%" class="vtable">
606
				<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
607
				<strong>not</strong>
608
				<br />
609
				Use this option to invert the sense of the match.
610
				<br />
611
				<br />
612
				<table border="0" cellspacing="0" cellpadding="0">
613
					<tr>
614
						<td>Type:&nbsp;&nbsp;</td>
615
						<td>
616
							<select name="srctype" class="formselect" onChange="typesel_change()">
617
<?php
618
								$sel = is_specialnet($pconfig['src']); ?>
619
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>any</option>
620
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
621
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
622
								<?php if(have_ruleint_access("wan")): ?>
623
								<option value="wanip" 	<?php if ($pconfig['src'] == "wanip") { echo "selected"; } ?>>WAN address</option>
624
								<?php endif; ?>
625
								<?php if(have_ruleint_access("lan")): ?>
626
								<option value="lanip" 	<?php if ($pconfig['src'] == "lanip") { echo "selected"; } ?>>LAN address</option>
627
								<?php endif; ?>
628
								<?php if(have_ruleint_access("lan")): ?>
629
								<option value="lan"     <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>LAN subnet</option>
630
								<?php endif; ?>
631
								<?php if(have_ruleint_access("pptp")): ?>
632
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
633
								<?php endif; ?>
634
								<?php if(have_ruleint_access("pppoe")): ?>
635
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
636
								<?php endif; ?>								
637
<?php
638
								for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
639
								<?php if(have_ruleint_access("opt{$i}")): ?>
640
									<option value="opt<?=$i;?>" <?php if ($pconfig['src'] == "opt" . $i) { echo "selected"; } ?>><?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
641
									<option value="opt<?=$i;?>ip"<?php if ($pconfig['src'] == "opt" . $i . "ip") { echo "selected"; } ?>>
642
										<?=$config['interfaces']['opt' . $i]['descr']?> address
643
									</option>
644
								<?php endif; ?>
645
<?php 							endfor; ?>
646
							</select>
647
						</td>
648
					</tr>
649
					<tr>
650
						<td>Address:&nbsp;&nbsp;</td>
651
						<td>
652
							<input autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>"> /
653
							<select name="srcmask" class="formselect" id="srcmask">
654
<?php						for ($i = 31; $i > 0; $i--): ?>
655
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
656
<?php 						endfor; ?>
657
							</select>
658
						</td>
659
					</tr>
660
				</table>
661
				<div id="showadvancedboxspr">
662
					<p>
663
					<input type="button" onClick="show_source_port_range()" value="Advanced"></input> - Show source port range</a>
664
				</div>
665
			</td>
666
		</tr>
667
		<tr style="display:none" id="sprtable" name="sprtable">
668
			<td width="22%" valign="top" class="vncellreq">Source port range</td>
669
			<td width="78%" class="vtable">
670
				<table border="0" cellspacing="0" cellpadding="0">
671
					<tr>
672
						<td>from:&nbsp;&nbsp;</td>
673
						<td>
674
							<select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
675
								<option value="">(other)</option>
676
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
677
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
678
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
679
<?php 							endforeach; ?>
680
							</select>
681
							<input autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>">
682
						</td>
683
					</tr>
684
					<tr>
685
						<td>to:</td>
686
						<td>
687
							<select name="srcendport" class="formselect" onchange="ext_change()">
688
								<option value="">(other)</option>
689
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
690
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
691
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
692
<?php							endforeach; ?>
693
							</select>
694
							<input autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>">
695
						</td>
696
					</tr>
697
				</table>
698
				<br />
699
				<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/>
700
				<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>
701
			</td>
702
		</tr>
703
		<tr>
704
			<td width="22%" valign="top" class="vncellreq">Source OS</td>
705
			<td width="78%" class="vtable">OS Type:&nbsp;
706
				<select name="os" id="os" class="formselect">
707
<?php
708
		           $ostypes = array(
709
						 "" => "any",
710
		                 "AIX" => "AIX",
711
		                 "Linux" => "Linux",
712
		                 "FreeBSD" => "FreeBSD",
713
		                 "NetBSD" => "NetBSD",
714
		                 "OpenBSD" => "OpenBSD",
715
		                 "Solaris" => "Solaris",
716
		                 "MacOS" => "MacOS",
717
		                 "Windows" => "Windows",
718
		                 "Novell" => "Novell",
719
		                 "NMAP" => "NMAP"
720
		           );
721

    
722
					foreach ($ostypes as $ostype => $descr): ?>
723
						<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>><?=htmlspecialchars($descr);?></option>
724
<?php				endforeach; ?>
725
				</select>
726
				<br />
727
				Note: this only works for TCP rules
728
			</td>
729
		</tr>
730
		<tr>
731
			<td width="22%" valign="top" class="vncellreq">Destination</td>
732
			<td width="78%" class="vtable">
733
				<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
734
				<strong>not</strong>
735
					<br />
736
				Use this option to invert the sense of the match.
737
					<br />
738
					<br />
739
				<table border="0" cellspacing="0" cellpadding="0">
740
					<tr>
741
						<td>Type:&nbsp;&nbsp;</td>
742
						<td>
743
							<select name="dsttype" class="formselect" onChange="typesel_change()">
744
<?php
745
								$sel = is_specialnet($pconfig['dst']); ?>
746
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>any</option>
747
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>Single host or alias</option>
748
								<option value="network" <?php if (!$sel) echo "selected"; ?>>Network</option>
749
								<?php if(have_ruleint_access("wan")): ?>
750
								<option value="wanip" <?php if ($pconfig['dst'] == "wanip") { echo "selected"; } ?>>WAN address</option>
751
								<?php endif; ?>
752
								<?php if(have_ruleint_access("lan")): ?>
753
								<option value="lanip" <?php if ($pconfig['dst'] == "lanip") { echo "selected"; } ?>>LAN address</option>
754
								<?php endif; ?>
755
								<?php if(have_ruleint_access("lan")): ?>
756
								<option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>LAN subnet</option>
757
								<?php endif; ?>
758
								<?php if(have_ruleint_access("pptp")): ?>
759
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>PPTP clients</option>
760
								<?php endif; ?>
761
								<?php if(have_ruleint_access("pppoe")): ?>
762
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected"; } ?>>PPPoE clients</option>
763
								<?php endif; ?>								
764
								
765
<?php 							for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
766
								<?php if(have_ruleint_access("opt{$i}")): ?>
767
									<option value="opt<?=$i;?>" <?php if ($pconfig['dst'] == "opt" . $i) { echo "selected"; } ?>><?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
768
									<option value="opt<?=$i;?>ip"<?php if ($pconfig['dst'] == "opt" . $i . "ip") { echo "selected"; } ?>>
769
										<?=$config['interfaces']['opt' . $i]['descr']?> address
770
									</option>
771
								<?php endif; ?>
772
<?php 							endfor; ?>
773
							</select>
774
						</td>
775
					</tr>
776
					<tr>
777
						<td>Address:&nbsp;&nbsp;</td>
778
						<td>
779
							<input name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
780
							/
781
							<select name="dstmask" class="formselect" id="dstmask">
782
<?php
783
							for ($i = 31; $i > 0; $i--): ?>
784
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
785
<?php						endfor; ?>
786
							</select>
787
						</td>
788
					</tr>
789
				</table>
790

    
791
			</td>
792
		</tr>
793
		<tr id="dprtr" name="dprtr">
794
			<td width="22%" valign="top" class="vncellreq">Destination port range </td>
795
			<td width="78%" class="vtable">
796
				<table border="0" cellspacing="0" cellpadding="0">
797
					<tr>
798
						<td>from:&nbsp;&nbsp;</td>
799
						<td>
800
							<select name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
801
								<option value="">(other)</option>
802
								<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
803
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
804
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected"; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
805
<?php 							endforeach; ?>
806
							</select>
807
							<input autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>">
808
						</td>
809
					</tr>
810
					<tr>
811
						<td>to:</td>
812
						<td>
813
							<select name="dstendport" class="formselect" onchange="ext_change()">
814
								<option value="">(other)</option>
815
								<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
816
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
817
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected"; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
818
<?php 							endforeach; ?>
819
							</select>
820
							<input autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>">
821
						</td>
822
					</tr>
823
				</table>
824
				<br />
825
				<span class="vexpl">
826
					Specify the port or port range for the destination of the packet for this rule.
827
						<br />
828
					Hint: you can leave the <em>'to'</em> field empty if you only want to filter a single port
829
				</span>
830
			</td>
831
		</tr>
832
                <tr>
833
                        <td width="22%" valign="top" class="vncellreq">Diffserv Code Point</td>
834
                        <td width="78%" class="vtable">
835
                                <input name="dscp" id="dscp" value="<?=htmlspecialchars($pconfig['dscp']);?>">
836
                                        <br />
837
                                <span class="vexpl">Valid values are: af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, EF, 1-64, 0x04-0xfc.</span>
838
                        </td>
839
                </tr>
840
		<tr>
841
			<td width="22%" valign="top" class="vncellreq">Log</td>
842
			<td width="78%" class="vtable">
843
				<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
844
				<strong>Log packets that are handled by this rule</strong>
845
					<br />
846
				<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>
847
			</td>
848
		</tr>
849
		<tr>
850
			<td width="22%" valign="top" class="vncell">Advanced Options</td>
851
			<td width="78%" class="vtable">
852
			<div id="aoadv" name="aoadv">
853
				<input type="button" onClick="show_aodiv();" value="Advanced"> - Show advanced options
854
			</div>
855
			<div id="aodivmain" name="aodivmain" style="display:none">
856
<?php if ($if == "FloatingRules" || isset($pconfig['floating'])): ?>
857
                <input type="hidden" id="floating" name="floating" value="floating">
858

    
859
                                <input name="tag" id="tag" value="<?=htmlspecialchars($pconfig['tag']);?>">
860
                                <br /><span class="vexpl"><?=gettext("You can mark a packet matching this rule and
861
use this mark to match on other rules. It is called <b>Policy filtering</b>");?>
862
                                </span><p>
863
<?php endif; ?>
864
                                <input name="tagged" id="tagged" value="<?=htmlspecialchars($pconfig['tagged']);?>"
865
>
866
                                <br /><span class="vexpl"><?=gettext("You can match packet on a mark placed before
867
on another rule.")?>
868
                                </span> <p>
869

    
870
				<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
871
				<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
872
				<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
873
				<select name="max-src-conn-rates" id="max-src-conn-rates">
874
					<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
875
<?php				for($x=1; $x<255; $x++) {
876
						if($x == $pconfig['max-src-conn-rates']) $selected = " selected"; else $selected = "";
877
						echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
878
					} ?>
879
				</select><br />
880
				Maximum new connections / per second
881
				<p>
882

    
883
				<input name="statetimeout" value="<?php echo $pconfig['statetimeout'] ?>"><br>
884
				State Timeout in seconds
885
				<p />
886

    
887
				<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
888
			  </div>
889
			</td>
890
		</tr>
891
		<tr>
892
			<td width="22%" valign="top" class="vncell">State Type</td>
893
			<td width="78%" class="vtable">
894
				<div id="showadvstatebox">
895
					<input type="button" onClick="show_advanced_state()" value="Advanced"></input> - Show state</a>
896
				</div>
897
				<div id="showstateadv" style="display:none">
898
					<select name="statetype">
899
						<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
900
						<option value="modulate state" <?php if($pconfig['statetype'] == "modulate state")  echo "selected"; ?>>modulate state</option>
901
						<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>>synproxy state</option>
902
						<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
903
					</select><br>HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.
904
					<p>
905
					<table width="90%">
906
						<tr><td width="25%"><ul><li>keep state</li></td><td>Works with all IP protocols.</ul></td></tr>
907
						<tr><td width="25%"><ul><li>modulate state</li></td><td>Works only with TCP. {$g['product_name']} will generate strong Initial Sequence Numbers (ISNs) for packets matching this rule.</li></ul></td></tr>
908
						<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>
909
						<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>
910
					</table>
911
					</p>
912
			  </div>
913
			</td>
914
		</tr>
915
		<tr>
916
			<td width="22%" valign="top" class="vncell">No XMLRPC Sync</td>
917
			<td width="78%" class="vtable">
918
				<input type="checkbox" name="nosync"<?php if($pconfig['nosync']) echo " CHECKED"; ?>><br>
919
				HINT: This prevents the rule from automatically syncing to other carp members.
920
			</td>
921
		</tr>
922
		<?php
923
			//build list of schedules
924
			$schedules = array();
925
			$schedules[] = "none";//leave none to leave rule enabled all the time
926
			if(is_array($config['schedules']['schedule'])) {
927
				foreach ($config['schedules']['schedule'] as $schedule) {
928
					if ($schedule['name'] <> "")
929
						$schedules[] = $schedule['name'];
930
				}
931
			}
932
		?>
933
		<tr>
934
			<td width="22%" valign="top" class="vncell">Schedule</td>
935
			<td width="78%" class="vtable">
936
				<select name='sched'>
937
<?php
938
				foreach($schedules as $schedule) {
939
					if($schedule == $pconfig['sched']) {
940
						$selected = " SELECTED";
941
					} else {
942
						$selected = "";
943
					}
944
					if ($schedule == "none") {
945
						echo "<option value=\"\" {$selected}>{$schedule}</option>\n";
946
					} else {
947
						echo "<option value=\"{$schedule}\" {$selected}>{$schedule}</option>\n";
948
					}
949
				}?>
950
				</select>
951
				<p>Leave as 'none' to leave the rule enabled all the time.</p>
952
				<strong>NOTE:  schedule logic can be a bit different.  Click <a target="_new" href='firewall_rules_schedule_logic.php'>here</a> for more information.</strong>
953
			</td>
954
		</tr>
955
		
956
<?php
957
			/* build a list of gateways */
958
			$gateways = array();
959
			$gateways[] = "default"; // default to don't use this feature :)
960
			if (is_array($config['gateways']['gateway_item'])) {
961
				foreach($config['gateways']['gateway_item'] as $gw_item) {
962
				if($gw_item['gateway'] <> "")
963
					$gateways[] = $gw_item['name'];
964
				}
965
			}
966
			
967
?>
968
		<tr>
969
			<td width="22%" valign="top" class="vncell">Gateway</td>
970
			<td width="78%" class="vtable">
971
				<select name='gateway'>
972
<?php
973
				foreach($gateways as $gw) {
974
					if($gw == "") 
975
						continue;
976
					if($gw == $pconfig['gateway']) {
977
						$selected = " SELECTED";
978
					} else {
979
						$selected = "";
980
					}
981
					if ($gw == "default") {
982
						echo "<option value=\"\" {$selected}>{$gw}</option>\n";
983
					} else {
984
						$gwip = lookup_gateway_ip_by_name($gw);
985
						echo "<option value=\"{$gw}\" {$selected}>{$gw} - {$gwip}</option>\n";
986
					}
987
				}
988
				if(is_array($config['load_balancer']['lbpool'])) {
989
					foreach($config['load_balancer']['lbpool'] as $lb) {
990
						if($lb['name'] == "") 
991
							continue;
992
						if($pconfig['gateway'] == $lb['name']) {
993
							echo "<option value=\"{$lb['name']}\" SELECTED>{$lb['name']}</option>\n";
994
						} else {
995
							echo "<option value=\"{$lb['name']}\">{$lb['name']}</option>\n";
996
						}
997
					}
998
				}
999
				for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
1000
					if($config['interfaces']['opt' . $i]['ipaddr'] == "dhcp") {
1001
						$descr = $config['interfaces']['opt' . $i]['descr'];
1002
						if ($pconfig['gateway'] == "opt{$i}") {
1003
							$selected = " SELECTED";
1004
						} else {
1005
							$selected = "";
1006
						}
1007
						if($descr <> "") 
1008
							echo "<option value=\"opt{$i}\" {$selected}>OPT{$i} - {$descr}</option>\n";
1009
					}
1010
				}
1011
?>
1012
				</select>
1013
				<p><strong>Leave as 'default' to use the system routing table.  Or choose a gateway to utilize policy based routing.</strong></p>
1014
			</td>
1015
		</tr>
1016
		<tr>
1017
			<td width="22%" valign="top" class="vncell">Ackqueue/Queue</td>
1018
			<td width="78%" class="vtable">
1019
			<select name="ackqueue">
1020
<?php
1021
		read_altq_config(); /* XXX: */
1022
		$qlist =& get_unique_queue_list();
1023
		if (!is_array($qlist))
1024
			$qlist = array();
1025
		foreach ($qlist as $q => $qkey) {
1026
			echo "<option value=\"$q\"";
1027
			if ($q == $pconfig['ackqueue']) {
1028
				$qselected = 1;
1029
				echo " SELECTED";
1030
			}
1031
			echo ">{$q}</option>"; 
1032
		}
1033
		echo "<option value=\"none\"";
1034
		if (!$qselected) echo " SELECTED";
1035
		echo " >none</option>";
1036
?>
1037
			</select> / 			
1038
			<select name="defaultqueue">
1039
<?php
1040
		$qselected = 0;
1041
		foreach ($qlist as $q => $qkey) {
1042
			echo "<option value=\"$q\"";
1043
			if ($q == $pconfig['defaultqueue']) {
1044
				$qselected = 1;
1045
				echo " SELECTED";
1046
			}
1047
			echo ">{$q}</option>"; 
1048
		}
1049
		echo "<option value=\"none\"";
1050
		if (!$qselected) echo " SELECTED";
1051
		echo " >none</option>";
1052
?>
1053
			</select>
1054
				<br />
1055
				<span class="vexpl">Choose the Acknowledge Queue only if you have selected Queue.</span>
1056
			</td>
1057
		</tr>
1058
		<tr>
1059
			<td width="22%" valign="top" class="vncell">Description</td>
1060
			<td width="78%" class="vtable">
1061
				<input name="descr" type="text" class="formfld unknown" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
1062
				<br />
1063
				<span class="vexpl">You may enter a description here for your reference (not parsed).</span>
1064
			</td>
1065
		</tr>
1066
		<tr>
1067
			<td width="22%" valign="top">&nbsp;</td>
1068
			<td width="78%">
1069
				<input name="Submit" type="submit" class="formbtn" value="Save">  <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
1070
<?php			if (isset($id) && $a_filter[$id]): ?>
1071
					<input name="id" type="hidden" value="<?=$id;?>">
1072
<?php 			endif; ?>
1073
				<input name="after" type="hidden" value="<?=$after;?>">
1074
			</td>
1075
		</tr>
1076
	</table>
1077
</form>
1078
<script language="JavaScript">
1079
<!--
1080
	ext_change();
1081
	typesel_change();
1082
	proto_change();
1083

    
1084
<?php
1085
	$isfirst = 0;
1086
	$aliases = "";
1087
	$addrisfirst = 0;
1088
	$aliasesaddr = "";
1089
	if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
1090
		foreach($config['aliases']['alias'] as $alias_name) {
1091
			if(!stristr($alias_name['address'], ".")) {
1092
				if($isfirst == 1) $aliases .= ",";
1093
				$aliases .= "'" . $alias_name['name'] . "'";
1094
				$isfirst = 1;
1095
			} else {
1096
				if($addrisfirst == 1) $aliasesaddr .= ",";
1097
				$aliasesaddr .= "'" . $alias_name['name'] . "'";
1098
				$addrisfirst = 1;
1099
			}
1100
		}
1101
?>
1102

    
1103
	var addressarray=new Array(<?php echo $aliasesaddr; ?>);
1104
	var customarray=new Array(<?php echo $aliases; ?>);
1105

    
1106
//-->
1107
</script>
1108

    
1109

    
1110
<?php include("fend.inc"); ?>
1111
</body>
1112
</html>
1113

    
(51-51/193)