Project

General

Profile

Download (43.5 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
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_nat.php');
50

    
51
$specialsrcdst = explode(" ", "any (self) pptp pppoe l2tp openvpn");
52
$ifdisp = get_configured_interface_with_descr();
53
foreach ($ifdisp as $kif => $kdescr) {
54
	$specialsrcdst[] = "{$kif}";
55
	$specialsrcdst[] = "{$kif}ip";
56
}
57

    
58
if (!is_array($config['nat']['rule'])) {
59
	$config['nat']['rule'] = array();
60
}
61
$a_nat = &$config['nat']['rule'];
62

    
63
if (is_numericint($_GET['id']))
64
	$id = $_GET['id'];
65
if (isset($_POST['id']) && is_numericint($_POST['id']))
66
	$id = $_POST['id'];
67

    
68
if (is_numericint($_GET['after']) || $_GET['after'] == "-1")
69
	$after = $_GET['after'];
70
if (isset($_POST['after']) && (is_numericint($_POST['after']) || $_POST['after'] == "-1"))
71
	$after = $_POST['after'];
72

    
73
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
74
        $id = $_GET['dup'];
75
        $after = $_GET['dup'];
76
}
77

    
78
if (isset($id) && $a_nat[$id]) {
79
	if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
80
		$pconfig['created'] = $a_nat[$id]['created'];
81

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

    
85
	$pconfig['disabled'] = isset($a_nat[$id]['disabled']);
86
	$pconfig['nordr'] = isset($a_nat[$id]['nordr']);
87
	address_to_pconfig($a_nat[$id]['source'], $pconfig['src'],
88
		$pconfig['srcmask'], $pconfig['srcnot'],
89
		$pconfig['srcbeginport'], $pconfig['srcendport']);
90

    
91
	address_to_pconfig($a_nat[$id]['destination'], $pconfig['dst'],
92
		$pconfig['dstmask'], $pconfig['dstnot'],
93
		$pconfig['dstbeginport'], $pconfig['dstendport']);
94

    
95
	$pconfig['proto'] = $a_nat[$id]['protocol'];
96
	$pconfig['localip'] = $a_nat[$id]['target'];
97
	$pconfig['localbeginport'] = $a_nat[$id]['local-port'];
98
	$pconfig['descr'] = $a_nat[$id]['descr'];
99
	$pconfig['interface'] = $a_nat[$id]['interface'];
100
	$pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id'];
101
	$pconfig['nosync'] = isset($a_nat[$id]['nosync']);
102
	$pconfig['natreflection'] = $a_nat[$id]['natreflection'];
103

    
104
	if (!$pconfig['interface'])
105
		$pconfig['interface'] = "wan";
106
} else {
107
	$pconfig['interface'] = "wan";
108
	$pconfig['src'] = "any";
109
	$pconfig['srcbeginport'] = "any";
110
	$pconfig['srcendport'] = "any";
111
}
112

    
113
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
114
	unset($id);
115

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

    
127
if ($_POST) {
128

    
129
	if(strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") {
130
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
131
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
132
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
133
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
134

    
135
		if ($_POST['srcbeginport'] == "any") {
136
			$_POST['srcbeginport'] = 0;
137
			$_POST['srcendport'] = 0;
138
		} else {
139
			if (!$_POST['srcendport'])
140
				$_POST['srcendport'] = $_POST['srcbeginport'];
141
		}
142
		if ($_POST['srcendport'] == "any")
143
			$_POST['srcendport'] = $_POST['srcbeginport'];
144

    
145
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
146
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
147
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
148
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
149

    
150
		if ($_POST['dstbeginport'] == "any") {
151
			$_POST['dstbeginport'] = 0;
152
			$_POST['dstendport'] = 0;
153
		} else {
154
			if (!$_POST['dstendport'])
155
				$_POST['dstendport'] = $_POST['dstbeginport'];
156
		}
157
		if ($_POST['dstendport'] == "any")
158
			$_POST['dstendport'] = $_POST['dstbeginport'];
159

    
160
		if ($_POST['localbeginport_cust'] && !$_POST['localbeginport'])
161
			$_POST['localbeginport'] = trim($_POST['localbeginport_cust']);
162

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

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

    
192
	$pconfig = $_POST;
193

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

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

    
216
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
217

    
218
	if (!$_POST['srcbeginport']) {
219
		$_POST['srcbeginport'] = 0;
220
		$_POST['srcendport'] = 0;
221
	}
222
	if (!$_POST['dstbeginport']) {
223
		$_POST['dstbeginport'] = 0;
224
		$_POST['dstendport'] = 0;
225
	}
226

    
227
	if ($_POST['src'])
228
		$_POST['src'] = trim($_POST['src']);
229
	if ($_POST['dst'])
230
		$_POST['dst'] = trim($_POST['dst']);
231
	if ($_POST['localip'])
232
		$_POST['localip'] = trim($_POST['localip']);
233

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

    
238
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
239
		$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']);
240
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
241
		$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']);
242
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
243
		$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']);
244
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
245
		$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']);
246

    
247
	if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
248
		$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']);
249
	}
250

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

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

    
274
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
275
		/* swap */
276
		$tmp = $_POST['srcendport'];
277
		$_POST['srcendport'] = $_POST['srcbeginport'];
278
		$_POST['srcbeginport'] = $tmp;
279
	}
280
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
281
		/* swap */
282
		$tmp = $_POST['dstendport'];
283
		$_POST['dstendport'] = $_POST['dstbeginport'];
284
		$_POST['dstbeginport'] = $tmp;
285
	}
286

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

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

    
303
		list($begp,$endp) = explode("-", $natent['destination']['port']);
304
		if (!$endp)
305
			$endp = $begp;
306

    
307
		if (!(   (($_POST['beginport'] < $begp) && ($_POST['endport'] < $begp))
308
		      || (($_POST['beginport'] > $endp) && ($_POST['endport'] > $endp)))) {
309

    
310
			$input_errors[] = gettext("The destination port range overlaps with an existing entry.");
311
			break;
312
		}
313
	}
314

    
315
	// Allow extending of the firewall edit page and include custom input validation 
316
	pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/input_validation");
317

    
318
	if (!$input_errors) {
319
		$natent = array();
320

    
321
		$natent['disabled'] = isset($_POST['disabled']) ? true:false;
322
		$natent['nordr'] = isset($_POST['nordr']) ? true:false;
323

    
324
		if ($natent['nordr']) {
325
			$_POST['associated-rule-id'] = '';
326
			$_POST['filter-rule-association'] = '';
327
		}
328

    
329
		pconfig_to_address($natent['source'], $_POST['src'],
330
			$_POST['srcmask'], $_POST['srcnot'],
331
			$_POST['srcbeginport'], $_POST['srcendport']);
332

    
333
		pconfig_to_address($natent['destination'], $_POST['dst'],
334
			$_POST['dstmask'], $_POST['dstnot'],
335
			$_POST['dstbeginport'], $_POST['dstendport']);
336

    
337
		$natent['protocol'] = $_POST['proto'];
338

    
339
		if (!$natent['nordr']) {
340
			$natent['target'] = $_POST['localip'];
341
			$natent['local-port'] = $_POST['localbeginport'];
342
		}
343
		$natent['interface'] = $_POST['interface'];
344
		$natent['descr'] = $_POST['descr'];
345
		$natent['associated-rule-id'] = $_POST['associated-rule-id'];
346

    
347
		if($_POST['filter-rule-association'] == "pass")
348
			$natent['associated-rule-id'] = "pass";
349

    
350
		if($_POST['nosync'] == "yes")
351
			$natent['nosync'] = true;
352
		else
353
			unset($natent['nosync']);
354

    
355
		if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "purenat" || $_POST['natreflection'] == "disable")
356
			$natent['natreflection'] = $_POST['natreflection'];
357
		else
358
			unset($natent['natreflection']);
359

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

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

    
383
		if ($need_filter_rule == true) {
384

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

    
400
			// Update interface, protocol and destination
401
			$filterent['interface'] = $_POST['interface'];
402
			$filterent['protocol'] = $_POST['proto'];
403
			$filterent['destination']['address'] = $_POST['localip'];
404

    
405
			$dstpfrom = $_POST['localbeginport'];
406
			$dstpto = $dstpfrom + $_POST['dstendport'] - $_POST['dstbeginport'];
407

    
408
			if ($dstpfrom == $dstpto)
409
				$filterent['destination']['port'] = $dstpfrom;
410
			else
411
				$filterent['destination']['port'] = $dstpfrom . "-" . $dstpto;
412

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

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

    
426
			mark_subsystem_dirty('filter');
427
		}
428

    
429
		if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
430
			$natent['created'] = $a_nat[$id]['created'];
431

    
432
		$natent['updated'] = make_config_revision_entry();
433

    
434
		// Allow extending of the firewall edit page and include custom input validation 
435
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_write_config");
436

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

    
448
		if (write_config())
449
			mark_subsystem_dirty('natconf');
450

    
451
		header("Location: firewall_nat.php");
452
		exit;
453
	}
454
}
455

    
456
$closehead = false;
457
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Port Forward"),gettext("Edit"));
458
include("head.inc");
459

    
460
?>
461
<link type="text/css" rel="stylesheet" href="/javascript/chosen/chosen.css" />
462
</head>
463

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

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

    
507
						if ($config['l2tp']['mode'] == "server")
508
							if(have_ruleint_access("l2tp"))
509
								$interfaces['l2tp'] = "L2TP VPN";
510

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

    
515
						if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
516
							$interfaces['pppoe'] = "PPPoE Server";
517

    
518
						/* add ipsec interfaces */
519
						if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
520
							if(have_ruleint_access("enc0"))
521
								$interfaces["enc0"] = "IPsec";
522

    
523
						/* add openvpn/tun interfaces */
524
						if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
525
							$interfaces["openvpn"] = "OpenVPN";
526

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

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

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

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

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