Project

General

Profile

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