2018-03-28 00:35:37 +00:00
|
|
|
<?php
|
2018-10-04 20:30:55 +00:00
|
|
|
require_once '../../misuzu.php';
|
2018-03-28 00:35:37 +00:00
|
|
|
|
2018-10-02 22:34:05 +00:00
|
|
|
$generalPerms = perms_get_user(MSZ_PERMS_GENERAL, user_session_current('user_id', 0));
|
2018-04-26 15:01:59 +00:00
|
|
|
|
2018-04-23 03:00:55 +00:00
|
|
|
switch ($_GET['v'] ?? null) {
|
2018-07-10 01:04:44 +00:00
|
|
|
default:
|
2018-04-23 03:00:55 +00:00
|
|
|
case 'overview':
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('manage.general.overview');
|
2018-04-23 03:00:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'logs':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_VIEW_LOGS)) {
|
2018-07-17 17:17:57 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-03 00:33:02 +00:00
|
|
|
$logsPagination = pagination_create(audit_log_count(), 50);
|
|
|
|
$logsOffset = pagination_offset($logsPagination, pagination_param());
|
|
|
|
|
|
|
|
if (!pagination_is_valid_offset($logsOffset)) {
|
|
|
|
echo render_error(404);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$logs = audit_log_list($logsOffset, $logsPagination['range']);
|
2018-12-15 18:14:23 +00:00
|
|
|
|
|
|
|
echo tpl_render('manage.general.logs', [
|
|
|
|
'global_logs' => $logs,
|
2019-01-03 00:33:02 +00:00
|
|
|
'global_logs_pagination' => $logsPagination,
|
2018-12-15 18:14:23 +00:00
|
|
|
'global_logs_strings' => MSZ_AUDIT_LOG_STRINGS,
|
|
|
|
]);
|
2018-04-23 03:00:55 +00:00
|
|
|
break;
|
|
|
|
|
2018-10-09 22:36:54 +00:00
|
|
|
case 'quotes':
|
2018-12-15 18:14:23 +00:00
|
|
|
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_VIEW_LOGS)) {
|
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-10-09 22:36:54 +00:00
|
|
|
$setId = (int)($_GET['s'] ?? '');
|
|
|
|
$quoteId = (int)($_GET['q'] ?? '');
|
|
|
|
|
|
|
|
if (!empty($_POST['quote']) && csrf_verify('add_quote', $_POST['csrf'] ?? '')) {
|
|
|
|
$quoteTime = strtotime($_POST['quote']['time'] ?? '');
|
|
|
|
$parentId = empty($_POST['quote']['parent']) ? null : (int)($_POST['quote']['parent']);
|
|
|
|
|
|
|
|
$quoteId = chat_quotes_add(
|
|
|
|
$_POST['quote']['text'] ?? null,
|
|
|
|
$_POST['quote']['user']['name'] ?? null,
|
|
|
|
empty($_POST['quote']['user']['colour']) ? MSZ_COLOUR_INHERIT : (int)($_POST['quote']['user']['colour']),
|
|
|
|
empty($_POST['quote']['user']['id']) ? null : (int)($_POST['quote']['user']['id']),
|
|
|
|
empty($_POST['quote']['parent']) || $_POST['quote']['id'] == $parentId ? null : (int)($_POST['quote']['parent']),
|
|
|
|
$quoteTime ? $quoteTime : null,
|
|
|
|
empty($_POST['quote']['id']) ? null : (int)($_POST['quote']['id'])
|
|
|
|
);
|
|
|
|
|
|
|
|
header('Location: ?v=quotes' . ($setId ? '&s=' . $setId : '&q=' . $quoteId));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($quoteId) {
|
|
|
|
tpl_vars([
|
|
|
|
'current_quote' => chat_quotes_single($quoteId),
|
|
|
|
'quote_parent' => $setId,
|
|
|
|
]);
|
|
|
|
} elseif ($setId > 0) {
|
|
|
|
tpl_var('quote_set', chat_quotes_set($setId));
|
|
|
|
}
|
|
|
|
|
2019-01-03 00:33:02 +00:00
|
|
|
$quotesPagination = pagination_create(chat_quotes_count(true), 15);
|
|
|
|
$quotesOffset = pagination_offset($quotesPagination, pagination_param());
|
|
|
|
|
|
|
|
if (!pagination_is_valid_offset($quotesOffset)) {
|
|
|
|
echo render_error(404);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$quotes = chat_quotes_parents($quotesPagination['offset']);
|
2018-10-09 22:36:54 +00:00
|
|
|
|
|
|
|
echo tpl_render('manage.general.quotes', [
|
|
|
|
'quote_parents' => $quotes,
|
2019-01-03 00:33:02 +00:00
|
|
|
'quotes_pagination' => $quotesPagination,
|
2018-10-09 22:36:54 +00:00
|
|
|
]);
|
|
|
|
break;
|
|
|
|
|
2018-04-23 03:00:55 +00:00
|
|
|
case 'emoticons':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) {
|
2018-08-15 20:29:18 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('manage.general.emoticons');
|
2018-04-23 03:00:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'settings':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_SETTINGS)) {
|
2018-08-15 20:29:18 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('manage.general.settings');
|
2018-04-23 03:00:55 +00:00
|
|
|
break;
|
2018-12-26 16:03:26 +00:00
|
|
|
|
|
|
|
case 'blacklist':
|
|
|
|
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_BLACKLIST)) {
|
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$notices = [];
|
|
|
|
|
2018-12-26 16:07:14 +00:00
|
|
|
if (!empty($_POST)) {
|
2018-12-26 16:03:26 +00:00
|
|
|
if (!csrf_verify('ip_blacklist', $_POST['csrf'] ?? '')) {
|
|
|
|
$notices[] = 'Verification failed.';
|
2018-12-26 16:07:14 +00:00
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
}
|
2018-12-26 16:03:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-26 16:07:14 +00:00
|
|
|
if (!empty($_POST['blacklist']['add']) && is_string($_POST['blacklist']['add'])) {
|
|
|
|
$cidrs = explode("\n", $_POST['blacklist']['add']);
|
2018-12-26 16:03:26 +00:00
|
|
|
|
2018-12-26 16:07:14 +00:00
|
|
|
foreach ($cidrs as $cidr) {
|
|
|
|
$cidr = trim($cidr);
|
2018-12-26 16:03:26 +00:00
|
|
|
|
2018-12-26 16:07:14 +00:00
|
|
|
if (empty($cidr)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-12-26 16:03:26 +00:00
|
|
|
|
2018-12-26 16:07:14 +00:00
|
|
|
if (!ip_blacklist_add($cidr)) {
|
|
|
|
$notices[] = sprintf('Failed to add "%s" to the blacklist.', $cidr);
|
|
|
|
}
|
2018-12-26 16:03:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('manage.general.blacklist', [
|
|
|
|
'notices' => $notices,
|
|
|
|
'blacklist' => ip_blacklist_list(),
|
|
|
|
]);
|
|
|
|
break;
|
2018-04-23 03:00:55 +00:00
|
|
|
}
|