Beginning work on splitting up manage into multiple files.
This commit is contained in:
parent
0f0c975209
commit
2a7b1680ad
15 changed files with 426 additions and 417 deletions
|
@ -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;
|
||||
}
|
22
public/manage/forum/category.php
Normal file
22
public/manage/forum/category.php
Normal 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'));
|
19
public/manage/forum/index.php
Normal file
19
public/manage/forum/index.php
Normal 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'));
|
46
public/manage/general/blacklist.php
Normal file
46
public/manage/general/blacklist.php
Normal 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(),
|
||||
]);
|
9
public/manage/general/emoticons.php
Normal file
9
public/manage/general/emoticons.php
Normal 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');
|
180
public/manage/general/index.php
Normal file
180
public/manage/general/index.php
Normal 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,
|
||||
]);
|
23
public/manage/general/logs.php
Normal file
23
public/manage/general/logs.php
Normal 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,
|
||||
]);
|
9
public/manage/general/settings.php
Normal file
9
public/manage/general/settings.php
Normal 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');
|
|
@ -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'));
|
||||
|
|
|
@ -8,22 +8,22 @@ function manage_get_menu(int $userId): array
|
|||
}
|
||||
|
||||
$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';
|
||||
$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';
|
||||
$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';
|
||||
$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';
|
||||
$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)) {
|
||||
|
@ -51,7 +51,7 @@ function manage_get_menu(int $userId): array
|
|||
}
|
||||
|
||||
if(perms_check($perms[MSZ_PERMS_FORUM], MSZ_PERM_FORUM_MANAGE_FORUMS)) {
|
||||
$menu['Forum']['Listing'] = '/manage/forum.php?v=listing';
|
||||
$menu['Forum']['Categories'] = url('manage-forum-categories');
|
||||
}
|
||||
|
||||
if(perms_check($perms[MSZ_PERMS_FORUM], 0)) {
|
||||
|
|
14
src/url.php
14
src/url.php
|
@ -92,15 +92,21 @@ define('MSZ_URLS', [
|
|||
'comment-pin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'pin']],
|
||||
'comment-unpin' => ['/comments.php', ['c' => '<comment>', 'csrf' => '{comments}', 'm' => 'unpin']],
|
||||
|
||||
'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-categories' => ['/manage/forum/index.php'],
|
||||
'manage-forum-category' => ['/manage/forum/category.php', ['f' => '<forum>']],
|
||||
|
||||
'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-forum-category-view' => ['/manage/forum.php', ['v' => 'forum', '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']],
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Add table
Reference in a new issue