Project

General

Profile

Download (16.1 KB) Statistics
| Branch: | Tag: | Revision:
1 340e6dca Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3
	firewall_nat.php
4
*/
5 fd9ebcd5 Stephen Beaver
/* ====================================================================
6 7c540a5c Stephen Beaver
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 9da2cf1c Stephen Beaver
 *
8 cb41dd63 Renato Botelho
 *	Some or all of this file is based on the m0n0wall project which is
9
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10 fd9ebcd5 Stephen Beaver
 *
11 7c540a5c Stephen Beaver
 *	Redistribution and use in source and binary forms, with or without modification,
12
 *	are permitted provided that the following conditions are met:
13 fd9ebcd5 Stephen Beaver
 *
14 7c540a5c Stephen Beaver
 *	1. Redistributions of source code must retain the above copyright notice,
15
 *		this list of conditions and the following disclaimer.
16 fd9ebcd5 Stephen Beaver
 *
17 7c540a5c Stephen Beaver
 *	2. Redistributions in binary form must reproduce the above copyright
18
 *		notice, this list of conditions and the following disclaimer in
19
 *		the documentation and/or other materials provided with the
20
 *		distribution.
21 fd9ebcd5 Stephen Beaver
 *
22 7c540a5c Stephen Beaver
 *	3. All advertising materials mentioning features or use of this software
23
 *		must display the following acknowledgment:
24
 *		"This product includes software developed by the pfSense Project
25
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
26 fd9ebcd5 Stephen Beaver
 *
27 7c540a5c Stephen Beaver
 *	4. The names "pfSense" and "pfSense Project" must not be used to
28
 *		 endorse or promote products derived from this software without
29
 *		 prior written permission. For written permission, please contact
30
 *		 coreteam@pfsense.org.
31 fd9ebcd5 Stephen Beaver
 *
32 7c540a5c Stephen Beaver
 *	5. Products derived from this software may not be called "pfSense"
33
 *		nor may "pfSense" appear in their names without prior written
34
 *		permission of the Electric Sheep Fencing, LLC.
35 fd9ebcd5 Stephen Beaver
 *
36 7c540a5c Stephen Beaver
 *	6. Redistributions of any form whatsoever must retain the following
37
 *		acknowledgment:
38 fd9ebcd5 Stephen Beaver
 *
39 7c540a5c Stephen Beaver
 *	"This product includes software developed by the pfSense Project
40
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
41 919d91f9 Phil Davis
 *
42 7c540a5c Stephen Beaver
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
54 fd9ebcd5 Stephen Beaver
 *
55 7c540a5c Stephen Beaver
 *	====================================================================
56 fd9ebcd5 Stephen Beaver
 *
57
 */
58 5b237745 Scott Ullrich
59 6b07c15a Matthew Grooms
##|+PRIV
60
##|*IDENT=page-firewall-nat-portforward
61 5230f468 jim-p
##|*NAME=Firewall: NAT: Port Forward
62 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Firewall: NAT: Port Forward' page.
63
##|*MATCH=firewall_nat.php*
64
##|-PRIV
65
66 5b237745 Scott Ullrich
require("guiconfig.inc");
67 7a927e67 Scott Ullrich
require_once("functions.inc");
68
require_once("filter.inc");
69
require_once("shaper.inc");
70 483e6de8 Scott Ullrich
require_once("itemid.inc");
71 5b237745 Scott Ullrich
72 37ba954d Phil Davis
if (!is_array($config['nat']['rule'])) {
73 5b237745 Scott Ullrich
	$config['nat']['rule'] = array();
74 37ba954d Phil Davis
}
75 fbe94068 Scott Ullrich
76 5b237745 Scott Ullrich
$a_nat = &$config['nat']['rule'];
77
78 8bbab8a3 Stephen Beaver
/* update rule order, POST[rule] is an array of ordered IDs */
79 67c2baf1 Phil Davis
if (array_key_exists('order-store', $_POST)) {
80 6cb366de Stephen Beaver
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
81
		$a_nat_new = array();
82 8bbab8a3 Stephen Beaver
83 6cb366de Stephen Beaver
		// if a rule is not in POST[rule], it has been deleted by the user
84 67c2baf1 Phil Davis
		foreach ($_POST['rule'] as $id) {
85 6cb366de Stephen Beaver
			$a_nat_new[] = $a_nat[$id];
86 67c2baf1 Phil Davis
		}
87 8bbab8a3 Stephen Beaver
88 6cb366de Stephen Beaver
		$a_nat = $a_nat_new;
89 dbbd22f9 Stephen Beaver
90 7d8552fc Stephen Beaver
91
		$config['nat']['separator'] = "";
92
93
		if ($_POST['separator']) {
94
			$idx = 0;
95
			foreach ($_POST['separator'] as $separator) {
96
				$config['nat']['separator']['sep' . $idx++] = $separator;
97
			}
98
		}
99
100 67c2baf1 Phil Davis
		if (write_config()) {
101 6cb366de Stephen Beaver
			mark_subsystem_dirty('filter');
102 67c2baf1 Phil Davis
		}
103 dbbd22f9 Stephen Beaver
104 6cb366de Stephen Beaver
		header("Location: firewall_nat.php");
105
		exit;
106
	}
107 8bbab8a3 Stephen Beaver
}
108
109 514dbaf8 Scott Ullrich
/* if a custom message has been passed along, lets process it */
110 37ba954d Phil Davis
if ($_GET['savemsg']) {
111 514dbaf8 Scott Ullrich
	$savemsg = $_GET['savemsg'];
112 37ba954d Phil Davis
}
113 514dbaf8 Scott Ullrich
114 5b237745 Scott Ullrich
if ($_POST) {
115
	$pconfig = $_POST;
116
117
	if ($_POST['apply']) {
118 e8c2c890 Bill Marquette
119 5b237745 Scott Ullrich
		$retval = 0;
120 7a6c350f Scott Ullrich
121 e2c9ef13 Scott Ullrich
		$retval |= filter_configure();
122 05da8941 Erik Fonnesbeck
		$savemsg = get_std_save_message($retval);
123 7d04082e Scott Ullrich
124 1a700ea6 Scott Ullrich
		pfSense_handle_custom_code("/usr/local/pkg/firewall_nat/apply");
125
126 5b237745 Scott Ullrich
		if ($retval == 0) {
127 a368a026 Ermal Lu?i
			clear_subsystem_dirty('natconf');
128
			clear_subsystem_dirty('filter');
129 5b237745 Scott Ullrich
		}
130 7d04082e Scott Ullrich
131 5b237745 Scott Ullrich
	}
132
}
133
134 759d0de1 Renato Botelho
if ($_GET['act'] == "del") {
135
	if ($a_nat[$_GET['id']]) {
136 3a343d73 jim-p
137 759d0de1 Renato Botelho
		if (isset($a_nat[$_GET['id']]['associated-rule-id'])) {
138
			delete_id($a_nat[$_GET['id']]['associated-rule-id'], $config['filter']['rule']);
139 3a343d73 jim-p
			$want_dirty_filter = true;
140 759d0de1 Renato Botelho
		}
141
		unset($a_nat[$_GET['id']]);
142 3a343d73 jim-p
143 7d8552fc Stephen Beaver
		// Update the separators
144
		$a_separators = &$config['nat']['separator'];
145 a4f41878 NOYB
		$ridx = $_GET['id'];
146
		$mvnrows = -1;
147
		move_separators($a_separators, $ridx, $mvnrows);
148 7d8552fc Stephen Beaver
149 3a343d73 jim-p
		if (write_config()) {
150
			mark_subsystem_dirty('natconf');
151 37ba954d Phil Davis
			if ($want_dirty_filter) {
152 3a343d73 jim-p
				mark_subsystem_dirty('filter');
153 37ba954d Phil Davis
			}
154 3a343d73 jim-p
		}
155 0e6ac11d Stephen Beaver
156 759d0de1 Renato Botelho
		header("Location: firewall_nat.php");
157
		exit;
158
	}
159
}
160
161 00bcbdd0 Bill Marquette
if (isset($_POST['del_x'])) {
162 0e6ac11d Stephen Beaver
	/* delete selected rules */
163
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
164 7d8552fc Stephen Beaver
		$a_separators = &$config['nat']['separator'];
165
166 0e6ac11d Stephen Beaver
		foreach ($_POST['rule'] as $rulei) {
167 7d8552fc Stephen Beaver
			$target = $rule['target'];
168
169 b9e28d57 unknown
			// Check for filter rule associations
170 6c07db48 Phil Davis
			if (isset($a_nat[$rulei]['associated-rule-id'])) {
171 9b16b834 Ermal Lu?i
				delete_id($a_nat[$rulei]['associated-rule-id'], $config['filter']['rule']);
172 7d5b007c Sjon Hortensius
173 b9e28d57 unknown
				mark_subsystem_dirty('filter');
174
			}
175 6cb366de Stephen Beaver
176 0e6ac11d Stephen Beaver
			unset($a_nat[$rulei]);
177 7d8552fc Stephen Beaver
178
			// Update the separators
179 a4f41878 NOYB
			$ridx = $rulei;
180
			$mvnrows = -1;
181
			move_separators($a_separators, $ridx, $mvnrows);
182 0e6ac11d Stephen Beaver
		}
183 6cb366de Stephen Beaver
184 37ba954d Phil Davis
		if (write_config()) {
185 3a343d73 jim-p
			mark_subsystem_dirty('natconf');
186 37ba954d Phil Davis
		}
187 6cb366de Stephen Beaver
188 cd567545 Phil Davis
		header("Location: firewall_nat.php");
189
		exit;
190
	}
191
} else if ($_GET['act'] == "toggle") {
192
	if ($a_nat[$_GET['id']]) {
193
		if (isset($a_nat[$_GET['id']]['disabled'])) {
194
			unset($a_nat[$_GET['id']]['disabled']);
195
		} else {
196
			$a_nat[$_GET['id']]['disabled'] = true;
197
		}
198
		if (write_config(gettext("Firewall: NAT: Port forward, enable/disable NAT rule"))) {
199
			mark_subsystem_dirty('natconf');
200
		}
201 3a343d73 jim-p
		header("Location: firewall_nat.php");
202
		exit;
203 4b9a670c Scott Ullrich
	}
204 0e6ac11d Stephen Beaver
}
205
206 6c07db48 Phil Davis
$pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Port Forward"));
207 6eb17647 Scott Ullrich
include("head.inc");
208
209 67c2baf1 Phil Davis
if ($savemsg) {
210 0e6ac11d Stephen Beaver
	print_info_box($savemsg, 'success');
211 67c2baf1 Phil Davis
}
212 0e6ac11d Stephen Beaver
213 67c2baf1 Phil Davis
if (is_subsystem_dirty('natconf')) {
214 3b3a95e5 Phil Davis
	print_apply_box(gettext('The NAT configuration has been changed.') . '<br />' .
215 358b2884 Stephen Beaver
					gettext('The changes must be applied for them to take effect.'));
216 67c2baf1 Phil Davis
}
217 2a9db752 Scott Dale
218 0e6ac11d Stephen Beaver
$tab_array = array();
219
$tab_array[] = array(gettext("Port Forward"), true, "firewall_nat.php");
220
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
221
$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
222
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
223
display_top_tabs($tab_array);
224 7d8552fc Stephen Beaver
225
$columns_in_table = 13;
226 24f600b0 Scott Ullrich
?>
227 d16a49ae Colin Fleming
228 00bcbdd0 Bill Marquette
<form action="firewall_nat.php" method="post" name="iform">
229 8bbab8a3 Stephen Beaver
	<div class="panel panel-default">
230 95fa5cce Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Rules')?></h2></div>
231 8bbab8a3 Stephen Beaver
		<div class="panel-body table-responsive">
232 7d8552fc Stephen Beaver
			<table id="ruletable" class="table table-striped table-hover table-condensed">
233 8bbab8a3 Stephen Beaver
				<thead>
234
					<tr>
235 7c540a5c Stephen Beaver
						<th><!-- Checkbox --></th>
236 cd567545 Phil Davis
						<th><!-- Icon --></th>
237 8bbab8a3 Stephen Beaver
						<th><!-- Rule type --></th>
238 5b8a7e90 NewEraCracker
						<th><?=gettext("Interface")?></th>
239 66c62a1a NewEraCracker
						<th><?=gettext("Protocol")?></th>
240 a66ce627 NewEraCracker
						<th><?=gettext("Source Address")?></th>
241
						<th><?=gettext("Source Ports")?></th>
242
						<th><?=gettext("Dest. Address")?></th>
243
						<th><?=gettext("Dest. Ports")?></th>
244 8bbab8a3 Stephen Beaver
						<th><?=gettext("NAT IP")?></th>
245
						<th><?=gettext("NAT Ports")?></th>
246
						<th><?=gettext("Description")?></th>
247
						<th><?=gettext("Actions")?></th>
248
					</tr>
249
				</thead>
250
				<tbody class='user-entries'>
251 0e6ac11d Stephen Beaver
<?php
252 dbbd22f9 Stephen Beaver
253 0e6ac11d Stephen Beaver
$nnats = $i = 0;
254 ccc62f13 NOYB
$separators = $config['nat']['separator'];
255 0e6ac11d Stephen Beaver
256 36bf13fd NOYB
// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s).
257
// More efficient than looping through the list of separators on every row.
258
$seprows = separator_rows($separators);
259 7d8552fc Stephen Beaver
260 0e6ac11d Stephen Beaver
foreach ($a_nat as $natent):
261
262 36bf13fd NOYB
	// Display separator(s) for section beginning at rule n
263
	if ($seprows[$nnats]) {
264
		display_separator($separators, $nnats, $columns_in_table);
265
	}
266
267 60ebb473 Stephen Beaver
	$localport = $natent['local-port'];
268
269
	list($dstbeginport, $dstendport) = explode("-", $natent['destination']['port']);
270
271
	if ($dstendport) {
272
		$localendport = $natent['local-port'] + $dstendport - $dstbeginport;
273
		$localport	 .= '-' . $localendport;
274
	}
275
276 dbbd22f9 Stephen Beaver
	$alias = rule_columns_with_alias(
277
		$natent['source']['address'],
278
		pprint_port($natent['source']['port']),
279
		$natent['destination']['address'],
280 60ebb473 Stephen Beaver
		pprint_port($natent['destination']['port']),
281
		$natent['target'],
282
		$localport
283 dbbd22f9 Stephen Beaver
	);
284 0e6ac11d Stephen Beaver
285 dbbd22f9 Stephen Beaver
	/* if user does not have access to edit an interface skip on to the next record */
286 67c2baf1 Phil Davis
	if (!have_natpfruleint_access($natent['interface'])) {
287 dbbd22f9 Stephen Beaver
		continue;
288 67c2baf1 Phil Davis
	}
289 cd567545 Phil Davis
290
	if (isset($natent['disabled'])) {
291
		$iconfn = "pass_d";
292
		$trclass = 'class="disabled"';
293
	} else {
294
		$iconfn = "pass";
295
		$trclass = '';
296
	}
297 0e6ac11d Stephen Beaver
?>
298 7c540a5c Stephen Beaver
299 cd567545 Phil Davis
					<tr id="fr<?=$nnats;?>" <?=$trclass?> onClick="fr_toggle(<?=$nnats;?>)" ondblclick="document.location='firewall_nat_edit.php?id=<?=$i;?>';">
300 7c540a5c Stephen Beaver
						<td >
301
							<input type="checkbox" id="frc<?=$nnats;?>" onClick="fr_toggle(<?=$nnats;?>)" name="rule[]" value="<?=$i;?>"/>
302
						</td>
303 8bbab8a3 Stephen Beaver
						<td>
304 cd567545 Phil Davis
							<a href="?act=toggle&amp;id=<?=$i?>">
305
								<i class="fa <?= ($iconfn == "pass") ? "fa-check":"fa-times"?>" title="<?=gettext("click to toggle enabled/disabled status")?>"></i>
306 719635b2 jim-p
<?php 	if (isset($natent['nordr'])) { ?>
307
								&nbsp;<i class="fa fa-hand-stop-o text-danger" title="<?=gettext("Negated: This rule excludes NAT from a later rule")?>"></i>
308
<?php 	} ?>
309 cd567545 Phil Davis
							</a>
310
						</td>
311
						<td>
312 0e6ac11d Stephen Beaver
<?php
313 e6f34d22 Phil Davis
	if ($natent['associated-rule-id'] == "pass"):
314 0e6ac11d Stephen Beaver
?>
315 1b7379f9 Jared Dillard
							<i class="fa fa-play" title="<?=gettext("All traffic matching this NAT entry is passed")?>"></i>
316 a8726a3d Scott Ullrich
<?php
317 dbbd22f9 Stephen Beaver
	elseif (!empty($natent['associated-rule-id'])):
318 a8726a3d Scott Ullrich
?>
319 7d95365e Phil Davis
							<i class="fa fa-random" title="<?=sprintf(gettext("Firewall rule ID %s is managed by this rule"), htmlspecialchars($natent['associated-rule-id']))?>"></i>
320 0e6ac11d Stephen Beaver
<?php
321 dbbd22f9 Stephen Beaver
	endif;
322 0e6ac11d Stephen Beaver
?>
323 8bbab8a3 Stephen Beaver
						</td>
324 91d452c7 Stephen Beaver
						<td>
325 8bbab8a3 Stephen Beaver
							<?=$textss?>
326 0e6ac11d Stephen Beaver
<?php
327 67c2baf1 Phil Davis
	if (!$natent['interface']) {
328 dbbd22f9 Stephen Beaver
		echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
329 67c2baf1 Phil Davis
	} else {
330 dbbd22f9 Stephen Beaver
		echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
331 67c2baf1 Phil Davis
	}
332 0e6ac11d Stephen Beaver
?>
333 8bbab8a3 Stephen Beaver
							<?=$textse?>
334
						</td>
335 dbbd22f9 Stephen Beaver
336 91d452c7 Stephen Beaver
						<td>
337 8bbab8a3 Stephen Beaver
							<?=$textss?><?=strtoupper($natent['protocol'])?><?=$textse?>
338
						</td>
339 dbbd22f9 Stephen Beaver
340 91d452c7 Stephen Beaver
						<td>
341 dbbd22f9 Stephen Beaver
342
343
<?php
344
	if (isset($alias['src'])):
345
?>
346 7d95365e Phil Davis
							<a href="/firewall_aliases_edit.php?id=<?=$alias['src']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['src'])?>" data-html="true">
347 dbbd22f9 Stephen Beaver
<?php
348
	endif;
349
?>
350 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars(pprint_address($natent['source'])))?>
351 dbbd22f9 Stephen Beaver
<?php
352
	if (isset($alias['src'])):
353
?>
354 9b4d9cd8 NOYB
							</a>
355 dbbd22f9 Stephen Beaver
<?php
356
	endif;
357
?>
358 8bbab8a3 Stephen Beaver
						</td>
359 91d452c7 Stephen Beaver
						<td>
360 dbbd22f9 Stephen Beaver
<?php
361
	if (isset($alias['srcport'])):
362
?>
363 7d95365e Phil Davis
							<a href="/firewall_aliases_edit.php?id=<?=$alias['srcport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['srcport'])?>" data-html="true">
364 dbbd22f9 Stephen Beaver
<?php
365
	endif;
366
?>
367 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars(pprint_port($natent['source']['port'])))?>
368 dbbd22f9 Stephen Beaver
<?php
369
	if (isset($alias['srcport'])):
370
?>
371 9b4d9cd8 NOYB
							</a>
372 dbbd22f9 Stephen Beaver
<?php
373
	endif;
374
?>
375 8bbab8a3 Stephen Beaver
						</td>
376 dbbd22f9 Stephen Beaver
377 91d452c7 Stephen Beaver
						<td>
378 dbbd22f9 Stephen Beaver
<?php
379
	if (isset($alias['dst'])):
380
?>
381 7d95365e Phil Davis
							<a href="/firewall_aliases_edit.php?id=<?=$alias['dst']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dst'])?>" data-html="true">
382 dbbd22f9 Stephen Beaver
<?php
383
	endif;
384
?>
385 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars(pprint_address($natent['destination'])))?>
386 dbbd22f9 Stephen Beaver
<?php
387
	if (isset($alias['dst'])):
388
?>
389 1b056591 NOYB
							</a>
390 dbbd22f9 Stephen Beaver
<?php
391
	endif;
392
?>
393 8bbab8a3 Stephen Beaver
						</td>
394 91d452c7 Stephen Beaver
						<td>
395 dbbd22f9 Stephen Beaver
<?php
396
	if (isset($alias['dstport'])):
397
?>
398 7d95365e Phil Davis
							<a href="/firewall_aliases_edit.php?id=<?=$alias['dstport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['dstport'])?>" data-html="true">
399 dbbd22f9 Stephen Beaver
<?php
400
	endif;
401
?>
402 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars(pprint_port($natent['destination']['port'])))?>
403 dbbd22f9 Stephen Beaver
<?php
404
	if (isset($alias['dstport'])):
405
?>
406 1b056591 NOYB
							</a>
407 dbbd22f9 Stephen Beaver
<?php
408
	endif;
409
?>
410 8bbab8a3 Stephen Beaver
						</td>
411 60ebb473 Stephen Beaver
						<td>
412
<?php
413
	if (isset($alias['target'])):
414
?>
415
							<a href="/firewall_aliases_edit.php?id=<?=$alias['target']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['target'])?>" data-html="true">
416
<?php
417
	endif;
418
?>
419 dbbd22f9 Stephen Beaver
420 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars($natent['target']))?>
421 60ebb473 Stephen Beaver
<?php
422
	if (isset($alias['target'])):
423
?>
424
							</a>
425
<?php
426
	endif;
427
?>
428 8bbab8a3 Stephen Beaver
						</td>
429 91d452c7 Stephen Beaver
						<td>
430 0e6ac11d Stephen Beaver
<?php
431 60ebb473 Stephen Beaver
	if (isset($alias['targetport'])):
432
?>
433
							<a href="/firewall_aliases_edit.php?id=<?=$alias['targetport']?>" data-toggle="popover" data-trigger="hover focus" title="<?=gettext('Alias details')?>" data-content="<?=alias_info_popup($alias['targetport'])?>" data-html="true">
434
<?php
435
	endif;
436 0e6ac11d Stephen Beaver
?>
437 faa020a3 NOYB
							<?=str_replace('_', ' ', htmlspecialchars(pprint_port($localport)))?>
438 60ebb473 Stephen Beaver
<?php
439
	if (isset($alias['targetport'])):
440
?>
441
							</a>
442
<?php
443
	endif;
444
?>
445 8bbab8a3 Stephen Beaver
						</td>
446 dbbd22f9 Stephen Beaver
447 91d452c7 Stephen Beaver
						<td>
448 dbbd22f9 Stephen Beaver
							<?=htmlspecialchars($natent['descr'])?>
449 8bbab8a3 Stephen Beaver
						</td>
450 91d452c7 Stephen Beaver
						<td>
451 65a0e193 Stephen Beaver
							<a class="fa fa-pencil" title="<?=gettext("Edit rule"); ?>" href="firewall_nat_edit.php?id=<?=$i?>"></a>
452
							<a class="fa fa-clone"	  title="<?=gettext("Add a new NAT based on this one")?>" href="firewall_nat_edit.php?dup=<?=$i?>"></a>
453 314e439e Stephen Beaver
							<a class="fa fa-trash"	title="<?=gettext("Delete rule")?>" href="firewall_nat.php?act=del&amp;id=<?=$i?>"></a>
454 8bbab8a3 Stephen Beaver
						</td>
455
					</tr>
456 0e6ac11d Stephen Beaver
<?php
457
	$i++;
458
	$nnats++;
459 8f561183 NOYB
460 0e6ac11d Stephen Beaver
endforeach;
461 36bf13fd NOYB
462
// There can be separator(s) after the last rule listed.
463
if ($seprows[$nnats]) {
464
	display_separator($separators, $nnats, $columns_in_table);
465
}
466 0e6ac11d Stephen Beaver
?>
467 8bbab8a3 Stephen Beaver
				</tbody>
468
			</table>
469
		</div>
470 4cf530c4 Stephen Beaver
	</div>
471 dbbd22f9 Stephen Beaver
472 c10cb196 Stephen Beaver
	<nav class="action-buttons">
473 b807e59c Stephen Beaver
		<a href="firewall_nat_edit.php?after=-1" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the top of the list')?>">
474
			<i class="fa fa-level-up icon-embed-btn"></i>
475 0149ef4d Stephen Beaver
			<?=gettext('Add')?>
476
		</a>
477 b807e59c Stephen Beaver
		<a href="firewall_nat_edit.php" class="btn btn-sm btn-success" title="<?=gettext('Add rule to the end of the list')?>">
478
			<i class="fa fa-level-down icon-embed-btn"></i>
479
			<?=gettext('Add')?>
480
		</a>
481
		<button name="del_x" type="submit" class="btn btn-danger btn-sm" title="<?=gettext('Delete selected rules')?>">
482 9d5a20cf heper
			<i class="fa fa-trash icon-embed-btn"></i>
483 0149ef4d Stephen Beaver
			<?=gettext("Delete"); ?>
484
		</button>
485 c4b60a9a Colin Fleming
		<button type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" disabled title="<?=gettext('Save rule order')?>">
486 9d5a20cf heper
			<i class="fa fa-save icon-embed-btn"></i>
487 0149ef4d Stephen Beaver
			<?=gettext("Save")?>
488
		</button>
489 7d8552fc Stephen Beaver
		<button type="submit" id="addsep" name="addsep" class="btn btn-sm btn-warning" title="<?=gettext('Add separator')?>">
490
			<i class="fa fa-plus icon-embed-btn"></i>
491
			<?=gettext("Separator")?>
492
		</button>
493 09415b9e Stephen Beaver
	</nav>
494 0e6ac11d Stephen Beaver
</form>
495 3d335c4d Scott Ullrich
496 8fd9052f Colin Fleming
<script type="text/javascript">
497
//<![CDATA[
498 2af731f8 NewEraCracker
//Need to create some variables here so that jquery/pfSenseHelpers.js can read them
499 7d8552fc Stephen Beaver
iface = "<?=strtolower($if)?>";
500
cncltxt = '<?=gettext("Cancel")?>';
501
svtxt = '<?=gettext("Save")?>';
502
svbtnplaceholder = '<?=gettext("Enter a description, Save, then drag to final location.")?>';
503
configsection = "nat";
504
dirty = false;
505
506 65a0e193 Stephen Beaver
events.push(function() {
507 7c540a5c Stephen Beaver
508 65a0e193 Stephen Beaver
	// Make rules sortable
509 4cf530c4 Stephen Beaver
	$('table tbody.user-entries').sortable({
510
		cursor: 'grabbing',
511
		update: function(event, ui) {
512
			$('#order-store').removeAttr('disabled');
513 ae6814a2 Phil Davis
			dirty = true;
514 7d8552fc Stephen Beaver
			reindex_rules(ui.item.parent('tbody'));
515
			dirty = true;
516 4cf530c4 Stephen Beaver
		}
517
	});
518 6cb366de Stephen Beaver
519
	// Check all of the rule checkboxes so that their values are posted
520
	$('#order-store').click(function () {
521
	   $('[id^=frc]').prop('checked', true);
522 ae6814a2 Phil Davis
523 7d8552fc Stephen Beaver
		// Save the separator bar configuration
524
		save_separators();
525
526 ae6814a2 Phil Davis
		// Suppress the "Do you really want to leave the page" message
527
		saving = true;
528 7d8552fc Stephen Beaver
529 ae6814a2 Phil Davis
	});
530
531
	// Globals
532
	saving = false;
533
	dirty = false;
534
535
	// provide a warning message if the user tries to change page before saving
536
	$(window).bind('beforeunload', function(){
537
		if (!saving && dirty) {
538 358b2884 Stephen Beaver
			return ("<?=gettext('One or more Port Forward rules have been moved but have not yet been saved')?>");
539 ae6814a2 Phil Davis
		} else {
540
			return undefined;
541
		}
542 6cb366de Stephen Beaver
	});
543 4cf530c4 Stephen Beaver
});
544 8fd9052f Colin Fleming
//]]>
545 4cf530c4 Stephen Beaver
</script>
546 3d335c4d Scott Ullrich
<?php
547 0e6ac11d Stephen Beaver
548 e6f34d22 Phil Davis
if (count($a_nat) > 0) {
549 3d335c4d Scott Ullrich
?>
550 0e6ac11d Stephen Beaver
<!-- Legend -->
551
<div>
552
	<dl class="dl-horizontal responsive">
553
		<dt><?=gettext('Legend')?></dt>					<dd></dd>
554 1b7379f9 Jared Dillard
		<dt><i class="fa fa-play"></i></dt>			<dd><?=gettext('Pass')?></dd>
555
		<dt><i class="fa fa-random"></i></dt>		<dd><?=gettext('Linked rule')?></dd>
556 0e6ac11d Stephen Beaver
	</dl>
557
</div>
558 3d335c4d Scott Ullrich
559 0e6ac11d Stephen Beaver
<?php
560
}
561
562 c10cb196 Stephen Beaver
include("foot.inc");