Project

General

Profile

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