// not really much reason to use the while workaround for this with only a single pyramid level

This commit is contained in:
flash 2018-12-26 17:07:14 +01:00
parent 38cb13aefe
commit dcd2830b40

View file

@ -101,38 +101,36 @@ switch ($_GET['v'] ?? null) {
$notices = [];
while (!empty($_POST)) {
if (!empty($_POST)) {
if (!csrf_verify('ip_blacklist', $_POST['csrf'] ?? '')) {
$notices[] = 'Verification failed.';
break;
}
} else {
header(csrf_http_header('ip_blacklist'));
header(csrf_http_header('ip_blacklist'));
if (!empty($_POST['blacklist']['remove']) && is_array($_POST['blacklist']['remove'])) {
foreach ($_POST['blacklist']['remove'] as $cidr) {
if (!ip_blacklist_remove($cidr)) {
$notices[] = sprintf('Failed to remove "%s" from the blacklist.', $cidr);
}
}
}
if (!empty($_POST['blacklist']['remove']) && is_array($_POST['blacklist']['remove'])) {
foreach ($_POST['blacklist']['remove'] as $cidr) {
if (!ip_blacklist_remove($cidr)) {
$notices[] = sprintf('Failed to remove "%s" from the blacklist.', $cidr);
if (!empty($_POST['blacklist']['add']) && is_string($_POST['blacklist']['add'])) {
$cidrs = explode("\n", $_POST['blacklist']['add']);
foreach ($cidrs as $cidr) {
$cidr = trim($cidr);
if (empty($cidr)) {
continue;
}
if (!ip_blacklist_add($cidr)) {
$notices[] = sprintf('Failed to add "%s" to the blacklist.', $cidr);
}
}
}
}
if (!empty($_POST['blacklist']['add']) && is_string($_POST['blacklist']['add'])) {
$cidrs = explode("\n", $_POST['blacklist']['add']);
foreach ($cidrs as $cidr) {
$cidr = trim($cidr);
if (empty($cidr)) {
continue;
}
if (!ip_blacklist_add($cidr)) {
$notices[] = sprintf('Failed to add "%s" to the blacklist.', $cidr);
}
}
}
break;
}
echo tpl_render('manage.general.blacklist', [