Beginning work on splitting up manage into multiple files.

This commit is contained in:
flash 2019-06-07 19:33:51 +02:00
parent 0f0c975209
commit 2a7b1680ad
15 changed files with 426 additions and 417 deletions

View file

@ -1,35 +0,0 @@
<?php
require_once '../../misuzu.php';
switch ($_GET['v'] ?? null) {
case 'listing':
$forums = db_query('SELECT * FROM `msz_forum_categories`');
$rawPerms = perms_create(MSZ_FORUM_PERM_MODES);
$perms = manage_forum_perms_list($rawPerms);
if (!empty($_POST['perms']) && is_array($_POST['perms'])) {
$finalPerms = manage_perms_apply($perms, $_POST['perms'], $rawPerms);
$perms = manage_forum_perms_list($finalPerms);
tpl_var('calculated_perms', $finalPerms);
}
echo tpl_render('manage.forum.listing', compact('forums', 'perms'));
break;
case 'forum':
$getForum = db_prepare('
SELECT *
FROM `msz_forum_categories`
WHERE `forum_id` = :forum_id
');
$getForum->bindValue('forum_id', (int)($_GET['f'] ?? 0));
$forum = db_fetch($getForum);
if (!$forum) {
echo render_error(404);
break;
}
echo tpl_render('manage.forum.forum', compact('forum'));
break;
}

View file

@ -0,0 +1,22 @@
<?php
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_FORUM_MANAGE_FORUMS)) {
echo render_error(403);
return;
}
$getForum = db_prepare('
SELECT *
FROM `msz_forum_categories`
WHERE `forum_id` = :forum_id
');
$getForum->bindValue('forum_id', (int)($_GET['f'] ?? 0));
$forum = db_fetch($getForum);
if(!$forum) {
echo render_error(404);
return;
}
echo tpl_render('manage.forum.forum', compact('forum'));

View file

@ -0,0 +1,19 @@
<?php
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_FORUM_MANAGE_FORUMS)) {
echo render_error(403);
return;
}
$forums = db_query('SELECT * FROM `msz_forum_categories`');
$rawPerms = perms_create(MSZ_FORUM_PERM_MODES);
$perms = manage_forum_perms_list($rawPerms);
if(!empty($_POST['perms']) && is_array($_POST['perms'])) {
$finalPerms = manage_perms_apply($perms, $_POST['perms'], $rawPerms);
$perms = manage_forum_perms_list($finalPerms);
tpl_var('calculated_perms', $finalPerms);
}
echo tpl_render('manage.forum.listing', compact('forums', 'perms'));

View file

@ -0,0 +1,46 @@
<?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)) {
if(!csrf_verify('ip_blacklist', $_POST['csrf'] ?? '')) {
$notices[] = 'Verification failed.';
} 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);
}
}
}
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(),
]);

View file

@ -0,0 +1,9 @@
<?php
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) {
echo render_error(403);
return;
}
echo tpl_render('manage.general.emoticons');

View file

@ -0,0 +1,180 @@
<?php
require_once '../../../misuzu.php';
$statistics = db_fetch(db_query('
SELECT
(
SELECT COUNT(`user_id`)
FROM `msz_users`
) AS `stat_users_total`,
(
SELECT COUNT(`user_id`)
FROM `msz_users`
WHERE `user_deleted` IS NOT NULL
) AS `stat_users_deleted`,
(
SELECT COUNT(`user_id`)
FROM `msz_users`
WHERE `user_active` IS NOT NULL
AND `user_deleted` IS NULL
) AS `stat_users_active`,
(
SELECT COUNT(`log_id`)
FROM `msz_audit_log`
) AS `stat_audit_logs`,
(
SELECT COUNT(`change_id`)
FROM `msz_changelog_changes`
) AS `stat_changelog_entries`,
(
SELECT COUNT(`category_id`)
FROM `msz_comments_categories`
) AS `stat_comment_categories_total`,
(
SELECT COUNT(`category_id`)
FROM `msz_comments_categories`
WHERE `category_locked` IS NOT NULL
) AS `stat_comment_categories_locked`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
) AS `stat_comment_posts_total`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_deleted` IS NOT NULL
) AS `stat_comment_posts_deleted`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_reply_to` IS NOT NULL
) AS `stat_comment_posts_replies`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_pinned` IS NOT NULL
) AS `stat_comment_posts_pinned`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_edited` IS NOT NULL
) AS `stat_comment_posts_edited`,
(
SELECT COUNT(`user_id`)
FROM `msz_comments_votes`
WHERE `comment_vote` > 0
) AS `stat_comment_likes`,
(
SELECT COUNT(`user_id`)
FROM `msz_comments_votes`
WHERE `comment_vote` < 0
) AS `stat_comment_dislikes`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
) AS `stat_forum_posts_total`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_deleted` IS NOT NULL
) AS `stat_forum_posts_deleted`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_edited` IS NOT NULL
) AS `stat_forum_posts_edited`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 0
) AS `stat_forum_posts_plain`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 1
) AS `stat_forum_posts_bbcode`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 2
) AS `stat_forum_posts_markdown`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_display_signature` != 0
) AS `stat_forum_posts_signature`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
) AS `stat_forum_topics_total`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 0
) AS `stat_forum_topics_normal`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 1
) AS `stat_forum_topics_pinned`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 2
) AS `stat_forum_topics_announce`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 3
) AS `stat_forum_topics_global_announce`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_deleted` IS NOT NULL
) AS `stat_forum_topics_deleted`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_locked` IS NOT NULL
) AS `stat_forum_topics_locked`,
(
SELECT COUNT(*)
FROM `msz_ip_blacklist`
) AS `stat_blacklist`,
(
SELECT COUNT(`attempt_id`)
FROM `msz_login_attempts`
) AS `stat_login_attempts_total`,
(
SELECT COUNT(`attempt_id`)
FROM `msz_login_attempts`
WHERE `attempt_success` = 0
) AS `stat_login_attempts_failed`,
(
SELECT COUNT(`session_id`)
FROM `msz_sessions`
) AS `stat_user_sessions`,
(
SELECT COUNT(`user_id`)
FROM `msz_users_password_resets`
) AS `stat_user_password_resets`,
(
SELECT COUNT(`user_id`)
FROM `msz_user_relations`
) AS `stat_user_relations`,
(
SELECT COUNT(`warning_id`)
FROM `msz_user_warnings`
WHERE `warning_type` != 0
) AS `stat_user_warnings`
'));
if(!empty($_GET['poll'])) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode($statistics);
return;
}
echo tpl_render('manage.general.overview', [
'statistics' => $statistics,
]);

View file

@ -0,0 +1,23 @@
<?php
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_GENERAL_VIEW_LOGS)) {
echo render_error(403);
return;
}
$logsPagination = pagination_create(audit_log_count(), 50);
$logsOffset = pagination_offset($logsPagination, pagination_param());
if (!pagination_is_valid_offset($logsOffset)) {
echo render_error(404);
return;
}
$logs = audit_log_list($logsOffset, $logsPagination['range']);
echo tpl_render('manage.general.logs', [
'global_logs' => $logs,
'global_logs_pagination' => $logsPagination,
'global_logs_strings' => MSZ_AUDIT_LOG_STRINGS,
]);

View file

@ -0,0 +1,9 @@
<?php
require_once '../../../misuzu.php';
if(!perms_check_user(MSZ_PERMS_GENERAL, user_session_current('user_id'), MSZ_PERM_GENERAL_MANAGE_SETTINGS)) {
echo render_error(403);
return;
}
echo tpl_render('manage.general.settings');

View file

@ -1,274 +1,4 @@
<?php
require_once '../../misuzu.php';
$generalPerms = perms_get_user(user_session_current('user_id', 0))[MSZ_PERMS_GENERAL];
switch ($_GET['v'] ?? null) {
default:
case 'overview':
$statistics = db_fetch(db_query('
SELECT
(
SELECT COUNT(`user_id`)
FROM `msz_users`
) AS `stat_users_total`,
(
SELECT COUNT(`user_id`)
FROM `msz_users`
WHERE `user_deleted` IS NOT NULL
) AS `stat_users_deleted`,
(
SELECT COUNT(`user_id`)
FROM `msz_users`
WHERE `user_active` IS NOT NULL
AND `user_deleted` IS NULL
) AS `stat_users_active`,
(
SELECT COUNT(`log_id`)
FROM `msz_audit_log`
) AS `stat_audit_logs`,
(
SELECT COUNT(`change_id`)
FROM `msz_changelog_changes`
) AS `stat_changelog_entries`,
(
SELECT COUNT(`category_id`)
FROM `msz_comments_categories`
) AS `stat_comment_categories_total`,
(
SELECT COUNT(`category_id`)
FROM `msz_comments_categories`
WHERE `category_locked` IS NOT NULL
) AS `stat_comment_categories_locked`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
) AS `stat_comment_posts_total`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_deleted` IS NOT NULL
) AS `stat_comment_posts_deleted`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_reply_to` IS NOT NULL
) AS `stat_comment_posts_replies`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_pinned` IS NOT NULL
) AS `stat_comment_posts_pinned`,
(
SELECT COUNT(`comment_id`)
FROM `msz_comments_posts`
WHERE `comment_edited` IS NOT NULL
) AS `stat_comment_posts_edited`,
(
SELECT COUNT(`user_id`)
FROM `msz_comments_votes`
WHERE `comment_vote` > 0
) AS `stat_comment_likes`,
(
SELECT COUNT(`user_id`)
FROM `msz_comments_votes`
WHERE `comment_vote` < 0
) AS `stat_comment_dislikes`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
) AS `stat_forum_posts_total`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_deleted` IS NOT NULL
) AS `stat_forum_posts_deleted`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_edited` IS NOT NULL
) AS `stat_forum_posts_edited`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 0
) AS `stat_forum_posts_plain`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 1
) AS `stat_forum_posts_bbcode`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_parse` = 2
) AS `stat_forum_posts_markdown`,
(
SELECT COUNT(`post_id`)
FROM `msz_forum_posts`
WHERE `post_display_signature` != 0
) AS `stat_forum_posts_signature`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
) AS `stat_forum_topics_total`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 0
) AS `stat_forum_topics_normal`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 1
) AS `stat_forum_topics_pinned`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 2
) AS `stat_forum_topics_announce`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_type` = 3
) AS `stat_forum_topics_global_announce`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_deleted` IS NOT NULL
) AS `stat_forum_topics_deleted`,
(
SELECT COUNT(`topic_id`)
FROM `msz_forum_topics`
WHERE `topic_locked` IS NOT NULL
) AS `stat_forum_topics_locked`,
(
SELECT COUNT(*)
FROM `msz_ip_blacklist`
) AS `stat_blacklist`,
(
SELECT COUNT(`attempt_id`)
FROM `msz_login_attempts`
) AS `stat_login_attempts_total`,
(
SELECT COUNT(`attempt_id`)
FROM `msz_login_attempts`
WHERE `attempt_success` = 0
) AS `stat_login_attempts_failed`,
(
SELECT COUNT(`session_id`)
FROM `msz_sessions`
) AS `stat_user_sessions`,
(
SELECT COUNT(`user_id`)
FROM `msz_users_password_resets`
) AS `stat_user_password_resets`,
(
SELECT COUNT(`user_id`)
FROM `msz_user_relations`
) AS `stat_user_relations`,
(
SELECT COUNT(`warning_id`)
FROM `msz_user_warnings`
WHERE `warning_type` != 0
) AS `stat_user_warnings`
'));
if (!empty($_GET['poll'])) {
header('Content-Type: application/json; charset=utf-8');
echo json_encode($statistics);
return;
}
echo tpl_render('manage.general.overview', [
'statistics' => $statistics,
]);
break;
case 'logs':
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_VIEW_LOGS)) {
echo render_error(403);
break;
}
$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']);
echo tpl_render('manage.general.logs', [
'global_logs' => $logs,
'global_logs_pagination' => $logsPagination,
'global_logs_strings' => MSZ_AUDIT_LOG_STRINGS,
]);
break;
case 'emoticons':
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) {
echo render_error(403);
break;
}
echo tpl_render('manage.general.emoticons');
break;
case 'settings':
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_SETTINGS)) {
echo render_error(403);
break;
}
echo tpl_render('manage.general.settings');
break;
case 'blacklist':
if (!perms_check($generalPerms, MSZ_PERM_GENERAL_MANAGE_BLACKLIST)) {
echo render_error(403);
break;
}
$notices = [];
if (!empty($_POST)) {
if (!csrf_verify('ip_blacklist', $_POST['csrf'] ?? '')) {
$notices[] = 'Verification failed.';
} 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);
}
}
}
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(),
]);
break;
}
header('Location: ' . url('manage-general-overview'));

View file

@ -3,66 +3,66 @@ function manage_get_menu(int $userId): array
{
$perms = perms_get_user($userId);
if (!perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_CAN_MANAGE)) {
if(!perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_CAN_MANAGE)) {
return [];
}
$menu = [];
$menu['General']['Overview'] = '/manage/index.php?v=overview';
$menu['General']['Overview'] = url('manage-general-overview');
if (perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_VIEW_LOGS)) {
$menu['General']['Logs'] = '/manage/index.php?v=logs';
if(perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_VIEW_LOGS)) {
$menu['General']['Logs'] = url('manage-general-logs');
}
if (perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) {
$menu['General']['Emoticons'] = '/manage/index.php?v=emoticons';
if(perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_EMOTICONS)) {
$menu['General']['Emoticons'] = url('manage-general-emoticons');
}
if (perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_SETTINGS)) {
$menu['General']['Settings'] = '/manage/index.php?v=settings';
if(perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_SETTINGS)) {
$menu['General']['Settings'] = url('manage-general-settings');
}
if (perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_BLACKLIST)) {
$menu['General']['IP Blacklist'] = '/manage/index.php?v=blacklist';
if(perms_check($perms[MSZ_PERMS_GENERAL], MSZ_PERM_GENERAL_MANAGE_BLACKLIST)) {
$menu['General']['IP Blacklist'] = url('manage-general-blacklist');
}
if (perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_USERS | MSZ_PERM_USER_MANAGE_PERMS)) {
if(perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_USERS | MSZ_PERM_USER_MANAGE_PERMS)) {
$menu['Users']['Listing'] = '/manage/users.php?v=listing';
}
if (perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_ROLES | MSZ_PERM_USER_MANAGE_PERMS)) {
if(perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_ROLES | MSZ_PERM_USER_MANAGE_PERMS)) {
$menu['Users']['Roles'] = '/manage/users.php?v=roles';
}
if (perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_REPORTS)) {
if(perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_REPORTS)) {
$menu['Users']['Reports'] = '/manage/users.php?v=reports';
}
if (perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_WARNINGS)) {
if(perms_check($perms[MSZ_PERMS_USER], MSZ_PERM_USER_MANAGE_WARNINGS)) {
$menu['Users']['Warnings'] = '/manage/users.php?v=warnings';
}
if (perms_check($perms[MSZ_PERMS_NEWS], MSZ_PERM_NEWS_MANAGE_POSTS)) {
if(perms_check($perms[MSZ_PERMS_NEWS], MSZ_PERM_NEWS_MANAGE_POSTS)) {
$menu['News']['Posts'] = '/manage/news.php?v=posts';
}
if (perms_check($perms[MSZ_PERMS_NEWS], MSZ_PERM_NEWS_MANAGE_CATEGORIES)) {
if(perms_check($perms[MSZ_PERMS_NEWS], MSZ_PERM_NEWS_MANAGE_CATEGORIES)) {
$menu['News']['Categories'] = '/manage/news.php?v=categories';
}
if (perms_check($perms[MSZ_PERMS_FORUM], MSZ_PERM_FORUM_MANAGE_FORUMS)) {
$menu['Forum']['Listing'] = '/manage/forum.php?v=listing';
if(perms_check($perms[MSZ_PERMS_FORUM], MSZ_PERM_FORUM_MANAGE_FORUMS)) {
$menu['Forum']['Categories'] = url('manage-forum-categories');
}
if (perms_check($perms[MSZ_PERMS_FORUM], 0)) {
if(perms_check($perms[MSZ_PERMS_FORUM], 0)) {
$menu['Forum']['Settings'] = '/manage/forum.php?v=settings';
}
if (perms_check($perms[MSZ_PERMS_CHANGELOG], MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
if(perms_check($perms[MSZ_PERMS_CHANGELOG], MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
$menu['Changelog']['Changes'] = '/manage/changelog.php?v=changes';
}
if (perms_check($perms[MSZ_PERMS_CHANGELOG], MSZ_PERM_CHANGELOG_MANAGE_TAGS)) {
if(perms_check($perms[MSZ_PERMS_CHANGELOG], MSZ_PERM_CHANGELOG_MANAGE_TAGS)) {
$menu['Changelog']['Tags'] = '/manage/changelog.php?v=tags';
}
@ -75,11 +75,11 @@ define('MSZ_MANAGE_PERM_NEVER', 'never');
function manage_perms_value(int $perm, int $allow, int $deny): string
{
if (perms_check($deny, $perm)) {
if(perms_check($deny, $perm)) {
return MSZ_MANAGE_PERM_NEVER;
}
if (perms_check($allow, $perm)) {
if(perms_check($allow, $perm)) {
return MSZ_MANAGE_PERM_YES;
}
@ -90,8 +90,8 @@ function manage_perms_apply(array $list, array $post, ?array $raw = null): ?arra
{
$perms = $raw !== null ? $raw : perms_create();
foreach ($list as $section) {
if (empty($post[$section['section']])
foreach($list as $section) {
if(empty($post[$section['section']])
|| !is_array($post[$section['section']])) {
continue;
}
@ -99,12 +99,12 @@ function manage_perms_apply(array $list, array $post, ?array $raw = null): ?arra
$allowKey = perms_get_key($section['section'], MSZ_PERMS_ALLOW);
$denyKey = perms_get_key($section['section'], MSZ_PERMS_DENY);
foreach ($section['perms'] as $perm) {
if (empty($post[$section['section']][$perm['section']]['value'])) {
foreach($section['perms'] as $perm) {
if(empty($post[$section['section']][$perm['section']]['value'])) {
continue;
}
switch ($post[$section['section']][$perm['section']]['value']) {
switch($post[$section['section']][$perm['section']]['value']) {
case MSZ_MANAGE_PERM_YES:
$perms[$allowKey] |= $perm['perm'];
$perms[$denyKey] &= ~$perm['perm'];
@ -126,11 +126,11 @@ function manage_perms_apply(array $list, array $post, ?array $raw = null): ?arra
$returnNothing = 0;
foreach ($perms as $perm) {
foreach($perms as $perm) {
$returnNothing |= $perm;
}
if ($returnNothing === 0) {
if($returnNothing === 0) {
return null;
}
@ -139,12 +139,12 @@ function manage_perms_apply(array $list, array $post, ?array $raw = null): ?arra
function manage_perms_calculate(array $rawPerms, array $perms): array
{
for ($i = 0; $i < count($perms); $i++) {
for($i = 0; $i < count($perms); $i++) {
$section = $perms[$i]['section'];
$allowKey = perms_get_key($section, MSZ_PERMS_ALLOW);
$denyKey = perms_get_key($section, MSZ_PERMS_DENY);
for ($j = 0; $j < count($perms[$i]['perms']); $j++) {
for($j = 0; $j < count($perms[$i]['perms']); $j++) {
$permission = $perms[$i]['perms'][$j]['perm'];
$perms[$i]['perms'][$j]['value'] = manage_perms_value($permission, $rawPerms[$allowKey], $rawPerms[$denyKey]);
}

View file

@ -13,107 +13,113 @@ define('MSZ_URLS', [
'media-proxy' => ['/proxy.php/<hash>/<url>'],
'search-index' => ['/search.php'],
'search-query' => ['/search.php', ['q' => '<query>']],
'search-query' => ['/search.php', ['q' => '<query>']],
'auth-login' => ['/auth/login.php', ['username' => '<username>', 'redirect' => '<redirect>']],
'auth-login-welcome' => ['/auth/login.php', ['welcome' => '1', 'username' => '<username>']],
'auth-login' => ['/auth/login.php', ['username' => '<username>', 'redirect' => '<redirect>']],
'auth-login-welcome' => ['/auth/login.php', ['welcome' => '1', 'username' => '<username>']],
'auth-register' => ['/auth/register.php'],
'auth-forgot' => ['/auth/password.php'],
'auth-reset' => ['/auth/password.php', ['user' => '<user>']],
'auth-logout' => ['/auth/logout.php', ['token' => '{logout}']],
'auth-resolve-user' => ['/auth/login.php', ['resolve_user' => '<username>']],
'auth-two-factor' => ['/auth/twofactor.php', ['token' => '<token>']],
'auth-reset' => ['/auth/password.php', ['user' => '<user>']],
'auth-logout' => ['/auth/logout.php', ['token' => '{logout}']],
'auth-resolve-user' => ['/auth/login.php', ['resolve_user' => '<username>']],
'auth-two-factor' => ['/auth/twofactor.php', ['token' => '<token>']],
'changelog-index' => ['/changelog.php'],
'changelog-change' => ['/changelog.php', ['c' => '<change>']],
'changelog-date' => ['/changelog.php', ['d' => '<date>']],
'changelog-tag' => ['/changelog.php', ['t' => '<tag>']],
'changelog-change' => ['/changelog.php', ['c' => '<change>']],
'changelog-date' => ['/changelog.php', ['d' => '<date>']],
'changelog-tag' => ['/changelog.php', ['t' => '<tag>']],
'news-index' => ['/news', ['page' => '<page>']],
'news-post' => ['/news/post.php', ['p' => '<post>']],
'news-post-comments' => ['/news/post.php', ['p' => '<post>'], 'comments'],
'news-category' => ['/news/category.php', ['c' => '<category>', 'p' => '<page>']],
'news-index' => ['/news', ['page' => '<page>']],
'news-post' => ['/news/post.php', ['p' => '<post>']],
'news-post-comments' => ['/news/post.php', ['p' => '<post>'], 'comments'],
'news-category' => ['/news/category.php', ['c' => '<category>', 'p' => '<page>']],
'news-feed-rss' => ['/news/feed.php/rss'],
'news-category-feed-rss' => ['/news/feed.php/rss', ['c' => '<category>']],
'news-category-feed-rss' => ['/news/feed.php/rss', ['c' => '<category>']],
'news-feed-atom' => ['/news/feed.php/atom'],
'news-category-feed-atom' => ['/news/feed.php/atom', ['c' => '<category>']],
'news-category-feed-atom' => ['/news/feed.php/atom', ['c' => '<category>']],
'forum-index' => ['/forum'],
'forum-leaderboard' => ['/forum/leaderboard.php', ['id' => '<id>', 'mode' => '<mode>']],
'forum-mark-global' => ['/forum/index.php', ['m' => 'mark', 'c' => '{forum_mark}']],
'forum-mark-single' => ['/forum/index.php', ['m' => 'mark', 'c' => '{forum_mark}', 'f' => '<forum>']],
'forum-topic-new' => ['/forum/posting.php', ['f' => '<forum>']],
'forum-reply-new' => ['/forum/posting.php', ['t' => '<topic>']],
'forum-category' => ['/forum/forum.php', ['f' => '<forum>', 'p' => '<page>']],
'forum-topic' => ['/forum/topic.php', ['t' => '<topic>', 'page' => '<page>']],
'forum-topic-create' => ['/forum/posting.php', ['f' => '<forum>']],
'forum-topic-bump' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'bump', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-lock' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'lock', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-unlock' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'unlock', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-delete' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'delete', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-restore' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'restore', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-nuke' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'nuke', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-priority' => ['/forum/topic-priority.php', ['t' => '<topic>', 'b' => '<bump>']],
'forum-post' => ['/forum/topic.php', ['p' => '<post>'], '<post_fragment>'],
'forum-post-create' => ['/forum/posting.php', ['t' => '<topic>']],
'forum-post-delete' => ['/forum/post.php', ['p' => '<post>', 'm' => 'delete']],
'forum-post-restore' => ['/forum/post.php', ['p' => '<post>', 'm' => 'restore']],
'forum-post-nuke' => ['/forum/post.php', ['p' => '<post>', 'm' => 'nuke']],
'forum-post-quote' => ['/forum/posting.php', ['q' => '<post>']],
'forum-post-edit' => ['/forum/posting.php', ['p' => '<post>', 'm' => 'edit']],
'forum-leaderboard' => ['/forum/leaderboard.php', ['id' => '<id>', 'mode' => '<mode>']],
'forum-mark-global' => ['/forum/index.php', ['m' => 'mark', 'c' => '{forum_mark}']],
'forum-mark-single' => ['/forum/index.php', ['m' => 'mark', 'c' => '{forum_mark}', 'f' => '<forum>']],
'forum-topic-new' => ['/forum/posting.php', ['f' => '<forum>']],
'forum-reply-new' => ['/forum/posting.php', ['t' => '<topic>']],
'forum-category' => ['/forum/forum.php', ['f' => '<forum>', 'p' => '<page>']],
'forum-topic' => ['/forum/topic.php', ['t' => '<topic>', 'page' => '<page>']],
'forum-topic-create' => ['/forum/posting.php', ['f' => '<forum>']],
'forum-topic-bump' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'bump', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-lock' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'lock', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-unlock' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'unlock', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-delete' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'delete', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-restore' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'restore', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-nuke' => ['/forum/topic.php', ['t' => '<topic>', 'm' => 'nuke', 'csrf[forum_post]' => '{forum_post}']],
'forum-topic-priority' => ['/forum/topic-priority.php', ['t' => '<topic>', 'b' => '<bump>']],
'forum-post' => ['/forum/topic.php', ['p' => '<post>'], '<post_fragment>'],
'forum-post-create' => ['/forum/posting.php', ['t' => '<topic>']],
'forum-post-delete' => ['/forum/post.php', ['p' => '<post>', 'm' => 'delete']],
'forum-post-restore' => ['/forum/post.php', ['p' => '<post>', 'm' => 'restore']],
'forum-post-nuke' => ['/forum/post.php', ['p' => '<post>', 'm' => 'nuke']],
'forum-post-quote' => ['/forum/posting.php', ['q' => '<post>']],
'forum-post-edit' => ['/forum/posting.php', ['p' => '<post>', 'm' => 'edit']],
'forum-poll-vote' => ['/forum/poll.php'],
'user-list' => ['/members.php', ['r' => '<role>', 'ss' => '<sort>', 'sd' => '<direction>', 'p' => '<page>']],
'user-list' => ['/members.php', ['r' => '<role>', 'ss' => '<sort>', 'sd' => '<direction>', 'p' => '<page>']],
'user-profile' => ['/profile.php', ['u' => '<user>']],
'user-profile-following' => ['/profile.php', ['u' => '<user>', 'm' => 'following']],
'user-profile-followers' => ['/profile.php', ['u' => '<user>', 'm' => 'followers']],
'user-profile-forum-topics' => ['/profile.php', ['u' => '<user>', 'm' => 'forum-topics']],
'user-profile-forum-posts' => ['/profile.php', ['u' => '<user>', 'm' => 'forum-posts']],
'user-profile-edit' => ['/profile.php', ['u' => '<user>', 'edit' => '1']],
'user-account-standing' => ['/profile.php', ['u' => '<user>'], 'account-standing'],
'user-profile' => ['/profile.php', ['u' => '<user>']],
'user-profile-following' => ['/profile.php', ['u' => '<user>', 'm' => 'following']],
'user-profile-followers' => ['/profile.php', ['u' => '<user>', 'm' => 'followers']],
'user-profile-forum-topics' => ['/profile.php', ['u' => '<user>', 'm' => 'forum-topics']],
'user-profile-forum-posts' => ['/profile.php', ['u' => '<user>', 'm' => 'forum-posts']],
'user-profile-edit' => ['/profile.php', ['u' => '<user>', 'edit' => '1']],
'user-account-standing' => ['/profile.php', ['u' => '<user>'], 'account-standing'],
'user-avatar' => ['/user-assets.php', ['u' => '<user>', 'm' => 'avatar', 'r' => '<res>']],
'user-background' => ['/user-assets.php', ['u' => '<user>', 'm' => 'background']],
'user-avatar' => ['/user-assets.php', ['u' => '<user>', 'm' => 'avatar', 'r' => '<res>']],
'user-background' => ['/user-assets.php', ['u' => '<user>', 'm' => 'background']],
'user-relation-create' => ['/relations.php', ['u' => '<user>', 'm' => '<type>', 'c' => '{user_relation}']],
'user-relation-none' => ['/relations.php', ['u' => '<user>', 'm' => '[MSZ_USER_RELATION_NONE]', 'c' => '{user_relation}']],
'user-relation-follow' => ['/relations.php', ['u' => '<user>', 'm' => '[MSZ_USER_RELATION_FOLLOW]', 'c' => '{user_relation}']],
'user-relation-create' => ['/relations.php', ['u' => '<user>', 'm' => '<type>', 'c' => '{user_relation}']],
'user-relation-none' => ['/relations.php', ['u' => '<user>', 'm' => '[MSZ_USER_RELATION_NONE]', 'c' => '{user_relation}']],
'user-relation-follow' => ['/relations.php', ['u' => '<user>', 'm' => '[MSZ_USER_RELATION_FOLLOW]', 'c' => '{user_relation}']],
'settings-index' => ['/settings'],
'settings-account' => ['/settings/account.php'],
'settings-sessions' => ['/settings/sessions.php'],
'settings-logs' => ['/settings/logs.php'],
'comment-create' => ['/comments.php', ['m' => 'create']],
'comment-vote' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'vote', 'v' => '<vote>']],
'comment-delete' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'delete']],
'comment-restore' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'restore']],
'comment-pin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'pin']],
'comment-unpin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'unpin']],
'comment-create' => ['/comments.php', ['m' => 'create']],
'comment-vote' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'vote', 'v' => '<vote>']],
'comment-delete' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'delete']],
'comment-restore' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'restore']],
'comment-pin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'pin']],
'comment-unpin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'unpin']],
'manage-changelog-tag-create' => ['/manage/changelog.php', ['v' => 'tag']],
'manage-changelog-tag-edit' => ['/manage/changelog.php', ['v' => 'tag', 't' => '<tag>']],
'manage-changelog-action-create' => ['/manage/changelog.php', ['v' => 'action']],
'manage-changelog-action-edit' => ['/manage/changelog.php', ['v' => 'action', 'a' => '<action>']],
'manage-changelog-change-create' => ['/manage/changelog.php', ['v' => 'change']],
'manage-changelog-change-edit' => ['/manage/changelog.php', ['v' => 'change', 'c' => '<change>']],
'manage-index' => ['/manage'],
'manage-general-overview' => ['/manage/general/index.php'],
'manage-general-logs' => ['/manage/general/logs.php'],
'manage-general-emoticons' => ['/manage/general/emoticons.php'],
'manage-general-settings' => ['/manage/general/settings.php'],
'manage-general-blacklist' => ['/manage/general/blacklist.php'],
'manage-forum-category-view' => ['/manage/forum.php', ['v' => 'forum', 'f' => '<forum>']],
'manage-forum-categories' => ['/manage/forum/index.php'],
'manage-forum-category' => ['/manage/forum/category.php', ['f' => '<forum>']],
'manage-news-category-create' => ['/manage/news.php', ['v' => 'category']],
'manage-news-category-edit' => ['/manage/news.php', ['v' => 'category', 'c' => '<category>']],
'manage-news-post-create' => ['/manage/news.php', ['v' => 'post']],
'manage-news-post-edit' => ['/manage/news.php', ['v' => 'post', 'p' => '<post>']],
'manage-changelog-tag-create' => ['/manage/changelog.php', ['v' => 'tag']],
'manage-changelog-tag-edit' => ['/manage/changelog.php', ['v' => 'tag', 't' => '<tag>']],
'manage-changelog-change-create' => ['/manage/changelog.php', ['v' => 'change']],
'manage-changelog-change-edit' => ['/manage/changelog.php', ['v' => 'change', 'c' => '<change>']],
'manage-user-index' => ['/manage/users.php', ['v' => 'listing']],
'manage-user-edit' => ['/manage/users.php', ['v' => 'view', 'u' => '<user>']],
'manage-news-category-create' => ['/manage/news.php', ['v' => 'category']],
'manage-news-category-edit' => ['/manage/news.php', ['v' => 'category', 'c' => '<category>']],
'manage-news-post-create' => ['/manage/news.php', ['v' => 'post']],
'manage-news-post-edit' => ['/manage/news.php', ['v' => 'post', 'p' => '<post>']],
'manage-role-index' => ['/manage/users.php', ['v' => 'roles']],
'manage-role-create' => ['/manage/users.php', ['v' => 'role']],
'manage-role-edit' => ['/manage/users.php', ['v' => 'role', 'r' => '<role>']],
'manage-user-index' => ['/manage/users.php', ['v' => 'listing']],
'manage-user-edit' => ['/manage/users.php', ['v' => 'view', 'u' => '<user>']],
'manage-warning-delete' => ['/manage/users.php', ['v' => 'warnings', 'u' => '<user>', 'w' => '<warning>', 'm' => 'delete', 'c' => '<token>']],
'manage-role-index' => ['/manage/users.php', ['v' => 'roles']],
'manage-role-create' => ['/manage/users.php', ['v' => 'role']],
'manage-role-edit' => ['/manage/users.php', ['v' => 'role', 'r' => '<role>']],
'manage-warning-delete' => ['/manage/users.php', ['v' => 'warnings', 'u' => '<user>', 'w' => '<warning>', 'm' => 'delete', 'c' => '<token>']],
]);
function url(string $name, array $variables = []): string

View file

@ -74,7 +74,7 @@
},
{
'title': 'Manage',
'url': manage_link|default('/manage/index.php'),
'url': manage_link|default(url('manage-index')),
'icon': 'fas fa-door-closed fa-fw',
'display': has_manage_access and manage_menu is not defined
},

View file

@ -8,7 +8,7 @@
<div class="container__content">
{% for forum in forums %}
<a href="{{ url('manage-forum-category-view', {'forum': forum.forum_id}) }}" class="warning__link">{{ forum.forum_name }}</a><br>
<a href="{{ url('manage-forum-category', {'forum': forum.forum_id}) }}" class="warning__link">{{ forum.forum_name }}</a><br>
{% endfor %}
</div>
</div>

View file

@ -21,13 +21,13 @@
{% endif %}
<div class="manage__blacklist">
<form action="" method="post" class="manage__blacklist__form">
<form action="{{ url('manage-general-blacklist') }}" method="post" class="manage__blacklist__form">
{{ input_csrf('ip_blacklist') }}
<textarea name="blacklist[add]" class="input__textarea manage__blacklist__textarea" placeholder="Enter CIDR (subnet/mask), each line will be processed. Addresses without a mask will just be blacklisted alone."></textarea>
<button class="input__button input__button--save manage__blacklist__button">Add</button>
</form>
<form action="" method="post" class="manage__blacklist__form">
<form action="{{ url('manage-general-blacklist') }}" method="post" class="manage__blacklist__form">
{{ input_csrf('ip_blacklist') }}
{{ input_select('blacklist[remove][]', blacklist, null, 'ip_cidr', null, true, 'manage__blacklist__select', {
'multiple': true,

View file

@ -5,7 +5,7 @@
{% block manage_content %}
<div class="container settings__container">
{{ container_title('<i class="fas fa-file-alt fa-fw"></i> Global Log') }}
{% set glp = pagination(global_logs_pagination, '/manage/index.php', null, {'v': 'logs'}) %}
{% set glp = pagination(global_logs_pagination, url('manage-general-logs'), null, {'v': 'logs'}) %}
<div class="settings__account-logs">
<div class="settings__account-logs__pagination">