Project

General

Profile

« Previous | Next » 

Revision c49db631

Added by Jim Pingle over 10 years ago

Jettison unused dragtable code from firewall_rules.php, it was broken and inactive and only causing trouble.

View differences:

usr/local/www/firewall_rules.php
75 75

  
76 76
$ifdescs = get_configured_interface_with_descr();
77 77

  
78
// Drag and drop reordering
79
if($_REQUEST['dragdroporder']) {
80
	// First create a new ruleset array and tmp arrays
81
	$a_filter_before = array();
82
	$a_filter_order = array();
83
	$a_filter_order_tmp = array();
84
	$a_filter_after = array();
85
	$found = false;
86
	$drag_order = $_REQUEST['dragtable'];
87
	// Next traverse through rules building a new order for interface
88
	for ($i = 0; isset($a_filter[$i]); $i++) {
89
		if(( $_REQUEST['if'] == "FloatingRules" && isset($a_filter[$i]['floating']) ) || ( $a_filter[$i]['interface'] == $_REQUEST['if'] && !isset($a_filter[$i]['floating']) )) {
90
			$a_filter_order_tmp[] = $a_filter[$i];
91
			$found = true;
92
		} else if (!$found)
93
			$a_filter_before[] = $a_filter[$i];
94
		else
95
			$a_filter_after[] = $a_filter[$i];
96
	}
97
	// Reorder rules with the posted order
98
	for ($i = 0; $i<count($drag_order); $i++)
99
		$a_filter_order[] = $a_filter_order_tmp[$drag_order[$i]];
100
	// In case $drag_order didn't account for some rules, make sure we don't lose them
101
	if(count($a_filter_order) < count($a_filter_order_tmp)) {
102
		for ($i = 0; $i<count($a_filter_order_tmp); $i++)
103
			if(!in_array($i, $drag_order))
104
				$a_filter_order[] = $a_filter_order_tmp[$i];
105
	}
106
	// Overwrite filter rules with newly created items
107
	$config['filter']['rule'] = array_merge($a_filter_before, $a_filter_order, $a_filter_after);
108
	// Write configuration
109
	$config = write_config(gettext("Drag and drop firewall rules ordering update."));
110
	// Redirect back to page
111
	mark_subsystem_dirty('filter');
112
	$undo = array();
113
	foreach($_REQUEST['dragtable'] as $dt)
114
		$undo[] = "";
115
	$counter = 0;
116
	foreach($_REQUEST['dragtable'] as $dt) {
117
		$undo[$dt] = $counter;
118
		$counter++;
119
	}
120
	foreach($undo as $dt)
121
		$undotxt .= "&dragtable[]={$dt}";
122
	header("Location: firewall_rules.php?if=" . $_REQUEST['if'] . "&undodrag=true" . $undotxt);
123
	exit;
124
}
125

  
126 78
/* add group interfaces */
127 79
if (is_array($config['ifgroups']['ifgroupentry']))
128 80
	foreach($config['ifgroups']['ifgroupentry'] as $ifgen)
......
285 237
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
286 238
<?php if ($savemsg) print_info_box($savemsg); ?>
287 239
<?php if (is_subsystem_dirty('filter')): ?><p>
288
<?php
289
if($_REQUEST['undodrag']) {
290
	foreach($_REQUEST['dragtable'] as $dt)
291
		$dragtable .= "&dragtable[]={$dt}";
292
	print_info_box_np_undo(gettext("The firewall rule configuration has been changed.<br />You must apply the changes in order for them to take effect."), "apply" , gettext("Apply changes") , "firewall_rules.php?if={$_REQUEST['if']}&dragdroporder=true&{$dragtable}");
293
} else {
294
	print_info_box_np(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."), "apply", "", true);
295
}
296
?>
240
<?php	print_info_box_np(gettext("The firewall rule configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."), "apply", "", true); ?>
297 241
<br />
298 242
<?php endif; ?>
299
<div id="loading" style="visibity:hidden">
300
    <img src="/themes/<?=$g['theme']?>/images/misc/loader.gif" alt="loader" /> <?php echo gettext("Loading, please wait..."); ?>
301
	<p>&nbsp;</p>
302
</div>
303 243
<?php
304 244
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/before_table");
305 245
?>
......
467 407
			</td>
468 408
			</tr>
469 409
<?php endif; ?>
470
			<tbody id="dragtable">
410
			<tbody>
471 411
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++):
472 412
	pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/row_start");
473 413
	$filterent = $a_filter[$i];
......
875 815
	</tr>
876 816
</table>
877 817
<input type="hidden" name="if" value="<?=htmlspecialchars($if);?>" />
878
<script type="text/javascript">
879
//<![CDATA[
880
	var number_of_rules = <?=$nrules?>;
881
	<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++): ?>
882
	/*
883
		Sortable.create("dragtable", {
884
			tag:"tr",
885
			format:"fr([0-9999999])",
886
			containment:["dragtable"],
887
			onChange:function(affected) {
888
				document.body.style.cursor = 'move';
889
			},
890
			onUpdate:function(container) {
891
				document.body.style.cursor = 'move';
892
				updateOrder(Sortable.serialize('dragtable', 'tr'));
893
			}
894
		});
895
	*/
896
	<?php endfor; ?>
897
	function updateOrder(order) {
898
		if(document.getElementById("redboxtable"))
899
			jQuery('#redboxtable').hide();
900
		jQuery('#loading').show();
901
		document.body.style.cursor = 'wait';
902
		document.location = 'firewall_rules.php?if=<?=htmlspecialchars($if);?>&dragdroporder=true&' + Sortable.serialize('dragtable', 'tr');
903
		return;
904
	}
905
	jQuery('#loading').hide();
906
//]]>
907
</script>
908 818
</form>
909 819
<?php include("fend.inc"); ?>
910 820
</body>

Also available in: Unified diff