Project

General

Profile

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