Project

General

Profile

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