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