Project

General

Profile

« Previous | Next » 

Revision d1fd8c3b

Added by Steve Beaver over 8 years ago

GET/POST conversion firewall_aliases*

View differences:

src/usr/local/www/firewall_aliases.php
42 42

  
43 43
$tab = ($_REQUEST['tab'] == "" ? "ip" : preg_replace("/\W/", "", $_REQUEST['tab']));
44 44

  
45
if ($_POST) {
46

  
47
	if ($_POST['apply']) {
48
		$retval = 0;
45
if ($_POST['apply']) {
46
	$retval = 0;
49 47

  
50
		/* reload all components that use aliases */
51
		$retval |= filter_configure();
48
	/* reload all components that use aliases */
49
	$retval |= filter_configure();
52 50

  
53
		if ($retval == 0) {
54
			clear_subsystem_dirty('aliases');
55
		}
51
	if ($retval == 0) {
52
		clear_subsystem_dirty('aliases');
56 53
	}
57 54
}
58 55

  
59
if ($_GET['act'] == "del") {
60
	if ($a_aliases[$_GET['id']]) {
56

  
57
if ($_POST['act'] == "del") {
58
	if ($a_aliases[$_POST['id']]) {
61 59
		/* make sure rule is not being referenced by any nat or filter rules */
62 60
		$is_alias_referenced = false;
63 61
		$referenced_by = false;
64
		$alias_name = $a_aliases[$_GET['id']]['name'];
62
		$alias_name = $a_aliases[$_POST['id']]['name'];
65 63
		// Firewall rules
66 64
		find_alias_reference(array('filter', 'rule'), array('source', 'address'), $alias_name, $is_alias_referenced, $referenced_by);
67 65
		find_alias_reference(array('filter', 'rule'), array('destination', 'address'), $alias_name, $is_alias_referenced, $referenced_by);
......
94 92
		if ($is_alias_referenced == true) {
95 93
			$delete_error = sprintf(gettext("Cannot delete alias. Currently in use by %s."), htmlspecialchars($referenced_by));
96 94
		} else {
97
			if (preg_match("/urltable/i", $a_aliases[$_GET['id']]['type'])) {
95
			if (preg_match("/urltable/i", $a_aliases[$_POST['id']]['type'])) {
98 96
				// this is a URL table type alias, delete its file as well
99
				unlink_if_exists("/var/db/aliastables/" . $a_aliases[$_GET['id']]['name'] . ".txt");
97
				unlink_if_exists("/var/db/aliastables/" . $a_aliases[$_POST['id']]['name'] . ".txt");
100 98
			}
101
			unset($a_aliases[$_GET['id']]);
99
			unset($a_aliases[$_POST['id']]);
102 100
			if (write_config()) {
103 101
				filter_configure();
104 102
				mark_subsystem_dirty('aliases');
......
254 252
				<?=htmlspecialchars($alias['descr'])?>&nbsp;
255 253
			</td>
256 254
			<td>
257
				<a class="fa fa-pencil" title="<?=gettext("Edit alias"); ?>" href="firewall_aliases_edit.php?id=<?=$i?>"></a>
258
				<a class="fa fa-trash"	title="<?=gettext("Delete alias")?>" href="?act=del&amp;tab=<?=$tab?>&amp;id=<?=$i?>"></a>
255
				<a class="fa fa-pencil" title="<?=gettext("Edit alias"); ?>" href="firewall_aliases_edit.php?id=<?=$i?>" usepost></a>
256
				<a class="fa fa-trash"	title="<?=gettext("Delete alias")?>" href="?act=del&amp;tab=<?=$tab?>&amp;id=<?=$i?>" usepost></a>
259 257
			</td>
260 258
		</tr>
261 259
<?php endif?>
......
268 266
</div>
269 267

  
270 268
<nav class="action-buttons">
271
	<a href="firewall_aliases_edit.php?tab=<?=$tab?>" role="button" class="btn btn-success btn-sm">
269
	<a href="firewall_aliases_edit.php?tab=<?=$tab?>" role="button" class="btn btn-success btn-sm" usepost>
272 270
		<i class="fa fa-plus icon-embed-btn"></i>
273 271
		<?=gettext("Add");?>
274 272
	</a>
275 273
<?php
276 274
if (($tab == "ip") || ($tab == "port") || ($tab == "all")):
277 275
?>
278
	<a href="firewall_aliases_import.php?tab=<?=$tab?>" role="button" class="btn btn-primary btn-sm">
276
	<a href="firewall_aliases_import.php?tab=<?=$tab?>" role="button" class="btn btn-primary btn-sm" usepost>
279 277
		<i class="fa fa-upload icon-embed-btn"></i>
280 278
		<?=gettext("Import");?>
281 279
	</a>
src/usr/local/www/firewall_aliases_edit.php
60 60
}
61 61
$a_aliases = &$config['aliases']['alias'];
62 62

  
63
if ($_POST) {
63
if ($_POST['save']) {
64 64
	$origname = $_POST['origname'];
65 65
}
66 66

  
......
99 99
	return true;
100 100
}
101 101

  
102
if (is_numericint($_GET['id'])) {
103
	$id = $_GET['id'];
104
}
105 102
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
106 103
	$id = $_POST['id'];
107 104
}
......
142 139
$pgtitle = array(gettext("Firewall"), gettext("Aliases"), gettext("Edit"));
143 140
$pglinks = array("", "firewall_aliases.php?tab=" . $tab, "@self");
144 141

  
145
if ($_POST) {
142
if ($_POST['save']) {
146 143

  
147 144
	unset($input_errors);
148 145
	$vertical_bar_err_text = gettext("Vertical bars (|) at start or end, or double in the middle of descriptions not allowed. Descriptions have been cleaned. Check and save again.");
src/usr/local/www/firewall_aliases_import.php
231 231
		'import separated by a carriage return. Common examples are lists of IPs, ' .
232 232
		'networks, blacklists, etc. The list may contain IP addresses, with or without ' .
233 233
		'CIDR prefix, IP ranges, blank lines (ignored) and an optional description after ' .
234
		'each IP. e.g.:') . 
234
		'each IP. e.g.:') .
235 235
		'</span><ul><li>' .
236 236
		'172.16.1.2' .
237 237
		'</li><li>' .

Also available in: Unified diff