Project

General

Profile

Download (42 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
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

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

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_MODULE:	nat
33
*/
34

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

    
42
require("guiconfig.inc");
43
require_once("itemid.inc");
44
require("filter.inc");
45
require("shaper.inc");
46

    
47
$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn");
48
$ifdisp = get_configured_interface_with_descr();
49
foreach ($ifdisp as $kif => $kdescr) {
50
	$specialsrcdst[] = "{$kif}";
51
	$specialsrcdst[] = "{$kif}ip";
52
}
53

    
54
if (!is_array($config['nat']['rule'])) {
55
	$config['nat']['rule'] = array();
56
}
57
$a_nat = &$config['nat']['rule'];
58

    
59
$id = $_GET['id'];
60
if (isset($_POST['id']))
61
	$id = $_POST['id'];
62

    
63
$after = $_GET['after'];
64

    
65
if (isset($_POST['after']))
66
	$after = $_POST['after'];
67

    
68
if (isset($_GET['dup'])) {
69
        $id = $_GET['dup'];
70
        $after = $_GET['dup'];
71
}
72

    
73
if (isset($id) && $a_nat[$id]) {
74
	if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
75
		$pconfig['created'] = $a_nat[$id]['created'];
76

    
77
	if ( isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']) )
78
		$pconfig['updated'] = $a_nat[$id]['updated'];
79

    
80
	$pconfig['disabled'] = isset($a_nat[$id]['disabled']);
81
	$pconfig['nordr'] = isset($a_nat[$id]['nordr']);
82
	address_to_pconfig($a_nat[$id]['source'], $pconfig['src'],
83
		$pconfig['srcmask'], $pconfig['srcnot'],
84
		$pconfig['srcbeginport'], $pconfig['srcendport']);
85

    
86
	address_to_pconfig($a_nat[$id]['destination'], $pconfig['dst'],
87
		$pconfig['dstmask'], $pconfig['dstnot'],
88
		$pconfig['dstbeginport'], $pconfig['dstendport']);
89

    
90
	$pconfig['proto'] = $a_nat[$id]['protocol'];
91
	$pconfig['localip'] = $a_nat[$id]['target'];
92
	$pconfig['localbeginport'] = $a_nat[$id]['local-port'];
93
	$pconfig['descr'] = $a_nat[$id]['descr'];
94
	$pconfig['interface'] = $a_nat[$id]['interface'];
95
	$pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id'];
96
	$pconfig['nosync'] = isset($a_nat[$id]['nosync']);
97
	$pconfig['natreflection'] = $a_nat[$id]['natreflection'];
98

    
99
	if (!$pconfig['interface'])
100
		$pconfig['interface'] = "wan";
101
} else {
102
	$pconfig['interface'] = "wan";
103
	$pconfig['src'] = "any";
104
	$pconfig['srcbeginport'] = "any";
105
	$pconfig['srcendport'] = "any";
106
}
107

    
108
if (isset($_GET['dup']))
109
	unset($id);
110

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

    
122
if ($_POST) {
123

    
124
	if(strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") {
125
		if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
126
			$_POST['srcbeginport'] = trim($_POST['srcbeginport_cust']);
127
		if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
128
			$_POST['srcendport'] = trim($_POST['srcendport_cust']);
129

    
130
		if ($_POST['srcbeginport'] == "any") {
131
			$_POST['srcbeginport'] = 0;
132
			$_POST['srcendport'] = 0;
133
		} else {
134
			if (!$_POST['srcendport'])
135
				$_POST['srcendport'] = $_POST['srcbeginport'];
136
		}
137
		if ($_POST['srcendport'] == "any")
138
			$_POST['srcendport'] = $_POST['srcbeginport'];
139

    
140
		if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
141
			$_POST['dstbeginport'] = trim($_POST['dstbeginport_cust']);
142
		if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
143
			$_POST['dstendport'] = trim($_POST['dstendport_cust']);
144

    
145
		if ($_POST['dstbeginport'] == "any") {
146
			$_POST['dstbeginport'] = 0;
147
			$_POST['dstendport'] = 0;
148
		} else {
149
			if (!$_POST['dstendport'])
150
				$_POST['dstendport'] = $_POST['dstbeginport'];
151
		}
152
		if ($_POST['dstendport'] == "any")
153
			$_POST['dstendport'] = $_POST['dstbeginport'];
154

    
155
		if ($_POST['localbeginport_cust'] && !$_POST['localbeginport'])
156
			$_POST['localbeginport'] = trim($_POST['localbeginport_cust']);
157

    
158
		/* Make beginning port end port if not defined and endport is */
159
		if (!$_POST['srcbeginport'] && $_POST['srcendport'])
160
			$_POST['srcbeginport'] = $_POST['srcendport'];
161
		if (!$_POST['dstbeginport'] && $_POST['dstendport'])
162
			$_POST['dstbeginport'] = $_POST['dstendport'];
163
	} else {
164
		$_POST['srcbeginport'] = 0;
165
		$_POST['srcendport'] = 0;
166
		$_POST['dstbeginport'] = 0;
167
		$_POST['dstendport'] = 0;
168
	}
169

    
170
	if (is_specialnet($_POST['srctype'])) {
171
		$_POST['src'] = $_POST['srctype'];
172
		$_POST['srcmask'] = 0;
173
	} else if ($_POST['srctype'] == "single") {
174
		$_POST['srcmask'] = 32;
175
	}
176
	if (is_specialnet($_POST['dsttype'])) {
177
		$_POST['dst'] = $_POST['dsttype'];
178
		$_POST['dstmask'] = 0;
179
	} else if ($_POST['dsttype'] == "single") {
180
		$_POST['dstmask'] = 32;
181
	} else if (is_ipaddr($_POST['dsttype'])) {
182
		$_POST['dst'] = $_POST['dsttype'];
183
		$_POST['dstmask'] = 32;
184
		$_POST['dsttype'] = "single";
185
	}
186

    
187
	$pconfig = $_POST;
188

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

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

    
211
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
212

    
213
	if (!$_POST['srcbeginport']) {
214
		$_POST['srcbeginport'] = 0;
215
		$_POST['srcendport'] = 0;
216
	}
217
	if (!$_POST['dstbeginport']) {
218
		$_POST['dstbeginport'] = 0;
219
		$_POST['dstendport'] = 0;
220
	}
221

    
222
	if ($_POST['src'])
223
		$_POST['src'] = trim($_POST['src']);
224
	if ($_POST['dst'])
225
		$_POST['dst'] = trim($_POST['dst']);
226
	if ($_POST['localip'])
227
		$_POST['localip'] = trim($_POST['localip']);
228

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

    
233
	if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport']))
234
		$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']);
235
	if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport']))
236
		$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']);
237
	if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport']))
238
		$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']);
239
	if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport']))
240
		$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']);
241

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

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

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

    
269
	if ($_POST['srcbeginport'] > $_POST['srcendport']) {
270
		/* swap */
271
		$tmp = $_POST['srcendport'];
272
		$_POST['srcendport'] = $_POST['srcbeginport'];
273
		$_POST['srcbeginport'] = $tmp;
274
	}
275
	if ($_POST['dstbeginport'] > $_POST['dstendport']) {
276
		/* swap */
277
		$tmp = $_POST['dstendport'];
278
		$_POST['dstendport'] = $_POST['dstbeginport'];
279
		$_POST['dstbeginport'] = $tmp;
280
	}
281

    
282
	if (!$input_errors) {
283
		if (!isset($_POST['nordr']) && ($_POST['dstendport'] - $_POST['dstbeginport'] + $_POST['localbeginport']) > 65535)
284
			$input_errors[] = gettext("The target port range must be an integer between 1 and 65535.");
285
	}
286

    
287
	/* check for overlaps */
288
	foreach ($a_nat as $natent) {
289
		if (isset($id) && ($a_nat[$id]) && ($a_nat[$id] === $natent))
290
			continue;
291
		if ($natent['interface'] != $_POST['interface'])
292
			continue;
293
		if ($natent['destination']['address'] != $_POST['dst'])
294
			continue;
295
		if (($natent['proto'] != $_POST['proto']) && ($natent['proto'] != "tcp/udp") && ($_POST['proto'] != "tcp/udp"))
296
			continue;
297

    
298
		list($begp,$endp) = explode("-", $natent['destination']['port']);
299
		if (!$endp)
300
			$endp = $begp;
301

    
302
		if (!(   (($_POST['beginport'] < $begp) && ($_POST['endport'] < $begp))
303
		      || (($_POST['beginport'] > $endp) && ($_POST['endport'] > $endp)))) {
304

    
305
			$input_errors[] = gettext("The destination port range overlaps with an existing entry.");
306
			break;
307
		}
308
	}
309

    
310
	// Allow extending of the firewall edit page and include custom input validation 
311
	pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/input_validation");
312

    
313
	if (!$input_errors) {
314
		$natent = array();
315

    
316
		$natent['disabled'] = isset($_POST['disabled']) ? true:false;
317
		$natent['nordr'] = isset($_POST['nordr']) ? true:false;
318

    
319
		if ($natent['nordr']) {
320
			$_POST['associated-rule-id'] = '';
321
			$_POST['filter-rule-association'] = '';
322
		}
323

    
324
		pconfig_to_address($natent['source'], $_POST['src'],
325
			$_POST['srcmask'], $_POST['srcnot'],
326
			$_POST['srcbeginport'], $_POST['srcendport']);
327

    
328
		pconfig_to_address($natent['destination'], $_POST['dst'],
329
			$_POST['dstmask'], $_POST['dstnot'],
330
			$_POST['dstbeginport'], $_POST['dstendport']);
331

    
332
		$natent['protocol'] = $_POST['proto'];
333

    
334
		if (!$natent['nordr']) {
335
			$natent['target'] = $_POST['localip'];
336
			$natent['local-port'] = $_POST['localbeginport'];
337
		}
338
		$natent['interface'] = $_POST['interface'];
339
		$natent['descr'] = $_POST['descr'];
340
		$natent['associated-rule-id'] = $_POST['associated-rule-id'];
341

    
342
		if($_POST['filter-rule-association'] == "pass")
343
			$natent['associated-rule-id'] = "pass";
344

    
345
		if($_POST['nosync'] == "yes")
346
			$natent['nosync'] = true;
347
		else
348
			unset($natent['nosync']);
349

    
350
		if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "purenat" || $_POST['natreflection'] == "disable")
351
			$natent['natreflection'] = $_POST['natreflection'];
352
		else
353
			unset($natent['natreflection']);
354

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

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

    
378
		if ($need_filter_rule == true) {
379

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

    
395
			// Update interface, protocol and destination
396
			$filterent['interface'] = $_POST['interface'];
397
			$filterent['protocol'] = $_POST['proto'];
398
			$filterent['destination']['address'] = $_POST['localip'];
399

    
400
			$dstpfrom = $_POST['localbeginport'];
401
			$dstpto = $dstpfrom + $_POST['dstendport'] - $_POST['dstbeginport'];
402

    
403
			if ($dstpfrom == $dstpto)
404
				$filterent['destination']['port'] = $dstpfrom;
405
			else
406
				$filterent['destination']['port'] = $dstpfrom . "-" . $dstpto;
407

    
408
			/*
409
			 * Our firewall filter description may be no longer than
410
			 * 63 characters, so don't let it be.
411
			 */
412
			$filterent['descr'] = substr("NAT " . $_POST['descr'], 0, 62);
413

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

    
421
			mark_subsystem_dirty('filter');
422
		}
423

    
424
		if ( isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']) )
425
			$natent['created'] = $a_nat[$id]['created'];
426

    
427
		$natent['updated'] = make_config_revision_entry();
428

    
429
		// Allow extending of the firewall edit page and include custom input validation 
430
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_write_config");
431

    
432
		// Update the NAT entry now
433
		if (isset($id) && $a_nat[$id])
434
			$a_nat[$id] = $natent;
435
		else {
436
			$natent['created'] = make_config_revision_entry();
437
			if (is_numeric($after))
438
				array_splice($a_nat, $after+1, 0, array($natent));
439
			else
440
				$a_nat[] = $natent;
441
		}
442

    
443
		if (write_config())
444
			mark_subsystem_dirty('natconf');
445

    
446
		header("Location: firewall_nat.php");
447
		exit;
448
	}
449
}
450

    
451
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Port Forward"),gettext("Edit"));
452
include("head.inc");
453

    
454
?>
455
<link rel="stylesheet" href="/javascript/chosen/chosen.css" />
456
</head>
457

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

    
494
						$iflist = get_configured_interface_with_descr(false, true);
495
						// Allow extending of the firewall edit interfaces 
496
						pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/pre_interfaces_edit");
497
						foreach ($iflist as $if => $ifdesc)
498
							if(have_ruleint_access($if))
499
								$interfaces[$if] = $ifdesc;
500

    
501
						if ($config['l2tp']['mode'] == "server")
502
							if(have_ruleint_access("l2tp"))
503
								$interfaces['l2tp'] = "L2TP VPN";
504

    
505
						if ($config['pptpd']['mode'] == "server")
506
							if(have_ruleint_access("pptp"))
507
								$interfaces['pptp'] = "PPTP VPN";
508

    
509
						if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
510
							$interfaces['pppoe'] = "PPPoE VPN";
511

    
512
						/* add ipsec interfaces */
513
						if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable']))
514
							if(have_ruleint_access("enc0"))
515
								$interfaces["enc0"] = "IPsec";
516

    
517
						/* add openvpn/tun interfaces */
518
						if  ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"])
519
							$interfaces["openvpn"] = "OpenVPN";
520

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

    
665
<?php 							foreach ($ifdisp as $if => $ifdesc): ?>
666
								<?php if(have_ruleint_access($if)): ?>
667
									<option value="<?=$if;?>" <?php if ($pconfig['dst'] == $if) { echo "selected"; } ?>><?=htmlspecialchars($ifdesc);?> <?=gettext("subnet"); ?></option>
668
									<option value="<?=$if;?>ip"<?php if ($pconfig['dst'] == $if . "ip") { echo "selected"; } ?>>
669
										<?=$ifdesc;?> <?=gettext("address");?>
670
									</option>
671
								<?php endif; ?>
672
<?php 							endforeach; ?>
673

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

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

    
916
	var oTextbox1 = new AutoSuggestControl(document.getElementById("localip"), new StateSuggestions(addressarray));
917
	var oTextbox2 = new AutoSuggestControl(document.getElementById("src"), new StateSuggestions(addressarray));
918
	var oTextbox3 = new AutoSuggestControl(document.getElementById("dst"), new StateSuggestions(addressarray));
919
	var oTextbox4 = new AutoSuggestControl(document.getElementById("dstbeginport_cust"), new StateSuggestions(customarray));
920
	var oTextbox5 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
921
	var oTextbox6 = new AutoSuggestControl(document.getElementById("srcbeginport_cust"), new StateSuggestions(customarray));
922
	var oTextbox7 = new AutoSuggestControl(document.getElementById("srcendport_cust"), new StateSuggestions(customarray));
923
	var oTextbox8 = new AutoSuggestControl(document.getElementById("localbeginport_cust"), new StateSuggestions(customarray));
924
//]]>
925
</script>
926
<?php include("fend.inc"); ?>
927
</body>
928
</html>
(64-64/246)