Project

General

Profile

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