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