Project

General

Profile

Download (43.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_nat_edit.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
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
	pfSense_MODULE:	nat
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-firewall-nat-portforward-edit
39
##|*NAME=Firewall: NAT: Port Forward: Edit page
40
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward: Edit' page.
41
##|*MATCH=firewall_nat_edit.php*
42
##|-PRIV
43

    
44
require("guiconfig.inc");
45
require_once("itemid.inc");
46
require_once("filter.inc");
47
require("shaper.inc");
48

    
49
if (isset($_POST['referer'])) {
50
	$referer = $_POST['referer'];
51
} else {
52
	$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_nat.php');
53
}
54

    
55
$specialsrcdst = explode(" ", "any (self) pptp pppoe l2tp openvpn");
56
$ifdisp = get_configured_interface_with_descr();
57
foreach ($ifdisp as $kif => $kdescr) {
58
	$specialsrcdst[] = "{$kif}";
59
	$specialsrcdst[] = "{$kif}ip";
60
}
61

    
62
if (!is_array($config['nat']['rule'])) {
63
	$config['nat']['rule'] = array();
64
}
65
$a_nat = &$config['nat']['rule'];
66

    
67
if (is_numericint($_GET['id']))
68
	$id = $_GET['id'];
69
if (isset($_POST['id']) && is_numericint($_POST['id']))
70
	$id = $_POST['id'];
71

    
72
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
73
	$after = $_GET['after'];
74
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
75
	$after = $_POST['after'];
76

    
77
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
78
        $id = $_GET['dup'];
79
        $after = $_GET['dup'];
80
}
81

    
82
if (isset($id) && $a_nat[$id]) {
83
	if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
84
		$pconfig['created'] = $a_nat[$id]['created'];
85

    
86
	if ( isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']) )
87
		$pconfig['updated'] = $a_nat[$id]['updated'];
88

    
89
	$pconfig['disabled'] = isset($a_nat[$id]['disabled']);
90
	$pconfig['nordr'] = isset($a_nat[$id]['nordr']);
91
	address_to_pconfig($a_nat[$id]['source'], $pconfig['src'],
92
		$pconfig['srcmask'], $pconfig['srcnot'],
93
		$pconfig['srcbeginport'], $pconfig['srcendport']);
94

    
95
	address_to_pconfig($a_nat[$id]['destination'], $pconfig['dst'],
96
		$pconfig['dstmask'], $pconfig['dstnot'],
97
		$pconfig['dstbeginport'], $pconfig['dstendport']);
98

    
99
	$pconfig['proto'] = $a_nat[$id]['protocol'];
100
	$pconfig['localip'] = $a_nat[$id]['target'];
101
	$pconfig['localbeginport'] = $a_nat[$id]['local-port'];
102
	$pconfig['descr'] = $a_nat[$id]['descr'];
103
	$pconfig['interface'] = $a_nat[$id]['interface'];
104
	$pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id'];
105
	$pconfig['nosync'] = isset($a_nat[$id]['nosync']);
106
	$pconfig['natreflection'] = $a_nat[$id]['natreflection'];
107

    
108
	if (!$pconfig['interface'])
109
		$pconfig['interface'] = "wan";
110
} else {
111
	$pconfig['interface'] = "wan";
112
	$pconfig['src'] = "any";
113
	$pconfig['srcbeginport'] = "any";
114
	$pconfig['srcendport'] = "any";
115
}
116

    
117
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
118
	unset($id);
119

    
120
/*  run through $_POST items encoding HTML entties so that the user
121
 *  cannot think he is slick and perform a XSS attack on the unwilling
122
 */
123
unset($input_errors);
124
foreach ($_POST as $key => $value) {
125
	$temp = $value;
126
	$newpost = htmlentities($temp);
127
	if($newpost <> $temp)
128
		$input_errors[] = sprintf(gettext("Invalid characters detected %s. Please remove invalid characters and save again."), $temp);
129
}
130

    
131
if ($_POST) {
132

    
133
	if(strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") {
134
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
135
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
136
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
137
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
138

    
139
		if ($_POST['srcbeginport'] == "any") {
140
			$_POST['srcbeginport'] = 0;
141
			$_POST['srcendport'] = 0;
142
		} else {
143
			if (!$_POST['srcendport'])
144
				$_POST['srcendport'] = $_POST['srcbeginport'];
145
		}
146
		if ($_POST['srcendport'] == "any")
147
			$_POST['srcendport'] = $_POST['srcbeginport'];
148

    
149
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
150
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
151
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
152
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
153

    
154
		if ($_POST['dstbeginport'] == "any") {
155
			$_POST['dstbeginport'] = 0;
156
			$_POST['dstendport'] = 0;
157
		} else {
158
			if (!$_POST['dstendport'])
159
				$_POST['dstendport'] = $_POST['dstbeginport'];
160
		}
161
		if ($_POST['dstendport'] == "any")
162
			$_POST['dstendport'] = $_POST['dstbeginport'];
163

    
164
		if ($_POST['localbeginport_cust'] && !$_POST['localbeginport'])
165
			$_POST['localbeginport'] = trim($_POST['localbeginport_cust']);
166

    
167
		/* Make beginning port end port if not defined and endport is */
168
		if (!$_POST['srcbeginport'] && $_POST['srcendport'])
169
			$_POST['srcbeginport'] = $_POST['srcendport'];
170
		if (!$_POST['dstbeginport'] && $_POST['dstendport'])
171
			$_POST['dstbeginport'] = $_POST['dstendport'];
172
	} else {
173
		$_POST['srcbeginport'] = 0;
174
		$_POST['srcendport'] = 0;
175
		$_POST['dstbeginport'] = 0;
176
		$_POST['dstendport'] = 0;
177
	}
178

    
179
	if (is_specialnet($_POST['srctype'])) {
180
		$_POST['src'] = $_POST['srctype'];
181
		$_POST['srcmask'] = 0;
182
	} else if ($_POST['srctype'] == "single") {
183
		$_POST['srcmask'] = 32;
184
	}
185
	if (is_specialnet($_POST['dsttype'])) {
186
		$_POST['dst'] = $_POST['dsttype'];
187
		$_POST['dstmask'] = 0;
188
	} else if ($_POST['dsttype'] == "single") {
189
		$_POST['dstmask'] = 32;
190
	} else if (is_ipaddr($_POST['dsttype'])) {
191
		$_POST['dst'] = $_POST['dsttype'];
192
		$_POST['dstmask'] = 32;
193
		$_POST['dsttype'] = "single";
194
	}
195

    
196
	$pconfig = $_POST;
197

    
198
	/* input validation */
199
	if(strtoupper($_POST['proto']) == "TCP" or strtoupper($_POST['proto']) == "UDP" or strtoupper($_POST['proto']) == "TCP/UDP") {
200
		$reqdfields = explode(" ", "interface proto dstbeginport dstendport");
201
		$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"),gettext("Destination port from"),gettext("Destination port to"));
202
	} else {
203
		$reqdfields = explode(" ", "interface proto");
204
		$reqdfieldsn = array(gettext("Interface"),gettext("Protocol"));
205
	}
206

    
207
	if ($_POST['srctype'] == "single" || $_POST['srctype'] == "network") {
208
		$reqdfields[] = "src";
209
		$reqdfieldsn[] = gettext("Source address");
210
	}
211
	if ($_POST['dsttype'] == "single" || $_POST['dsttype'] == "network") {
212
		$reqdfields[] = "dst";
213
		$reqdfieldsn[] = gettext("Destination address");
214
	}
215
	if (!isset($_POST['nordr'])) {
216
		$reqdfields[] = "localip";
217
		$reqdfieldsn[] = gettext("Redirect target IP");
218
	}
219

    
220
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
221

    
222
	if (!$_POST['srcbeginport']) {
223
		$_POST['srcbeginport'] = 0;
224
		$_POST['srcendport'] = 0;
225
	}
226
	if (!$_POST['dstbeginport']) {
227
		$_POST['dstbeginport'] = 0;
228
		$_POST['dstendport'] = 0;
229
	}
230

    
231
	if ($_POST['src'])
232
		$_POST['src'] = trim($_POST['src']);
233
	if ($_POST['dst'])
234
		$_POST['dst'] = trim($_POST['dst']);
235
	if ($_POST['localip'])
236
		$_POST['localip'] = trim($_POST['localip']);
237

    
238
	if (!isset($_POST['nordr']) && ($_POST['localip'] && !is_ipaddroralias($_POST['localip']))) {
239
		$input_errors[] = sprintf(gettext("\"%s\" is not a valid redirect target IP address or host alias."), $_POST['localip']);
240
	}
241

    
242
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
243
		$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
244
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
245
		$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
246
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
247
		$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
248
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
249
		$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
250

    
251
	if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
252
		$input_errors[] = sprintf(gettext("A valid redirect target port must be specified. It must be a port alias or integer between 1 and 65535."), $_POST['localbeginport']);
253
	}
254

    
255
	/* if user enters an alias and selects "network" then disallow. */
256
	if( ($_POST['srctype'] == "network" && is_alias($_POST['src']) ) 
257
	 || ($_POST['dsttype'] == "network" && is_alias($_POST['dst']) ) ) {
258
		$input_errors[] = gettext("You must specify single host or alias for alias entries.");
259
	}
260

    
261
	if (!is_specialnet($_POST['srctype'])) {
262
		if (($_POST['src'] && !is_ipaddroralias($_POST['src']))) {
263
			$input_errors[] = sprintf(gettext("%s is not a valid source IP address or alias."), $_POST['src']);
264
		}
265
		if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
266
			$input_errors[] = gettext("A valid source bit count must be specified.");
267
		}
268
	}
269
	if (!is_specialnet($_POST['dsttype'])) {
270
		if (($_POST['dst'] && !is_ipaddroralias($_POST['dst']))) {
271
			$input_errors[] = sprintf(gettext("%s is not a valid destination IP address or alias."), $_POST['dst']);
272
		}
273
		if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
274
			$input_errors[] = gettext("A valid destination bit count must be specified.");
275
		}
276
	}
277

    
278
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
279
		/* swap */
280
		$tmp = $_POST['srcendport'];
281
		$_POST['srcendport'] = $_POST['srcbeginport'];
282
		$_POST['srcbeginport'] = $tmp;
283
	}
284
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
285
		/* swap */
286
		$tmp = $_POST['dstendport'];
287
		$_POST['dstendport'] = $_POST['dstbeginport'];
288
		$_POST['dstbeginport'] = $tmp;
289
	}
290

    
291
	if (!$input_errors) {
292
		if (!isset($_POST['nordr']) && ($_POST['dstendport'] - $_POST['dstbeginport'] + $_POST['localbeginport']) > 65535)
293
			$input_errors[] = gettext("The target port range must be an integer between 1 and 65535.");
294
	}
295

    
296
	/* check for overlaps */
297
	foreach ($a_nat as $natent) {
298
		if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent))
299
			continue;
300
		if ($natent['interface'] != $_POST['interface'])
301
			continue;
302
		if ($natent['destination']['address'] != $_POST['dst'])
303
			continue;
304
		if (($natent['proto'] != $_POST['proto']) && ($natent['proto'] != "tcp/udp") && ($_POST['proto'] != "tcp/udp"))
305
			continue;
306

    
307
		list($begp,$endp) = explode("-", $natent['destination']['port']);
308
		if (!$endp)
309
			$endp = $begp;
310

    
311
		if (!(   (($_POST['dstbeginport'] < $begp) && ($_POST['dstendport'] < $begp))
312
		      || (($_POST['dstbeginport'] > $endp) && ($_POST['dstendport'] > $endp)))) {
313

    
314
			$input_errors[] = gettext("The destination port range overlaps with an existing entry.");
315
			break;
316
		}
317
	}
318

    
319
	// Allow extending of the firewall edit page and include custom input validation 
320
	pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/input_validation");
321

    
322
	if (!$input_errors) {
323
		$natent = array();
324

    
325
		$natent['disabled'] = isset($_POST['disabled']) ? true:false;
326
		$natent['nordr'] = isset($_POST['nordr']) ? true:false;
327

    
328
		if ($natent['nordr']) {
329
			$_POST['associated-rule-id'] = '';
330
			$_POST['filter-rule-association'] = '';
331
		}
332

    
333
		pconfig_to_address($natent['source'], $_POST['src'],
334
			$_POST['srcmask'], $_POST['srcnot'],
335
			$_POST['srcbeginport'], $_POST['srcendport']);
336

    
337
		pconfig_to_address($natent['destination'], $_POST['dst'],
338
			$_POST['dstmask'], $_POST['dstnot'],
339
			$_POST['dstbeginport'], $_POST['dstendport']);
340

    
341
		$natent['protocol'] = $_POST['proto'];
342

    
343
		if (!$natent['nordr']) {
344
			$natent['target'] = $_POST['localip'];
345
			$natent['local-port'] = $_POST['localbeginport'];
346
		}
347
		$natent['interface'] = $_POST['interface'];
348
		$natent['descr'] = $_POST['descr'];
349
		$natent['associated-rule-id'] = $_POST['associated-rule-id'];
350

    
351
		if($_POST['filter-rule-association'] == "pass")
352
			$natent['associated-rule-id'] = "pass";
353

    
354
		if($_POST['nosync'] == "yes")
355
			$natent['nosync'] = true;
356
		else
357
			unset($natent['nosync']);
358

    
359
		if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "purenat" || $_POST['natreflection'] == "disable")
360
			$natent['natreflection'] = $_POST['natreflection'];
361
		else
362
			unset($natent['natreflection']);
363

    
364
		// If we used to have an associated filter rule, but no-longer should have one
365
		if (!empty($a_nat[$id]) && ( empty($natent['associated-rule-id']) || $natent['associated-rule-id'] != $a_nat[$id]['associated-rule-id'] ) ) {
366
			// Delete the previous rule
367
			delete_id($a_nat[$id]['associated-rule-id'], $config['filter']['rule']);
368
			mark_subsystem_dirty('filter');
369
		}
370

    
371
		$need_filter_rule = false;
372
		// Updating a rule with a filter rule associated
373
		if (!empty($natent['associated-rule-id']))
374
			$need_filter_rule = true;
375
		// Create a rule or if we want to create a new one
376
		if( $natent['associated-rule-id']=='new' ) {
377
			$need_filter_rule = true;
378
			unset( $natent['associated-rule-id'] );
379
			$_POST['filter-rule-association']='add-associated';
380
		}
381
		// If creating a new rule, where we want to add the filter rule, associated or not
382
		else if( isset($_POST['filter-rule-association']) &&
383
			($_POST['filter-rule-association']=='add-associated' ||
384
			$_POST['filter-rule-association']=='add-unassociated') )
385
			$need_filter_rule = true;
386

    
387
		if ($need_filter_rule == true) {
388

    
389
			/* auto-generate a matching firewall rule */
390
			$filterent = array();
391
			unset($filterentid);
392
			// If a rule already exists, load it
393
			if (!empty($natent['associated-rule-id'])) {
394
				$filterentid = get_id($natent['associated-rule-id'], $config['filter']['rule']);
395
				if ($filterentid === false)
396
					$filterent['associated-rule-id'] = $natent['associated-rule-id'];
397
				else
398
					$filterent =& $config['filter']['rule'][$filterentid];
399
			}
400
			pconfig_to_address($filterent['source'], $_POST['src'],
401
				$_POST['srcmask'], $_POST['srcnot'],
402
				$_POST['srcbeginport'], $_POST['srcendport']);
403

    
404
			// Update interface, protocol and destination
405
			$filterent['interface'] = $_POST['interface'];
406
			$filterent['protocol'] = $_POST['proto'];
407
			$filterent['destination']['address'] = $_POST['localip'];
408

    
409
			$dstpfrom = $_POST['localbeginport'];
410
			$dstpto = $dstpfrom + $_POST['dstendport'] - $_POST['dstbeginport'];
411

    
412
			if ($dstpfrom == $dstpto)
413
				$filterent['destination']['port'] = $dstpfrom;
414
			else
415
				$filterent['destination']['port'] = $dstpfrom . "-" . $dstpto;
416

    
417
			/*
418
			 * Our firewall filter description may be no longer than
419
			 * 63 characters, so don't let it be.
420
			 */
421
			$filterent['descr'] = substr("NAT " . $_POST['descr'], 0, 62);
422

    
423
			// If this is a new rule, create an ID and add the rule
424
			if( $_POST['filter-rule-association']=='add-associated' ) {
425
				$filterent['associated-rule-id'] = $natent['associated-rule-id'] = get_unique_id();
426
				$filterent['created'] = make_config_revision_entry(null, gettext("NAT Port Forward"));
427
				$config['filter']['rule'][] = $filterent;
428
			}
429

    
430
			mark_subsystem_dirty('filter');
431
		}
432

    
433
		if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
434
			$natent['created'] = $a_nat[$id]['created'];
435

    
436
		$natent['updated'] = make_config_revision_entry();
437

    
438
		// Allow extending of the firewall edit page and include custom input validation 
439
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_write_config");
440

    
441
		// Update the NAT entry now
442
		if (isset($id) && $a_nat[$id])
443
			$a_nat[$id] = $natent;
444
		else {
445
			$natent['created'] = make_config_revision_entry();
446
			if (is_numeric($after))
447
				array_splice($a_nat, $after+1, 0, array($natent));
448
			else
449
				$a_nat[] = $natent;
450
		}
451

    
452
		if (write_config())
453
			mark_subsystem_dirty('natconf');
454

    
455
		header("Location: firewall_nat.php");
456
		exit;
457
	}
458
}
459

    
460
$closehead = false;
461
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Port Forward"),gettext("Edit"));
462
include("head.inc");
463

    
464
?>
465
<link type="text/css" rel="stylesheet" href="/javascript/chosen/chosen.css" />
466
</head>
467

    
468
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
469
<script src="/javascript/chosen/chosen.jquery.js" type="text/javascript"></script>
470
<?php
471
include("fbegin.inc"); ?>
472
<?php if ($input_errors) print_input_errors($input_errors); ?>
473
            <form action="firewall_nat_edit.php" method="post" name="iform" id="iform">
474
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="firewall nat edit">
475
				<tr>
476
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Redirect entry"); ?></td>
477
				</tr>
478
<?php
479
		// Allow extending of the firewall edit page and include custom input validation 
480
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/htmlphpearly");
481
?>
482
		<tr>
483
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
484
			<td width="78%" class="vtable">
485
				<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
486
				<strong><?=gettext("Disable this rule"); ?></strong><br />
487
				<span class="vexpl"><?=gettext("Set this option to disable this rule without removing it from the list."); ?></span>
488
			</td>
489
		</tr>
490
                <tr>
491
                  <td width="22%" valign="top" class="vncell"><?=gettext("No RDR (NOT)"); ?></td>
492
                  <td width="78%" class="vtable">
493
                    <input type="checkbox" name="nordr" id="nordr" onclick="nordr_change();" <?php if($pconfig['nordr']) echo "checked=\"checked\""; ?> />
494
                    <span class="vexpl"><?=gettext("Enabling this option will disable redirection for traffic matching this rule."); ?>
495
                    <br /><?=gettext("Hint: this option is rarely needed, don't use this unless you know what you're doing."); ?></span>
496
                  </td>
497
                </tr>
498
		<tr>
499
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
500
                  <td width="78%" class="vtable">
501
					<select name="interface" class="formselect" onchange="dst_change(this.value,iface_old,document.iform.dsttype.value);iface_old = document.iform.interface.value;typesel_change();">
502
						<?php
503

    
504
						$iflist = get_configured_interface_with_descr(false, true);
505
						// Allow extending of the firewall edit interfaces 
506
						pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_interfaces_edit");
507
						foreach ($iflist as $if => $ifdesc)
508
							if(have_ruleint_access($if))
509
								$interfaces[$if] = $ifdesc;
510

    
511
						if ($config['l2tp']['mode'] == "server")
512
							if(have_ruleint_access("l2tp"))
513
								$interfaces['l2tp'] = "L2TP VPN";
514

    
515
						if ($config['pptpd']['mode'] == "server")
516
							if(have_ruleint_access("pptp"))
517
								$interfaces['pptp'] = "PPTP VPN";
518

    
519
						if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
520
							$interfaces['pppoe'] = "PPPoE Server";
521

    
522
						/* add ipsec interfaces */
523
						if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
524
							if(have_ruleint_access("enc0"))
525
								$interfaces["enc0"] = "IPsec";
526

    
527
						/* add openvpn/tun interfaces */
528
						if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
529
							$interfaces["openvpn"] = "OpenVPN";
530

    
531
						foreach ($interfaces as $iface => $ifacename): ?>
532
						<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected=\"selected\""; ?>>
533
						<?=htmlspecialchars($ifacename);?>
534
						</option>
535
						<?php endforeach; ?>
536
					</select><br />
537
                     <span class="vexpl"><?=gettext("Choose which interface this rule applies to."); ?><br />
538
                     <?=gettext("Hint: in most cases, you'll want to use WAN here."); ?></span></td>
539
                </tr>
540
                <tr>
541
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol"); ?></td>
542
                  <td width="78%" class="vtable">
543
                    <select name="proto" class="formselect" onchange="proto_change(); check_for_aliases();">
544
                      <?php $protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPV6 IGMP PIM OSPF"); foreach ($protocols as $proto): ?>
545
                      <option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected=\"selected\""; ?>><?=htmlspecialchars($proto);?></option>
546
                      <?php endforeach; ?>
547
                    </select> <br /> <span class="vexpl"><?=gettext("Choose which IP protocol " .
548
                    "this rule should match."); ?><br />
549
                    <?=gettext("Hint: in most cases, you should specify"); ?> <em><?=gettext("TCP"); ?></em> &nbsp;<?=gettext("here."); ?></span></td>
550
                </tr>
551
		<tr id="showadvancedboxsrc" name="showadvancedboxsrc">
552
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source"); ?></td>
553
			<td width="78%" class="vtable">
554
				<input type="button" onclick="show_source()" value="<?=gettext("Advanced"); ?>" /> - <?=gettext("Show source address and port range"); ?>
555
			</td>
556
		</tr>
557
		<tr style="display: none;" id="srctable" name="srctable">
558
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source"); ?></td>
559
			<td width="78%" class="vtable">
560
				<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked=\"checked\""; ?> />
561
				<strong><?=gettext("not"); ?></strong>
562
				<br />
563
				<?=gettext("Use this option to invert the sense of the match."); ?>
564
				<br />
565
				<br />
566
				<table border="0" cellspacing="0" cellpadding="0" summary="type">
567
					<tr>
568
						<td><?=gettext("Type:"); ?>&nbsp;&nbsp;</td>
569
						<td>
570
							<select name="srctype" class="formselect" onchange="typesel_change()">
571
<?php
572
								$sel = is_specialnet($pconfig['src']); ?>
573
								<option value="any"     <?php if ($pconfig['src'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any"); ?></option>
574
								<option value="single"  <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected=\"selected\""; $sel = 1; } ?>><?=gettext("Single host or alias"); ?></option>
575
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network"); ?></option>
576
								<?php if(have_ruleint_access("pptp")): ?>
577
								<option value="pptp"    <?php if ($pconfig['src'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients"); ?></option>
578
								<?php endif; ?>
579
								<?php if(have_ruleint_access("pppoe")): ?>
580
								<option value="pppoe"   <?php if ($pconfig['src'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients"); ?></option>
581
								<?php endif; ?>
582
								 <?php if(have_ruleint_access("l2tp")): ?>
583
                                                                <option value="l2tp"   <?php if ($pconfig['src'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients"); ?></option>
584
                                 <?php endif; ?>
585
<?php
586
								foreach ($ifdisp as $ifent => $ifdesc): ?>
587
								<?php if(have_ruleint_access($ifent)): ?>
588
									<option value="<?=$ifent;?>" <?php if ($pconfig['src'] == $ifent) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net"); ?></option>
589
									<option value="<?=$ifent;?>ip"<?php if ($pconfig['src'] ==  $ifent . "ip") { echo "selected=\"selected\""; } ?>>
590
										<?=$ifdesc?> <?=gettext("address");?>
591
									</option>
592
								<?php endif; ?>
593
<?php 							endforeach; ?>
594
							</select>
595
						</td>
596
					</tr>
597
					<tr>
598
						<td><?=gettext("Address:"); ?>&nbsp;&nbsp;</td>
599
						<td>
600
							<input autocomplete='off' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>" /> /
601
							<select name="srcmask" class="formselect" id="srcmask">
602
<?php						for ($i = 31; $i > 0; $i--): ?>
603
								<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
604
<?php 						endfor; ?>
605
							</select>
606
						</td>
607
					</tr>
608
				</table>
609
			</td>
610
		</tr>
611
		<tr style="display:none" id="sprtable" name="sprtable">
612
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Source port range"); ?></td>
613
			<td width="78%" class="vtable">
614
				<table border="0" cellspacing="0" cellpadding="0" summary="source port range">
615
					<tr>
616
						<td><?=gettext("from:"); ?>&nbsp;&nbsp;</td>
617
						<td>
618
							<select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
619
								<option value="">(<?=gettext("other"); ?>)</option>
620
								<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any"); ?></option>
621
<?php 							foreach ($wkports as $wkport => $wkportdesc): ?>
622
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
623
<?php 							endforeach; ?>
624
							</select>
625
							<input autocomplete='off' class="formfldalias" name="srcbeginport_cust" id="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo htmlspecialchars($pconfig['srcbeginport']); ?>" />
626
						</td>
627
					</tr>
628
					<tr>
629
						<td><?=gettext("to:"); ?></td>
630
						<td>
631
							<select name="srcendport" class="formselect" onchange="ext_change()">
632
								<option value="">(<?=gettext("other"); ?>)</option>
633
								<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected=\"selected\""; $bfound = 1; } ?>><?=gettext("any"); ?></option>
634
<?php							foreach ($wkports as $wkport => $wkportdesc): ?>
635
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
636
<?php							endforeach; ?>
637
							</select>
638
							<input autocomplete='off' class="formfldalias" name="srcendport_cust" id="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo htmlspecialchars($pconfig['srcendport']); ?>" />
639
						</td>
640
					</tr>
641
				</table>
642
				<br />
643
				<span class="vexpl"><?=gettext("Specify the source port or port range for this rule"); ?>. <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be 'any')"); ?>.</b> <br /> <?=gettext("Hint: you can leave the"); ?> <em>'<?=gettext("to"); ?>'</em> <?=gettext("field empty if you only want to filter a single port."); ?></span><br />
644
			</td>
645
		</tr>
646
		<tr>
647
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination"); ?></td>
648
			<td width="78%" class="vtable">
649
				<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked=\"checked\""; ?> />
650
				<strong><?=gettext("not"); ?></strong>
651
					<br />
652
				<?=gettext("Use this option to invert the sense of the match."); ?>
653
					<br />
654
					<br />
655
				<table border="0" cellspacing="0" cellpadding="0" summary="type">
656
					<tr>
657
						<td><?=gettext("Type:"); ?>&nbsp;&nbsp;</td>
658
						<td>
659
							<select name="dsttype" class="formselect" onchange="typesel_change()">
660
<?php
661
								$sel = is_specialnet($pconfig['dst']); ?>
662
								<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected=\"selected\""; } ?>><?=gettext("any"); ?></option>
663
								<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected=\"selected\""; $sel = 1; } ?>><?=gettext("Single host or alias"); ?></option>
664
								<option value="network" <?php if (!$sel) echo "selected=\"selected\""; ?>><?=gettext("Network"); ?></option>
665
								<option value="(self)" <?PHP if ($pconfig['dst'] == "(self)") echo "selected=\"selected\""; ?>><?=gettext("This Firewall (self)");?></option>
666
								<?php if(have_ruleint_access("pptp")): ?>
667
								<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected=\"selected\""; } ?>><?=gettext("PPTP clients"); ?></option>
668
								<?php endif; ?>
669
								<?php if(have_ruleint_access("pppoe")): ?>
670
								<option value="pppoe" <?php if ($pconfig['dst'] == "pppoe") { echo "selected=\"selected\""; } ?>><?=gettext("PPPoE clients"); ?></option>
671
								<?php endif; ?>
672
								<?php if(have_ruleint_access("l2tp")): ?>
673
                                                                <option value="l2tp" <?php if ($pconfig['dst'] == "l2tp") { echo "selected=\"selected\""; } ?>><?=gettext("L2TP clients"); ?></option>
674
                                                                <?php endif; ?>
675

    
676
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
677
								<?php if(have_ruleint_access($if)): ?>
678
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected=\"selected\""; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("net"); ?></option>
679
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected=\"selected\""; } ?>>
680
										<?=$ifdesc;?> <?=gettext("address");?>
681
									</option>
682
								<?php endif; ?>
683
<?php 							endforeach; ?>
684

    
685
<?php							if (is_array($config['virtualip']['vip'])):
686
									foreach ($config['virtualip']['vip'] as $sn):
687
										if (isset($sn['noexpand']))
688
											continue;
689
										if ($sn['mode'] == "proxyarp" && $sn['type'] == "network"):
690
											$start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
691
											$end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
692
											$len = $end - $start;
693
											for ($i = 0; $i <= $len; $i++):
694
												$snip = long2ip32($start+$i);
695
?>
696
												<option value="<?=$snip;?>" <?php if ($snip == $pconfig['dst']) echo "selected=\"selected\""; ?>><?=htmlspecialchars("{$snip} ({$sn['descr']})");?></option>
697
<?php										endfor;
698
										else:
699
?>
700
											<option value="<?=$sn['subnet'];?>" <?php if ($sn['subnet'] == $pconfig['dst']) echo "selected=\"selected\""; ?>><?=htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");?></option>
701
<?php									endif;
702
									endforeach;
703
								endif;
704
?>
705
							</select>
706
						</td>
707
					</tr>
708
					<tr>
709
						<td><?=gettext("Address:"); ?>&nbsp;&nbsp;</td>
710
						<td>
711
							<input autocomplete='off' name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>" />
712
							/
713
							<select name="dstmask" class="formselect" id="dstmask">
714
<?php
715
							for ($i = 31; $i > 0; $i--): ?>
716
								<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected=\"selected\""; ?>><?=$i;?></option>
717
<?php						endfor; ?>
718
							</select>
719
						</td>
720
					</tr>
721
				</table>
722
			</td>
723
		</tr>
724
		<tr id="dprtr" name="dprtr">
725
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Destination port range"); ?> </td>
726
			<td width="78%" class="vtable">
727
				<table border="0" cellspacing="0" cellpadding="0" summary="destination port range">
728
					<tr>
729
						<td><?=gettext("from:"); ?>&nbsp;&nbsp;</td>
730
						<td>
731
							<select name="dstbeginport" id="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
732
								<option value="">(<?=gettext("other"); ?>)</option>
733
<?php 							$bfound = 0;
734
								foreach ($wkports as $wkport => $wkportdesc): ?>
735
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) { echo "selected=\"selected\""; $bfound = 1; }?>><?=htmlspecialchars($wkportdesc);?></option>
736
<?php 							endforeach; ?>
737
							</select>
738
							<input autocomplete='off' class="formfldalias" name="dstbeginport_cust" id="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo htmlspecialchars($pconfig['dstbeginport']); ?>" />
739
						</td>
740
					</tr>
741
					<tr>
742
						<td><?=gettext("to:"); ?></td>
743
						<td>
744
							<select name="dstendport" id="dstendport" class="formselect" onchange="ext_change()">
745
								<option value="">(<?=gettext("other"); ?>)</option>
746
<?php							$bfound = 0;
747
								foreach ($wkports as $wkport => $wkportdesc): ?>
748
									<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) { echo "selected=\"selected\""; $bfound = 1; } ?>><?=htmlspecialchars($wkportdesc);?></option>
749
<?php 							endforeach; ?>
750
							</select>
751
							<input autocomplete='off' class="formfldalias" name="dstendport_cust" id="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo htmlspecialchars($pconfig['dstendport']); ?>" />
752
						</td>
753
					</tr>
754
				</table>
755
				<br />
756
				<span class="vexpl">
757
					<?=gettext("Specify the port or port range for the destination of the packet for this mapping."); ?>
758
					<br />
759
					<?=gettext("Hint: you can leave the"); ?> <em>'<?=gettext("to"); ?>'</em> <?=gettext("field empty if you only want to map a single port"); ?>
760
				</span>
761
			</td>
762
		</tr>
763
                <tr name="localiptable" id="localiptable">
764
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Redirect target IP"); ?></td>
765
                  <td width="78%" class="vtable">
766
                    <input autocomplete='off' name="localip" type="text" class="formfldalias" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>" />
767
                    <br /> <span class="vexpl"><?=gettext("Enter the internal IP address of " .
768
                    "the server on which you want to map the ports."); ?><br />
769
                    <?=gettext("e.g."); ?> <em>192.168.1.12</em></span></td>
770
                </tr>
771
                <tr name="lprtr" id="lprtr">
772
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Redirect target port"); ?></td>
773
                  <td width="78%" class="vtable">
774
                    <select name="localbeginport" id="localbeginport" class="formselect" onchange="ext_change();check_for_aliases();">
775
                      <option value="">(<?=gettext("other"); ?>)</option>
776
                      <?php $bfound = 0; foreach ($wkports as $wkport => $wkportdesc): ?>
777
                      <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['localbeginport']) {
778
							echo "selected=\"selected\"";
779
							$bfound = 1;
780
						}?>>
781
					  <?=htmlspecialchars($wkportdesc);?>
782
					  </option>
783
                      <?php endforeach; ?>
784
                    </select> <input onchange="check_for_aliases();" autocomplete='off' class="formfldalias" name="localbeginport_cust" id="localbeginport_cust" type="text" size="5" value="<?php if (!$bfound) echo htmlspecialchars($pconfig['localbeginport']); ?>" />
785
                    <br />
786
                    <span class="vexpl"><?=gettext("Specify the port on the machine with the " .
787
                    "IP address entered above. In case of a port range, specify " .
788
                    "the beginning port of the range (the end port will be calculated " .
789
                    "automatically)."); ?><br />
790
                    <?=gettext("Hint: this is usually identical to the 'from' port above"); ?></span></td>
791
                </tr>
792
                <tr>
793
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
794
                  <td width="78%" class="vtable">
795
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
796
                    <br /> <span class="vexpl"><?=gettext("You may enter a description here " .
797
                    "for your reference (not parsed)."); ?></span></td>
798
                </tr>
799
				<tr>
800
					<td width="22%" valign="top" class="vncell"><?=gettext("No XMLRPC Sync"); ?></td>
801
					<td width="78%" class="vtable">
802
						<input type="checkbox" value="yes" name="nosync"<?php if($pconfig['nosync']) echo " checked=\"checked\""; ?> /><br />
803
						<?=gettext("Hint: This prevents the rule on Master from automatically syncing to other CARP members. This does NOT prevent the rule from being overwritten on Slave.");?>
804
					</td>
805
				</tr>
806
				<tr>
807
					<td width="22%" valign="top" class="vncell"><?=gettext("NAT reflection"); ?></td>
808
					<td width="78%" class="vtable">
809
						<select name="natreflection" class="formselect">
810
						<option value="default" <?php if ($pconfig['natreflection'] != "enable" && $pconfig['natreflection'] != "purenat" && $pconfig['natreflection'] != "disable") echo "selected=\"selected\""; ?>><?=gettext("Use system default"); ?></option>
811
						<option value="enable" <?php if ($pconfig['natreflection'] == "enable") echo "selected=\"selected\""; ?>><?=gettext("Enable (NAT + Proxy)"); ?></option>
812
						<option value="purenat" <?php if ($pconfig['natreflection'] == "purenat") echo "selected=\"selected\""; ?>><?=gettext("Enable (Pure NAT)"); ?></option>
813
						<option value="disable" <?php if ($pconfig['natreflection'] == "disable") echo "selected=\"selected\""; ?>><?=gettext("Disable"); ?></option>
814
						</select>
815
					</td>
816
				</tr>
817
				<?php if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET['dup']))): ?>
818
				<tr name="assoctable" id="assoctable">
819
					<td width="22%" valign="top" class="vncell"><?=gettext("Filter rule association"); ?></td>
820
					<td width="78%" class="vtable">
821
						<select name="associated-rule-id">
822
							<option value=""><?=gettext("None"); ?></option>
823
							<option value="pass" <?php if($pconfig['associated-rule-id'] == "pass") echo " selected=\"selected\""; ?>><?=gettext("Pass"); ?></option>
824
							<?php
825
							$linkedrule = "";
826
							if (is_array($config['filter']['rule'])) {
827
							      filter_rules_sort();
828
							      foreach ($config['filter']['rule'] as $filter_id => $filter_rule) {
829
								if (isset($filter_rule['associated-rule-id'])) {
830
									echo "<option value=\"{$filter_rule['associated-rule-id']}\"";
831
									if ($filter_rule['associated-rule-id']==$pconfig['associated-rule-id']) {
832
										echo " selected=\"selected\"";
833
										$linkedrule = "<br /><a href=\"firewall_rules_edit.php?id={$filter_id}\">" . gettext("View the filter rule") . "</a><br />";
834
									}
835
									echo ">". htmlspecialchars('Rule ' . $filter_rule['descr']) . "</option>\n";
836

    
837
								}
838
							      }
839
							}
840
							if (isset($pconfig['associated-rule-id']))
841
								echo "<option value=\"new\">" . gettext("Create new associated filter rule") . "</option>\n";
842
						echo "</select>\n";
843
						echo $linkedrule;
844
						?>
845
					</td>
846
				</tr>
847
				<?php endif; ?>
848
                <?php if ((!(isset($id) && $a_nat[$id])) || (isset($_GET['dup']) && is_numericint($_GET['dup']))): ?>
849
                <tr name="assoctable" id="assoctable">
850
                  <td width="22%" valign="top" class="vncell"><?=gettext("Filter rule association"); ?></td>
851
                  <td width="78%" class="vtable">
852
                    <select name="filter-rule-association" id="filter-rule-association">
853
						<option value=""><?=gettext("None"); ?></option>
854
						<option value="add-associated" selected="selected"><?=gettext("Add associated filter rule"); ?></option>
855
						<option value="add-unassociated"><?=gettext("Add unassociated filter rule"); ?></option>
856
						<option value="pass"><?=gettext("Pass"); ?></option>
857
					</select>
858
					<br /><br /><?=gettext("NOTE: The \"pass\" selection does not work properly with Multi-WAN. It will only work on an interface containing the default gateway.")?>
859
				  </td>
860
                </tr><?php endif; ?>
861
<?php
862
		// Allow extending of the firewall edit page and include custom input validation 
863
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/htmlphplate");
864
?>
865
<?php
866
$has_created_time = (isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']));
867
$has_updated_time = (isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']));
868
?>
869
		<?php if ($has_created_time || $has_updated_time): ?>
870
		<tr>
871
			<td>&nbsp;</td>
872
		</tr>
873
		<tr>
874
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Rule Information");?></td>
875
		</tr>
876
		<?php if ($has_created_time): ?>
877
		<tr>
878
			<td width="22%" valign="top" class="vncell"><?=gettext("Created");?></td>
879
			<td width="78%" class="vtable">
880
				<?= date(gettext("n/j/y H:i:s"), $a_nat[$id]['created']['time']) ?> <?= gettext("by") ?> <strong><?= $a_nat[$id]['created']['username'] ?></strong>
881
			</td>
882
		</tr>
883
		<?php endif; ?>
884
		<?php if ($has_updated_time): ?>
885
		<tr>
886
			<td width="22%" valign="top" class="vncell"><?=gettext("Updated");?></td>
887
			<td width="78%" class="vtable">
888
				<?= date(gettext("n/j/y H:i:s"), $a_nat[$id]['updated']['time']) ?> <?= gettext("by") ?> <strong><?= $a_nat[$id]['updated']['username'] ?></strong>
889
			</td>
890
		</tr>
891
		<?php endif; ?>
892
		<?php endif; ?>
893
				<tr>
894
                  <td width="22%" valign="top">&nbsp;</td>
895
                  <td width="78%">&nbsp;</td>
896
				</tr>
897
                <tr>
898
                  <td width="22%" valign="top">&nbsp;</td>
899
                  <td width="78%">
900
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
901
                    <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
902
                    <input name="referer" type="hidden" value="<?=$referer;?>" />
903
                    <?php if (isset($id) && $a_nat[$id]): ?>
904
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
905
                    <?php endif; ?>
906
                    <input name="after" type="hidden" value="<?=htmlspecialchars($after);?>" />
907
                  </td>
908
                </tr>
909
              </table>
910
</form>
911
<script type="text/javascript">
912
//<![CDATA[
913
	ext_change();
914
	dst_change(document.iform.interface.value,'<?=htmlspecialchars($pconfig['interface'])?>','<?=htmlspecialchars($pconfig['dst'])?>');
915
	var iface_old = document.iform.interface.value;
916
	typesel_change();
917
	proto_change();
918
	<?php if ($pconfig['srcnot'] || $pconfig['src'] != "any" || $pconfig['srcbeginport'] != "any" || $pconfig['srcendport'] != "any"): ?>
919
	show_source();
920
	<?php endif; ?>
921
	nordr_change();
922
//]]>
923
</script>
924
<script type="text/javascript">
925
//<![CDATA[
926
	var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>;
927
	var customarray  = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>;
928

    
929
	var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
930
	var oTextbox2 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
931
	var oTextbox3 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
932
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
933
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
934
	var oTextbox6 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
935
	var oTextbox7 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
936
	var oTextbox8 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
937
//]]>
938
</script>
939
<?php include("fend.inc"); ?>
940
</body>
941
</html>
(66-66/252)