summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-06-14 12:29:31 +0400
committerilotterytea <iltsu@alright.party>2025-06-14 12:29:31 +0400
commitde84928b8a6bcb9bfd64c5697c874495d983b819 (patch)
treea7b65c2477f9eb37d07e2bd58d6184884b23d7f6 /public
parentdd0faa97a3c890e90d9307cde57e797146a97d3c (diff)
upd: generate alerts in /mod.php
Diffstat (limited to 'public')
-rw-r--r--public/mod.php18
1 files changed, 5 insertions, 13 deletions
diff --git a/public/mod.php b/public/mod.php
index 38e259e..2d45e76 100644
--- a/public/mod.php
+++ b/public/mod.php
@@ -8,16 +8,16 @@ session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!isset($_POST['password'])) {
- json_response(null, 'No password set', 400);
+ generate_alert('/mod.php', 'No password set!', 400, null);
exit();
}
if (!is_file(MOD_FILE) && !file_put_contents(MOD_FILE, '')) {
- json_response(null, 'Failed to create a file for mod passwords', 500);
+ generate_alert('/mod.php', 'Failed to create a file for mod passwords!', 500, null);
exit();
}
- $password_file = explode('\n', file_get_contents(MOD_FILE));
+ $password_file = explode(PHP_EOL, file_get_contents(MOD_FILE));
$is_authorized = false;
@@ -29,21 +29,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
}
if (!$is_authorized) {
- if (IS_JSON_REQUEST) {
- json_response(null, 'Unauthorized!', 401);
- } else {
- header('Location: /mod.php');
- }
+ generate_alert('/mod.php', 'Unauthorized!', 401, null);
exit();
}
$_SESSION['is_moderator'] = $is_authorized;
- if (IS_JSON_REQUEST) {
- json_response(null, 'Authorized!', 200);
- } else {
- header('Location: /mod.php');
- }
+ generate_alert('/mod.php', 'Authorized!', 200, null);
exit();
}