Project

General

Profile

« Previous | Next » 

Revision 6cb366de

Added by Stephen Beaver over 9 years ago

Double-click to edit, click to select, multi-delete and drag to re-order now supported on:
firewall-nat.php
firewall-nat-out.php
firewall_nat-1to1.php
firewall_rules.php

View differences:

src/usr/local/www/firewall_nat.php
80 80
$a_nat = &$config['nat']['rule'];
81 81

  
82 82
/* update rule order, POST[rule] is an array of ordered IDs */
83
if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
84
	$a_nat_new = array();
83
if($_POST['order-store']) {
84
	if (is_array($_POST['rule']) && !empty($_POST['rule'])) {
85
		$a_nat_new = array();
85 86

  
86
	// if a rule is not in POST[rule], it has been deleted by the user
87
	foreach ($_POST['rule'] as $id)
88
		$a_nat_new[] = $a_nat[$id];
87
		// if a rule is not in POST[rule], it has been deleted by the user
88
		foreach ($_POST['rule'] as $id)
89
			$a_nat_new[] = $a_nat[$id];
89 90

  
90
	$a_nat = $a_nat_new;
91
		$a_nat = $a_nat_new;
91 92

  
92
	if (write_config())
93
		mark_subsystem_dirty('filter');
93
		if (write_config())
94
			mark_subsystem_dirty('filter');
94 95

  
95
	header("Location: firewall_nat.php");
96
	exit;
96
		header("Location: firewall_nat.php");
97
		exit;
98
	}
97 99
}
98 100

  
99 101
/* if a custom message has been passed along, lets process it */
......
102 104
}
103 105

  
104 106
if ($_POST) {
105

  
106 107
	$pconfig = $_POST;
107 108

  
108 109
	if ($_POST['apply']) {
......
154 155

  
155 156
				mark_subsystem_dirty('filter');
156 157
			}
158

  
157 159
			unset($a_nat[$rulei]);
158 160
		}
161

  
159 162
		if (write_config()) {
160 163
			mark_subsystem_dirty('natconf');
161 164
		}
165

  
162 166
		header("Location: firewall_nat.php");
163 167
		exit;
164 168
	}
165

  
166
} else {
167
		/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
168
		unset($movebtn);
169
		foreach ($_POST as $pn => $pd) {
170
			if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
171
				$movebtn = $matches[1];
172
				break;
173
			}
174
		}
175
		/* move selected rules before this rule */
176
		if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
177
			$a_nat_new = array();
178

  
179
			/* copy all rules < $movebtn and not selected */
180
			for ($i = 0; $i < $movebtn; $i++) {
181
				if (!in_array($i, $_POST['rule'])) {
182
					$a_nat_new[] = $a_nat[$i];
183
				}
184
			}
185

  
186
			/* copy all selected rules */
187
			for ($i = 0; $i < count($a_nat); $i++) {
188
				if ($i == $movebtn) {
189
					continue;
190
				}
191
				if (in_array($i, $_POST['rule'])) {
192
					$a_nat_new[] = $a_nat[$i];
193
				}
194
			}
195

  
196
			/* copy $movebtn rule */
197
			if ($movebtn < count($a_nat)) {
198
				$a_nat_new[] = $a_nat[$movebtn];
199
			}
200

  
201
			/* copy all rules > $movebtn and not selected */
202
			for ($i = $movebtn+1; $i < count($a_nat); $i++) {
203
				if (!in_array($i, $_POST['rule'])) {
204
					$a_nat_new[] = $a_nat[$i];
205
				}
206
			}
207
			$a_nat = $a_nat_new;
208
			if (write_config()) {
209
				mark_subsystem_dirty('natconf');
210
			}
211
			header("Location: firewall_nat.php");
212
			exit;
213
		}
214 169
}
215 170

  
216 171
$closehead = false;
......
301 256
						</td>
302 257

  
303 258
						<td>
304
							<input type="hidden" name="rule[]" value="<?=$i?>" />
305 259
							<?=$textss?><?=strtoupper($natent['protocol'])?><?=$textse?>
306 260
						</td>
307 261

  
......
415 369

  
416 370
	<div class="pull-right">
417 371
		<a href="firewall_nat_edit.php?after=-1" class="btn btn-sm btn-success" title="<?=gettext('Add new rule')?>"><?=gettext('Add new rule')?></a>
418
		<input name="del" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>"  />
419
		<input type="submit" id="order-store" class="btn btn-primary btn-sm" value="<?=gettext("Save changes")?>" disabled="disabled" />
372
		<input name="del_x" type="submit" class="btn btn-danger btn-sm" value="<?=gettext("Delete selected rules"); ?>"	 />
373
		<input type="submit" id="order-store" name="order-store" class="btn btn-primary btn-sm" value="<?=gettext("Save changes")?>" disabled="disabled" />
420 374
	</div>
421 375
</form>
422 376

  
......
454 408
			$('#order-store').removeAttr('disabled');
455 409
		}
456 410
	});
411

  
412
	// Check all of the rule checkboxes so that their values are posted
413
	$('#order-store').click(function () {
414
	   $('[id^=frc]').prop('checked', true);
415
	});
457 416
});
458 417
</script>
459 418
<?php

Also available in: Unified diff