Projet

Général

Profil

Télécharger (43,4 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_nat_edit.php @ 62424bdb

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_once("filter.inc");
45
require("shaper.inc");
46

    
47
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/firewall_nat.php');
48

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

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

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

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

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

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

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

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

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

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

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

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

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

    
125
if ($_POST) {
126

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

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

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

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

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

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

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

    
190
	$pconfig = $_POST;
191

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

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

    
214
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
215

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
316
	if (!$input_errors) {
317
		$natent = array();
318

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

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

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

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

    
335
		$natent['protocol'] = $_POST['proto'];
336

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

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

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

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

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

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

    
381
		if ($need_filter_rule == true) {
382

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

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

    
403
			$dstpfrom = $_POST['localbeginport'];
404
			$dstpto = $dstpfrom + $_POST['dstendport'] - $_POST['dstbeginport'];
405

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

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

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

    
424
			mark_subsystem_dirty('filter');
425
		}
426

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

    
430
		$natent['updated'] = make_config_revision_entry();
431

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

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

    
446
		if (write_config())
447
			mark_subsystem_dirty('natconf');
448

    
449
		header("Location: firewall_nat.php");
450
		exit;
451
	}
452
}
453

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

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

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

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

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

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

    
513
						if (is_pppoe_server_enabled() && have_ruleint_access("pppoe"))
514
							$interfaces['pppoe'] = "PPPoE VPN";
515

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

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

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

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

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

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

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