Project

General

Profile

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