Project

General

Profile

Download (37.2 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 5ba18897 Scott Ullrich
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5 bdb7d6e7 Scott Ullrich
	firewall_rules_edit.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7 5ba18897 Scott Ullrich
8 bdb7d6e7 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 5ba18897 Scott Ullrich
11 bdb7d6e7 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 5ba18897 Scott Ullrich
14 bdb7d6e7 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 5ba18897 Scott Ullrich
17 bdb7d6e7 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 5ba18897 Scott Ullrich
21 bdb7d6e7 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31 5b237745 Scott Ullrich
*/
32
33
require("guiconfig.inc");
34
35
$specialsrcdst = explode(" ", "any lan pptp");
36
37
if (!is_array($config['filter']['rule'])) {
38
	$config['filter']['rule'] = array();
39
}
40
filter_rules_sort();
41
$a_filter = &$config['filter']['rule'];
42
43
$id = $_GET['id'];
44
if (is_numeric($_POST['id']))
45
	$id = $_POST['id'];
46 5ba18897 Scott Ullrich
47 5b237745 Scott Ullrich
$after = $_GET['after'];
48
49
if (isset($_POST['after']))
50
	$after = $_POST['after'];
51
52
if (isset($_GET['dup'])) {
53
	$id = $_GET['dup'];
54
	$after = $_GET['dup'];
55
}
56
57
if (isset($id) && $a_filter[$id]) {
58
	$pconfig['interface'] = $a_filter[$id]['interface'];
59 5ba18897 Scott Ullrich
60 5b237745 Scott Ullrich
	if (!isset($a_filter[$id]['type']))
61
		$pconfig['type'] = "pass";
62
	else
63
		$pconfig['type'] = $a_filter[$id]['type'];
64 5ba18897 Scott Ullrich
65 5b237745 Scott Ullrich
	if (isset($a_filter[$id]['protocol']))
66
		$pconfig['proto'] = $a_filter[$id]['protocol'];
67
	else
68
		$pconfig['proto'] = "any";
69 5ba18897 Scott Ullrich
70 5b237745 Scott Ullrich
	if ($a_filter[$id]['protocol'] == "icmp")
71
		$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
72 5ba18897 Scott Ullrich
73 5b237745 Scott Ullrich
	address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
74
		$pconfig['srcmask'], $pconfig['srcnot'],
75
		$pconfig['srcbeginport'], $pconfig['srcendport']);
76 5ba18897 Scott Ullrich
77 8be60f21 Scott Ullrich
	if($a_filter[$id]['os'] <> "")
78
		$pconfig['os'] = $a_filter[$id]['os'];
79 e33c8694 Bill Marquette
80 5b237745 Scott Ullrich
	address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
81
		$pconfig['dstmask'], $pconfig['dstnot'],
82
		$pconfig['dstbeginport'], $pconfig['dstendport']);
83
84
	$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
85
	$pconfig['log'] = isset($a_filter[$id]['log']);
86
	$pconfig['descr'] = $a_filter[$id]['descr'];
87 ed08ef3e Scott Ullrich
	
88
	/* advanced */
89 fa9af164 Scott Ullrich
        $pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
90
        $pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
91
        $pconfig['statetype'] = $a_filter[$id]['statetype'];
92 5ba18897 Scott Ullrich
	$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
93 ed08ef3e Scott Ullrich
	
94
	/* advanced - new connection per second banning*/
95
	$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
96
	$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
97 5ba18897 Scott Ullrich
98 e5980370 Scott Ullrich
	/* Multi-WAN next-hop support */
99 c98ddde2 Bill Marquette
	$pconfig['gateway'] = $a_filter[$id]['gateway'];
100
101 5b237745 Scott Ullrich
} else {
102
	/* defaults */
103 a23d7248 Scott Ullrich
	if ($_GET['if'])
104
		$pconfig['interface'] = $_GET['if'];
105 5b237745 Scott Ullrich
	$pconfig['type'] = "pass";
106
	$pconfig['src'] = "any";
107
	$pconfig['dst'] = "any";
108
}
109
110
if (isset($_GET['dup']))
111
	unset($id);
112
113
if ($_POST) {
114
115
	if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
116
		$_POST['srcbeginport'] = 0;
117
		$_POST['srcendport'] = 0;
118
		$_POST['dstbeginport'] = 0;
119
		$_POST['dstendport'] = 0;
120
	} else {
121 5ba18897 Scott Ullrich
122 5b237745 Scott Ullrich
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
123
			$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
124
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
125
			$_POST['srcendport'] = $_POST['srcendport_cust'];
126 5ba18897 Scott Ullrich
127 5b237745 Scott Ullrich
		if ($_POST['srcbeginport'] == "any") {
128
			$_POST['srcbeginport'] = 0;
129
			$_POST['srcendport'] = 0;
130 5ba18897 Scott Ullrich
		} else {
131 5b237745 Scott Ullrich
			if (!$_POST['srcendport'])
132
				$_POST['srcendport'] = $_POST['srcbeginport'];
133
		}
134
		if ($_POST['srcendport'] == "any")
135
			$_POST['srcendport'] = $_POST['srcbeginport'];
136 5ba18897 Scott Ullrich
137 5b237745 Scott Ullrich
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
138
			$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
139
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
140
			$_POST['dstendport'] = $_POST['dstendport_cust'];
141 5ba18897 Scott Ullrich
142 5b237745 Scott Ullrich
		if ($_POST['dstbeginport'] == "any") {
143
			$_POST['dstbeginport'] = 0;
144
			$_POST['dstendport'] = 0;
145 5ba18897 Scott Ullrich
		} else {
146 5b237745 Scott Ullrich
			if (!$_POST['dstendport'])
147
				$_POST['dstendport'] = $_POST['dstbeginport'];
148
		}
149
		if ($_POST['dstendport'] == "any")
150 5ba18897 Scott Ullrich
			$_POST['dstendport'] = $_POST['dstbeginport'];
151 5b237745 Scott Ullrich
	}
152 5ba18897 Scott Ullrich
153 5b237745 Scott Ullrich
	if (is_specialnet($_POST['srctype'])) {
154
		$_POST['src'] = $_POST['srctype'];
155
		$_POST['srcmask'] = 0;
156
	} else if ($_POST['srctype'] == "single") {
157
		$_POST['srcmask'] = 32;
158
	}
159
	if (is_specialnet($_POST['dsttype'])) {
160
		$_POST['dst'] = $_POST['dsttype'];
161
		$_POST['dstmask'] = 0;
162
	}  else if ($_POST['dsttype'] == "single") {
163
		$_POST['dstmask'] = 32;
164
	}
165 5ba18897 Scott Ullrich
166 5b237745 Scott Ullrich
	unset($input_errors);
167
	$pconfig = $_POST;
168
169
	/* input validation */
170
	$reqdfields = explode(" ", "type interface proto src dst");
171
	$reqdfieldsn = explode(",", "Type,Interface,Protocol,Source,Destination");
172
173 bdb7d6e7 Scott Ullrich
174
	if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state")
175 c22767b1 Bill Marquette
		if( $_POST['proto'] != "tcp" )
176
			$input_errors[] = "{$_POST['statetype']} is only valid with protocol tcp.";
177 bdb7d6e7 Scott Ullrich
178 5ba18897 Scott Ullrich
179 5b237745 Scott Ullrich
	if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
180
		$reqdfields[] = "srcmask";
181
		$reqdfieldsn[] = "Source bit count";
182
	}
183
	if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
184
		$reqdfields[] = "dstmask";
185
		$reqdfieldsn[] = "Destination bit count";
186
	}
187 5ba18897 Scott Ullrich
188 5b237745 Scott Ullrich
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
189 5ba18897 Scott Ullrich
190 5b237745 Scott Ullrich
	if (!$_POST['srcbeginport']) {
191
		$_POST['srcbeginport'] = 0;
192
		$_POST['srcendport'] = 0;
193
	}
194
	if (!$_POST['dstbeginport']) {
195
		$_POST['dstbeginport'] = 0;
196
		$_POST['dstendport'] = 0;
197
	}
198 5ba18897 Scott Ullrich
199 19757279 Scott Ullrich
	if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
200 aba8aace Scott Ullrich
		$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
201 bdb7d6e7 Scott Ullrich
	}
202 19757279 Scott Ullrich
	if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
203 aba8aace Scott Ullrich
		$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
204 bdb7d6e7 Scott Ullrich
	}
205 19757279 Scott Ullrich
	if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
206 aba8aace Scott Ullrich
		$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
207 bdb7d6e7 Scott Ullrich
	}
208 19757279 Scott Ullrich
	if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
209 aba8aace Scott Ullrich
		$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
210 bdb7d6e7 Scott Ullrich
	}
211 5ba18897 Scott Ullrich
212 5b237745 Scott Ullrich
	if (!is_specialnet($_POST['srctype'])) {
213
		if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
214
			$input_errors[] = "A valid source IP address or alias must be specified.";
215
		}
216
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
217
			$input_errors[] = "A valid source bit count must be specified.";
218
		}
219
	}
220
	if (!is_specialnet($_POST['dsttype'])) {
221
		if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
222
			$input_errors[] = "A valid destination IP address or alias must be specified.";
223
		}
224
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
225
			$input_errors[] = "A valid destination bit count must be specified.";
226
		}
227
	}
228 5ba18897 Scott Ullrich
229 5b237745 Scott Ullrich
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
230
		/* swap */
231
		$tmp = $_POST['srcendport'];
232
		$_POST['srcendport'] = $_POST['srcbeginport'];
233
		$_POST['srcbeginport'] = $tmp;
234
	}
235
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
236
		/* swap */
237
		$tmp = $_POST['dstendport'];
238
		$_POST['dstendport'] = $_POST['dstbeginport'];
239
		$_POST['dstbeginport'] = $tmp;
240
	}
241 e33c8694 Bill Marquette
	if ($_POST['os'])
242
		if( $_POST['proto'] != "tcp" )
243
			$input_errors[] = "OS detection is only valid with protocol tcp.";
244 5b237745 Scott Ullrich
245
	if (!$input_errors) {
246
		$filterent = array();
247
		$filterent['type'] = $_POST['type'];
248
		$filterent['interface'] = $_POST['interface'];
249 d59874c1 Scott Ullrich
250 bdb7d6e7 Scott Ullrich
		/* Advanced options */
251
		$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
252
		$filterent['max-src-states'] = $_POST['max-src-states'];
253 5ba18897 Scott Ullrich
		$filterent['statetimeout'] = $_POST['statetimeout'];
254 fa9af164 Scott Ullrich
		$filterent['statetype'] = $_POST['statetype'];
255 e33c8694 Bill Marquette
		$filterent['os'] = $_POST['os'];
256 f87f85c3 Bill Marquette
		$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
257
		$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
258 5ba18897 Scott Ullrich
259 5b237745 Scott Ullrich
		if ($_POST['proto'] != "any")
260
			$filterent['protocol'] = $_POST['proto'];
261
		else
262
			unset($filterent['protocol']);
263 5ba18897 Scott Ullrich
264 5b237745 Scott Ullrich
		if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
265
			$filterent['icmptype'] = $_POST['icmptype'];
266
		else
267
			unset($filterent['icmptype']);
268 5ba18897 Scott Ullrich
269 5b237745 Scott Ullrich
		pconfig_to_address($filterent['source'], $_POST['src'],
270
			$_POST['srcmask'], $_POST['srcnot'],
271
			$_POST['srcbeginport'], $_POST['srcendport']);
272 5ba18897 Scott Ullrich
273 5b237745 Scott Ullrich
		pconfig_to_address($filterent['destination'], $_POST['dst'],
274
			$_POST['dstmask'], $_POST['dstnot'],
275
			$_POST['dstbeginport'], $_POST['dstendport']);
276 5ba18897 Scott Ullrich
277 f87f85c3 Bill Marquette
                if ($_POST['disabled'])
278
                        $filterent['disabled'] = true;
279
                else
280
                        unset($filterent['disabled']);
281
                if ($_POST['log'])
282
                        $filterent['log'] = true;
283
                else
284
                        unset($filterent['log']);
285 c68fc1e7 Bill Marquette
		strncpy($filterent['descr'], $_POST['descr'], 52);
286 5ba18897 Scott Ullrich
287 c98ddde2 Bill Marquette
		if ($_POST['gateway'] != "") {
288
			$filterent['gateway'] = $_POST['gateway'];
289
		}
290
291 5b237745 Scott Ullrich
		if (isset($id) && $a_filter[$id])
292
			$a_filter[$id] = $filterent;
293
		else {
294
			if (is_numeric($after))
295
				array_splice($a_filter, $after+1, 0, array($filterent));
296
			else
297
				$a_filter[] = $filterent;
298
		}
299 f4e2a352 Scott Ullrich
300 5b237745 Scott Ullrich
		write_config();
301
		touch($d_filterconfdirty_path);
302 5ba18897 Scott Ullrich
303 a23d7248 Scott Ullrich
		header("Location: firewall_rules.php?if=" . $_POST['interface']);
304 5b237745 Scott Ullrich
		exit;
305
	}
306 c60824d2 Scott Ullrich
}
307
308 da7ae7ef Bill Marquette
$pgtitle = "Firewall: Rules: Edit";
309 a1357fe0 Bill Marquette
$closehead = false;
310 da7ae7ef Bill Marquette
include("head.inc");
311 c60824d2 Scott Ullrich
312 5b237745 Scott Ullrich
?>
313 da7ae7ef Bill Marquette
314 5b237745 Scott Ullrich
<script language="JavaScript">
315
<!--
316
var portsenabled = 1;
317 bdb7d6e7 Scott Ullrich
318 5b237745 Scott Ullrich
function ext_change() {
319
	if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
320
		document.iform.srcbeginport_cust.disabled = 0;
321
	} else {
322
		document.iform.srcbeginport_cust.value = "";
323
		document.iform.srcbeginport_cust.disabled = 1;
324
	}
325
	if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
326
		document.iform.srcendport_cust.disabled = 0;
327
	} else {
328
		document.iform.srcendport_cust.value = "";
329
		document.iform.srcendport_cust.disabled = 1;
330
	}
331
	if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled) {
332
		document.iform.dstbeginport_cust.disabled = 0;
333
	} else {
334
		document.iform.dstbeginport_cust.value = "";
335
		document.iform.dstbeginport_cust.disabled = 1;
336
	}
337
	if ((document.iform.dstendport.selectedIndex == 0) && portsenabled) {
338
		document.iform.dstendport_cust.disabled = 0;
339
	} else {
340
		document.iform.dstendport_cust.value = "";
341
		document.iform.dstendport_cust.disabled = 1;
342
	}
343 5ba18897 Scott Ullrich
344 5b237745 Scott Ullrich
	if (!portsenabled) {
345
		document.iform.srcbeginport.disabled = 1;
346
		document.iform.srcendport.disabled = 1;
347
		document.iform.dstbeginport.disabled = 1;
348
		document.iform.dstendport.disabled = 1;
349
	} else {
350
		document.iform.srcbeginport.disabled = 0;
351
		document.iform.srcendport.disabled = 0;
352
		document.iform.dstbeginport.disabled = 0;
353
		document.iform.dstendport.disabled = 0;
354
	}
355
}
356
357 bdb7d6e7 Scott Ullrich
function typesel_change() {
358 5b237745 Scott Ullrich
	switch (document.iform.srctype.selectedIndex) {
359
		case 1:	/* single */
360
			document.iform.src.disabled = 0;
361
			document.iform.srcmask.value = "";
362
			document.iform.srcmask.disabled = 1;
363
			break;
364
		case 2:	/* network */
365
			document.iform.src.disabled = 0;
366
			document.iform.srcmask.disabled = 0;
367
			break;
368
		default:
369
			document.iform.src.value = "";
370
			document.iform.src.disabled = 1;
371
			document.iform.srcmask.value = "";
372
			document.iform.srcmask.disabled = 1;
373
			break;
374
	}
375
	switch (document.iform.dsttype.selectedIndex) {
376
		case 1:	/* single */
377
			document.iform.dst.disabled = 0;
378
			document.iform.dstmask.value = "";
379
			document.iform.dstmask.disabled = 1;
380
			break;
381
		case 2:	/* network */
382
			document.iform.dst.disabled = 0;
383
			document.iform.dstmask.disabled = 0;
384
			break;
385
		default:
386
			document.iform.dst.value = "";
387
			document.iform.dst.disabled = 1;
388
			document.iform.dstmask.value = "";
389
			document.iform.dstmask.disabled = 1;
390
			break;
391
	}
392
}
393
394
function proto_change() {
395
	if (document.iform.proto.selectedIndex < 3) {
396
		portsenabled = 1;
397
	} else {
398
		portsenabled = 0;
399
	}
400 5ba18897 Scott Ullrich
401 65465a3c Scott Ullrich
	/* Disable OS knob if the proto is not TCP. */
402
	if (document.iform.proto.selectedIndex < 1) {
403
		document.forms[0].os.disabled = 0;
404
	} else {
405
		document.forms[0].os.disabled = 1;
406
	}
407
408 5b237745 Scott Ullrich
	if (document.iform.proto.selectedIndex == 3) {
409
		document.iform.icmptype.disabled = 0;
410
	} else {
411
		document.iform.icmptype.disabled = 1;
412
	}
413 5ba18897 Scott Ullrich
414 5b237745 Scott Ullrich
	ext_change();
415
}
416
417
function src_rep_change() {
418
	document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
419
}
420
function dst_rep_change() {
421
	document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
422
}
423
//-->
424
</script>
425
</head>
426
427
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
428
<?php include("fbegin.inc"); ?>
429 da7ae7ef Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
430 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
431
            <form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
432 ef97ce1b Bill Marquette
              <?display_topbar()?>
433 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
434 5ba18897 Scott Ullrich
                <tr>
435 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Action</td>
436
                  <td width="78%" class="vtable">
437 bdb7d6e7 Scott Ullrich
<select name="type" class="formfld">
438 5b237745 Scott Ullrich
                      <?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
439
                      <option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
440
                      <?=htmlspecialchars($type);?>
441
                      </option>
442
                      <?php endforeach; ?>
443
                    </select> <br>
444 bdb7d6e7 Scott Ullrich
                    <span class="vexpl">Choose what to do with packets that match
445
					the criteria specified below.<br>
446
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.</span></td>
447 5b237745 Scott Ullrich
                </tr>
448 5ba18897 Scott Ullrich
                <tr>
449 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Disabled</td>
450 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
451 5b237745 Scott Ullrich
                    <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
452
                    <strong>Disable this rule</strong><br>
453
                    <span class="vexpl">Set this option to disable this rule without
454
					removing it from the list.</span></td>
455
                </tr>
456 5ba18897 Scott Ullrich
                <tr>
457 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Interface</td>
458
                  <td width="78%" class="vtable">
459 bdb7d6e7 Scott Ullrich
<select name="interface" class="formfld">
460 5b237745 Scott Ullrich
                      <?php $interfaces = array('wan' => 'WAN', 'lan' => 'LAN', 'pptp' => 'PPTP');
461
					  for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
462
					  	$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
463
					  }
464
					  foreach ($interfaces as $iface => $ifacename): ?>
465
                      <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
466
                      <?=htmlspecialchars($ifacename);?>
467
                      </option>
468
                      <?php endforeach; ?>
469
                    </select> <br>
470 5ba18897 Scott Ullrich
                    <span class="vexpl">Choose on which interface packets must
471 5b237745 Scott Ullrich
                    come in to match this rule.</span></td>
472
                </tr>
473 5ba18897 Scott Ullrich
                <tr>
474 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Protocol</td>
475
                  <td width="78%" class="vtable">
476 bdb7d6e7 Scott Ullrich
<select name="proto" class="formfld" onchange="proto_change()">
477 9620d290 Scott Ullrich
                      <?php $protocols = explode(" ", "TCP UDP TCP/UDP ICMP ICMP6 ESP AH GRE IPv6 IGMP any carp pfsync"); foreach ($protocols as $proto): ?>
478 5b237745 Scott Ullrich
                      <option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>>
479
                      <?=htmlspecialchars($proto);?>
480
                      </option>
481
                      <?php endforeach; ?>
482
                    </select> <br>
483 5ba18897 Scott Ullrich
                    <span class="vexpl">Choose which IP protocol this rule should
484 5b237745 Scott Ullrich
                    match.<br>
485
                    Hint: in most cases, you should specify <em>TCP</em> &nbsp;here.</span></td>
486
                </tr>
487
                <tr>
488
                  <td valign="top" class="vncell">ICMP type</td>
489
                  <td class="vtable">
490
                    <select name="icmptype" class="formfld">
491
                      <?php
492 5ba18897 Scott Ullrich
493 5b237745 Scott Ullrich
					  $icmptypes = array(
494
					  	"" => "any",
495
						"echorep" => "Echo reply",
496 ec4940b9 Bill Marquette
					  	"unreach" => "Destination unreachable",
497 5b237745 Scott Ullrich
						"squench" => "Source quench",
498
						"redir" => "Redirect",
499 ec4940b9 Bill Marquette
						"althost" => "Alternate Host",
500
						"echoreq" => "Echo",
501
						"routeradv" => "Router advertisement",
502
						"routersol" => "Router solicitation",
503 5b237745 Scott Ullrich
						"timex" => "Time exceeded",
504 ec4940b9 Bill Marquette
						"paramprob" => "Invalid IP header",
505
						"timereq" => "Timestamp",
506
						"timerep" => "Timestamp reply",
507 5b237745 Scott Ullrich
						"inforeq" => "Information request",
508
						"inforep" => "Information reply",
509
						"maskreq" => "Address mask request",
510
						"maskrep" => "Address mask reply"
511
					  );
512 5ba18897 Scott Ullrich
513 5b237745 Scott Ullrich
					  foreach ($icmptypes as $icmptype => $descr): ?>
514
                      <option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>>
515
                      <?=htmlspecialchars($descr);?>
516
                      </option>
517
                      <?php endforeach; ?>
518
                    </select>
519
                    <br>
520
                    <span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span></td>
521
                </tr>
522 5ba18897 Scott Ullrich
                <tr>
523 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Source</td>
524
                  <td width="78%" class="vtable">
525 bdb7d6e7 Scott Ullrich
<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
526 5b237745 Scott Ullrich
                    <strong>not</strong><br>
527
                    Use this option to invert the sense of the match.<br>
528
                    <br>
529
                    <table border="0" cellspacing="0" cellpadding="0">
530 5ba18897 Scott Ullrich
                      <tr>
531 5b237745 Scott Ullrich
                        <td>Type:&nbsp;&nbsp;</td>
532 bdb7d6e7 Scott Ullrich
                        <td><select name="srctype" class="formfld" onChange="typesel_change()">
533 5b237745 Scott Ullrich
							<?php $sel = is_specialnet($pconfig['src']); ?>
534
                            <option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>
535
                            any</option>
536
                            <option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
537
                            Single host or alias</option>
538
                            <option value="network" <?php if (!$sel) echo "selected"; ?>>
539
                            Network</option>
540
                            <option value="lan" <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>
541
                            LAN subnet</option>
542
                            <option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>
543
                            PPTP clients</option>
544
							<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
545
                            <option value="opt<?=$i;?>" <?php if ($pconfig['src'] == "opt" . $i) { echo "selected"; } ?>>
546
                            <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
547
							<?php endfor; ?>
548
                          </select></td>
549
                      </tr>
550 5ba18897 Scott Ullrich
                      <tr>
551 5b237745 Scott Ullrich
                        <td>Address:&nbsp;&nbsp;</td>
552 3d85f6b4 Scott Ullrich
                        <td><input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this)' onkeyup='actb_tocomplete(this,event,addressarray);' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>">
553 5b237745 Scott Ullrich
                        /
554 bdb7d6e7 Scott Ullrich
						<select name="srcmask" class="formfld" id="srcmask">
555
						<?php for ($i = 31; $i > 0; $i--): ?>
556
						<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
557
						<?php endfor; ?>
558
						</select>
559
						</td>
560
					  </tr>
561 5b237745 Scott Ullrich
                    </table></td>
562
                </tr>
563 5ba18897 Scott Ullrich
                <tr>
564
                  <td width="22%" valign="top" class="vncellreq">Source port range
565 5b237745 Scott Ullrich
                  </td>
566 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
567 5b237745 Scott Ullrich
                    <table border="0" cellspacing="0" cellpadding="0">
568 5ba18897 Scott Ullrich
                      <tr>
569 5b237745 Scott Ullrich
                        <td>from:&nbsp;&nbsp;</td>
570
                        <td><select name="srcbeginport" class="formfld" onchange="src_rep_change();ext_change()">
571
                            <option value="">(other)</option>
572 bdb7d6e7 Scott Ullrich
                            <option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
573 5b237745 Scott Ullrich
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
574
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) {
575
																echo "selected";
576
																$bfound = 1;
577
															}?>>
578
                            <?=htmlspecialchars($wkportdesc);?>
579
                            </option>
580
                            <?php endforeach; ?>
581 3d85f6b4 Scott Ullrich
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);'  onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>"></td>
582 5b237745 Scott Ullrich
                      </tr>
583 5ba18897 Scott Ullrich
                      <tr>
584 5b237745 Scott Ullrich
                        <td>to:</td>
585
                        <td><select name="srcendport" class="formfld" onchange="ext_change()">
586
                            <option value="">(other)</option>
587 bdb7d6e7 Scott Ullrich
                            <option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
588 5b237745 Scott Ullrich
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
589
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) {
590
																echo "selected";
591
																$bfound = 1;
592
															}?>>
593
                            <?=htmlspecialchars($wkportdesc);?>
594
                            </option>
595
                            <?php endforeach; ?>
596 3d85f6b4 Scott Ullrich
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);'  onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
597 5b237745 Scott Ullrich
                      </tr>
598
                    </table>
599 5ba18897 Scott Ullrich
                    <br>
600
                    <span class="vexpl">Specify the port or port range for
601 bdb7d6e7 Scott Ullrich
                    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>
602 5ba18897 Scott Ullrich
                    Hint: you can leave the <em>'to'</em> field empty if you only
603 5b237745 Scott Ullrich
                    want to filter a single port</span></td>
604 e33c8694 Bill Marquette
605
                <tr>
606
                  <td width="22%" valign="top" class="vncellreq">Source OS</td>
607
                  <td width="78%" class="vtable">OS Type:&nbsp;
608 65465a3c Scott Ullrich
                    <select name="os" id="os" class="formfld">
609 e33c8694 Bill Marquette
                      <?php
610
                                          $ostypes = array(
611
						"" => "any",
612
                                                "AIX" => "AIX",
613
                                                "Linux" => "Linux",
614
                                                "FreeBSD" => "FreeBSD",
615
                                                "NetBSD" => "NetBSD",
616
                                                "OpenBSD" => "OpenBSD",
617
                                                "Solaris" => "Solaris",
618
                                                "MacOS" => "MacOS",
619
                                                "Windows" => "Windows",
620
                                                "Novell" => "Novell"
621
                                          );
622
623
                                          foreach ($ostypes as $ostype => $descr): ?>
624
                      <option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>>
625
                      <?=htmlspecialchars($descr);?>
626
                      </option>
627
                      <?php endforeach; ?>
628
                    </select><br>
629
                    Note: this only works for TCP rules</td>
630
		</tr>
631 5ba18897 Scott Ullrich
                <tr>
632 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Destination</td>
633 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
634
                    <input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
635 5b237745 Scott Ullrich
                    <strong>not</strong><br>
636
                    Use this option to invert the sense of the match.<br>
637
                    <br>
638
                    <table border="0" cellspacing="0" cellpadding="0">
639 5ba18897 Scott Ullrich
                      <tr>
640 5b237745 Scott Ullrich
                        <td>Type:&nbsp;&nbsp;</td>
641 bdb7d6e7 Scott Ullrich
                        <td><select name="dsttype" class="formfld" onChange="typesel_change()">
642 5b237745 Scott Ullrich
                            <?php $sel = is_specialnet($pconfig['dst']); ?>
643
                            <option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>
644
                            any</option>
645
                            <option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
646
                            Single host or alias</option>
647
                            <option value="network" <?php if (!$sel) echo "selected"; ?>>
648
                            Network</option>
649
                            <option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>
650
                            LAN subnet</option>
651
                            <option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>
652
                            PPTP clients</option>
653
							<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
654
                            <option value="opt<?=$i;?>" <?php if ($pconfig['dst'] == "opt" . $i) { echo "selected"; } ?>>
655
                            <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
656
							<?php endfor; ?>
657
                          </select></td>
658
                      </tr>
659 5ba18897 Scott Ullrich
                      <tr>
660 5b237745 Scott Ullrich
                        <td>Address:&nbsp;&nbsp;</td>
661 3d85f6b4 Scott Ullrich
                        <td><input name="dst" autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);'  onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,addressarray)' type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
662 5ba18897 Scott Ullrich
                          /
663 bdb7d6e7 Scott Ullrich
                          <select name="dstmask" class="formfld" id="dstmask">
664
						<?php for ($i = 31; $i > 0; $i--): ?>
665
						<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
666
						<?php endfor; ?>
667
						</select></td>
668 5b237745 Scott Ullrich
                      </tr>
669
                    </table></td>
670
                </tr>
671 5ba18897 Scott Ullrich
                <tr>
672
                  <td width="22%" valign="top" class="vncellreq">Destination port
673 5b237745 Scott Ullrich
                    range </td>
674 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
675 5b237745 Scott Ullrich
                    <table border="0" cellspacing="0" cellpadding="0">
676 5ba18897 Scott Ullrich
                      <tr>
677 5b237745 Scott Ullrich
                        <td>from:&nbsp;&nbsp;</td>
678
                        <td><select name="dstbeginport" class="formfld" onchange="dst_rep_change();ext_change()">
679
                            <option value="">(other)</option>
680
                            <option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
681
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
682
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) {
683
																echo "selected";
684
																$bfound = 1;
685
															}?>>
686
                            <?=htmlspecialchars($wkportdesc);?>
687
                            </option>
688
                            <?php endforeach; ?>
689 3d85f6b4 Scott Ullrich
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>"></td>
690 5b237745 Scott Ullrich
                      </tr>
691 5ba18897 Scott Ullrich
                      <tr>
692 5b237745 Scott Ullrich
                        <td>to:</td>
693
                        <td><select name="dstendport" class="formfld" onchange="ext_change()">
694
                            <option value="">(other)</option>
695
                            <option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
696
                            <?php foreach ($wkports as $wkport => $wkportdesc): ?>
697
                            <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) {
698
																echo "selected";
699
																$bfound = 1;
700
															}?>>
701
                            <?=htmlspecialchars($wkportdesc);?>
702
                            </option>
703
                            <?php endforeach; ?>
704 3d85f6b4 Scott Ullrich
                          </select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>"></td>
705 5b237745 Scott Ullrich
                      </tr>
706
                    </table>
707 5ba18897 Scott Ullrich
                    <br> <span class="vexpl">Specify the port or port range for
708 5b237745 Scott Ullrich
                    the destination of the packet for this rule.<br>
709 5ba18897 Scott Ullrich
                    Hint: you can leave the <em>'to'</em> field empty if you only
710 5b237745 Scott Ullrich
                    want to filter a single port</span></td>
711 bdb7d6e7 Scott Ullrich
                </tr>
712 5ba18897 Scott Ullrich
                <tr>
713 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Log</td>
714 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
715 5b237745 Scott Ullrich
                    <input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
716
                    <strong>Log packets that are handled by this rule</strong><br>
717 5ba18897 Scott Ullrich
                    <span class="vexpl">Hint: the firewall has limited local log
718
                    space. Don't turn on logging for everything. If you want to
719
                    do a lot of logging, consider using a remote syslog server
720
                    (see the <a href="diag_logs_settings.php">Diagnostics: System
721 5b237745 Scott Ullrich
                    logs: Settings</a> page).</span></td>
722
                </tr>
723 5ba18897 Scott Ullrich
                <tr>
724 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncell">Description</td>
725 5ba18897 Scott Ullrich
                  <td width="78%" class="vtable">
726 c68fc1e7 Bill Marquette
                    <input name="descr" type="text" class="formfld" id="descr" size="52" maxlength="52" value="<?=htmlspecialchars($pconfig['descr']);?>">
727 5ba18897 Scott Ullrich
                    <br> <span class="vexpl">You may enter a description here
728 5b237745 Scott Ullrich
                    for your reference (not parsed).</span></td>
729
                </tr>
730 a44455c4 Scott Ullrich
               <tr>
731
                  <td width="22%" valign="top" class="vncell">Advanced Options</td>
732
                  <td width="78%" class="vtable">
733
			<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
734 e33c8694 Bill Marquette
			<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
735 ed08ef3e Scott Ullrich
			<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
736
			<select name="max-src-conn-rates" id="max-src-conn-rates">
737 40b0fe5b Scott Ullrich
			 <option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
738 ed08ef3e Scott Ullrich
			 <?php
739 40b0fe5b Scott Ullrich
			   for($x=1; $x<255; $x++) {
740 ed08ef3e Scott Ullrich
				if($x == $pconfig['max-src-conn-rates'])
741
					$selected = " selected";
742
				else 
743
					$selected = "";
744
				echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
745
			   }
746
			 ?>
747
			 </select>
748
			<br>
749 40b0fe5b Scott Ullrich
			Maximum new connections / per second
750 4cc0d94c Scott Ullrich
			<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
751 a44455c4 Scott Ullrich
		    </td>
752
                </tr>
753 3849b323 Scott Ullrich
               <tr>
754
                  <td width="22%" valign="top" class="vncell">State Type</td>
755
                  <td width="78%" class="vtable">
756 d59874c1 Scott Ullrich
			<select name="statetype">
757 3849b323 Scott Ullrich
			<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
758
			<option value="modulate state" <?php if($pconfig['statetype'] == "modulate state")  echo "selected"; ?>>modulate state</option>
759
			<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state")  echo "selected"; ?>>synproxy state</option>
760
			<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
761
			</select><br>HINT: Select which type of state tracking mechanism you would like to use.  If in doubt, use keep state.
762
			<p><strong>
763
			<table>
764 5ba18897 Scott Ullrich
			<tr><td width="25%"><li>keep state</li></td><td>works with TCP, UDP, and ICMP.</td></tr>
765
			<tr><td width="25%"><li>modulate state</li></td><td>works only with TCP. pfSense will generate strong Initial Sequence Numbers (ISNs) for packets matching this rule.</li></td></tr>
766
			<tr><td width="25%"><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.</td></tr>
767
			<tr><td width="25%"><li>none</li></td><td>do not use state mechanisms to keep track.  this is only useful if your doing advanced queueing in certain situations.  please check the faq.</td></tr>
768
			</table>
769 3849b323 Scott Ullrich
			</strong>
770
		    </td>
771
                </tr>
772 a44455c4 Scott Ullrich
773 5ba18897 Scott Ullrich
		<tr>
774
                  <td width="22%" valign="top" class="vncell">State Timeout</td>
775
                  <td width="78%" class="vtable">
776
			<input name="statetimeout" value="<?php echo $pconfig['frags'] ?>">
777
			<p><strong>Leave blank for default.  Amount is in seconds.
778
			</strong>
779
		    </td>
780
		</tr>
781
782 82628210 Scott Ullrich
		<?php
783
			/* build a list of gateways */
784
			$gateways = array();
785 c98ddde2 Bill Marquette
                        $gateways[] = "default"; // default to don't use this feature :)
786 82628210 Scott Ullrich
			foreach($config['interfaces'] as $int) {
787
				if($int['gateway'] <> "")
788
					$gateways[]=$int['gateway'];
789
			}
790
		?>
791
		<tr>
792
                  <td width="22%" valign="top" class="vncell">Gateway</td>
793
                  <td width="78%" class="vtable">
794
			<select name='gateway'>
795
			<?php
796
				foreach($gateways as $gw) {
797 dd31e6a9 Scott Ullrich
					if($gw == $pconfig['gateway'])
798 82628210 Scott Ullrich
						$selected = " SELECTED";
799
					else
800
						$selected = "";
801 bd8d9d92 Bill Marquette
					if ($gw == "default") 
802 c98ddde2 Bill Marquette
						echo "<option value=\"\" {$selected}>{$gw}</option>\n";
803 d957c1fb Scott Ullrich
					else
804 bd8d9d92 Bill Marquette
						echo "<option value=\"{$gw}\" {$selected}>{$gw}</option>\n";
805 82628210 Scott Ullrich
				}
806
			?>
807
			</select>
808
			<p><strong>Leave blank for default.
809
			</strong>
810
		    </td>
811
		</tr>
812 5ba18897 Scott Ullrich
                <tr>
813 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
814 5ba18897 Scott Ullrich
                  <td width="78%">
815 fc01e414 Scott Ullrich
                    <input name="Submit" type="submit" class="formbtn" value="Save">  <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
816 5b237745 Scott Ullrich
                    <?php if (isset($id) && $a_filter[$id]): ?>
817 5ba18897 Scott Ullrich
                    <input name="id" type="hidden" value="<?=$id;?>">
818 5b237745 Scott Ullrich
                    <?php endif; ?>
819 5ba18897 Scott Ullrich
                    <input name="after" type="hidden" value="<?=$after;?>">
820 5b237745 Scott Ullrich
                  </td>
821
                </tr>
822
              </table>
823
</form>
824
<script language="JavaScript">
825
<!--
826
ext_change();
827
typesel_change();
828
proto_change();
829 19757279 Scott Ullrich
830
<?php
831
$isfirst = 0;
832
$aliases = "";
833
$addrisfirst = 0;
834
$aliasesaddr = "";
835 092ac49d Scott Ullrich
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
836
	foreach($config['aliases']['alias'] as $alias_name) {
837
		if(!stristr($alias_name['address'], ".")) {
838
			if($isfirst == 1) $aliases .= ",";
839
			$aliases .= "'" . $alias_name['name'] . "'";
840
			$isfirst = 1;
841
		} else {
842
			if($addrisfirst == 1) $aliasesaddr .= ",";
843
			$aliasesaddr .= "'" . $alias_name['name'] . "'";
844
			$addrisfirst = 1;
845
		}
846 19757279 Scott Ullrich
	}
847
?>
848
849
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
850
var customarray=new Array(<?php echo $aliases; ?>);
851
852 5b237745 Scott Ullrich
//-->
853
</script>
854 ef8b343d Scott Ullrich
<script type="text/javascript" language="javascript" src="auto_complete_helper.js">
855
</script>
856 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
857
</body>
858
</html>