2019-06-07 17:33:51 +00:00
|
|
|
<?php
|
|
|
|
require_once '../../../misuzu.php';
|
|
|
|
|
|
|
|
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_GENERAL_MANAGE_BLACKLIST)) {
|
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$notices = [];
|
|
|
|
|
|
|
|
if(!empty($_POST)) {
|
2019-06-10 15:21:53 +00:00
|
|
|
if(!csrf_verify_request()) {
|
2019-06-07 17:33:51 +00:00
|
|
|
$notices[] = 'Verification failed.';
|
|
|
|
} else {
|
2019-06-10 15:21:53 +00:00
|
|
|
csrf_http_header();
|
2019-06-07 17:33:51 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('manage.general.blacklist', [
|
|
|
|
'notices' => $notices,
|
|
|
|
'blacklist' => ip_blacklist_list(),
|
|
|
|
]);
|