From 64f0533dc1779e7cca5f2678f7ae560df8d922bb Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 3 May 2025 01:39:13 +0500 Subject: feat: config sample and more config options --- public/404.php | 3 +- public/account/index.php | 2 +- public/account/login/index.php | 22 +++++++++++---- public/account/login/twitch.php | 12 ++++++-- public/captcha.php | 11 ++++---- public/emotes/index.php | 62 +++++++++++++++++++++-------------------- public/emotes/rate.php | 5 ++++ public/emotes/upload.php | 30 +++++++++++--------- public/emotesets.php | 6 ++-- public/inbox.php | 2 +- public/index.php | 6 ++-- public/report/index.php | 8 +++++- public/report/list.php | 7 ++++- public/report/send.php | 5 ++++ public/system/emotes/index.php | 2 +- public/system/index.php | 2 +- public/users.php | 4 +-- 17 files changed, 118 insertions(+), 71 deletions(-) (limited to 'public') diff --git a/public/404.php b/public/404.php index 5646c46..8a4106d 100644 --- a/public/404.php +++ b/public/404.php @@ -1,10 +1,11 @@ - Not found - alright.party + Not found - <?php echo INSTANCE_NAME ?> diff --git a/public/account/index.php b/public/account/index.php index a216eea..6b1385f 100644 --- a/public/account/index.php +++ b/public/account/index.php @@ -70,7 +70,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { - Account management - alright.party + Account management - <?php echo INSTANCE_NAME ?> diff --git a/public/account/login/index.php b/public/account/login/index.php index e104a88..954ccc9 100644 --- a/public/account/login/index.php +++ b/public/account/login/index.php @@ -3,12 +3,20 @@ include "../../../src/accounts.php"; authorize_user(); include "../../../src/partials.php"; +include_once "../../../src/config.php"; +include_once "../../../src/alert.php"; + +if (!ACCOUNT_REGISTRATION_ENABLE) { + generate_alert("/404.php", "Account registration is disabled", 403); + exit; +} + ?> - Log in to alright.party + Login - <?php echo INSTANCE_NAME ?> @@ -20,13 +28,15 @@ include "../../../src/partials.php";
-
- -
+ +
+ +
+
diff --git a/public/account/login/twitch.php b/public/account/login/twitch.php index 1c72bc3..dfd319f 100644 --- a/public/account/login/twitch.php +++ b/public/account/login/twitch.php @@ -1,10 +1,16 @@ - Resolving a hCaptcha for alright.party + Resolving a hCaptcha - <?php echo INSTANCE_NAME ?> diff --git a/public/emotes/index.php b/public/emotes/index.php index 2102aba..3c165be 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -154,8 +154,8 @@ if (CLIENT_REQUIRES_JSON) { <?php - echo empty($emotes) ? "Emote " . $emote->get_code() : "Emotes" - ?> - alright.party + echo (empty($emotes) ? "Emote " . $emote->get_code() : "Emotes") . ' - ' . INSTANCE_NAME + ?> @@ -309,33 +309,34 @@ if (CLIENT_REQUIRES_JSON) { echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago"; ?> - - Rating - get_rating()["total"] < 10) { - echo 'Not rated (' . $emote->get_rating()["total"] . ')'; - } else { + + + Rating + get_rating()["total"] < 10) { + echo 'Not rated (' . $emote->get_rating()["total"] . ')'; + } else { - $rating = $emote->get_rating()["average"]; + $rating = $emote->get_rating()["average"]; - // TODO: make it customizable - list($rating_classname, $rating_name) = match (true) { - in_range($rating, 0.75, 1.0) => [ - "gemerald", - " + // TODO: make it customizable + list($rating_classname, $rating_name) = match (true) { + in_range($rating, 0.75, 1.0) => [ + "gemerald", + " Shiny Gemerald! " - ], - in_range($rating, 0.25, 0.75) => ["gem", " Gem "], - in_range($rating, -0.25, 0.25) => ["iron", "Iron"], - in_range($rating, -0.75, -0.25) => ["coal", " Coal "], - in_range($rating, -1.0, -0.75) => [ - "brimstone", - " + ], + in_range($rating, 0.25, 0.75) => ["gem", " Gem "], + in_range($rating, -0.25, 0.25) => ["iron", "Iron"], + in_range($rating, -0.75, -0.25) => ["coal", " Coal "], + in_range($rating, -1.0, -0.75) => [ + "brimstone", + " @@ -344,16 +345,17 @@ if (CLIENT_REQUIRES_JSON) { " - ] - }; + ] + }; - echo ''; - echo "$rating_name"; - echo ' (' . $emote->get_rating()["total"] . ')'; - echo ''; - } - ?> - + echo ''; + echo "$rating_name"; + echo ' (' . $emote->get_rating()["total"] . ')'; + echo ''; + } + ?> + + Visibility - Upload an emote at alright.party + Upload an emote - <?php echo INSTANCE_NAME ?> @@ -58,14 +62,14 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") {

Emote name

-

Image

+

Image

@@ -123,8 +127,8 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { image.src = e.target.result; image.onload = () => { let m = 1; - let max_width = 128; - let max_height = 128; + let max_width = ; + let max_height = ; isImage = true; for (let i = 3; i > 0; i--) { @@ -153,9 +157,9 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { let validCode = ""; code.addEventListener("input", (e) => { - const regex = /^[a-zA-Z0-9]*$/; + const regex = ; - if (regex.test(e.target.value) && e.target.value.length <= 100) { + if (regex.test(e.target.value) && e.target.value.length <= ) { validCode = e.target.value; } else { e.target.value = validCode; @@ -196,9 +200,9 @@ if (!isset($_FILES["file"])) { exit; } -$code = str_safe($_POST["code"] ?? "", 500); +$code = str_safe($_POST["code"] ?? "", EMOTE_NAME_MAX_LENGTH); -if ($code == "") { +if ($code == "" || !preg_match(EMOTE_NAME_REGEX, $code)) { http_response_code(400); echo json_encode([ "status_code" => 400, @@ -273,7 +277,7 @@ if ($resized_image) { $db = null; -if (isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json") { +if (CLIENT_REQUIRES_JSON) { http_response_code(201); echo json_encode([ "status_code" => 201, diff --git a/public/emotesets.php b/public/emotesets.php index 8dfdab0..cacdae4 100644 --- a/public/emotesets.php +++ b/public/emotesets.php @@ -185,8 +185,10 @@ if (CLIENT_REQUIRES_JSON) { - <?php echo $emote_sets != null ? (count($emote_sets) . " emotesets") : ('"' . $emote_set["name"] . '" emoteset') ?> - - alright.party + <?php + echo $emote_sets != null ? (count($emote_sets) . " emotesets") : ('"' . $emote_set["name"] . '" emoteset'); + echo ' - ' . INSTANCE_NAME; + ?> diff --git a/public/inbox.php b/public/inbox.php index 878bfe4..7d632b6 100644 --- a/public/inbox.php +++ b/public/inbox.php @@ -23,7 +23,7 @@ $stmt->execute([$_SESSION["user_id"]]); - Inbox - alright.party + Inbox - <?php echo INSTANCE_NAME ?> diff --git a/public/index.php b/public/index.php index 8f1d7dd..1b1c33b 100644 --- a/public/index.php +++ b/public/index.php @@ -7,20 +7,20 @@ authorize_user(); - alright.party + <?php echo INSTANCE_NAME ?>
-

<?php echo $_SERVER['HTTP_HOST']; ?>

+

<?php echo INSTANCE_NAME; ?>

Emotes Emotesets Users - Upload'; } ?> Account diff --git a/public/report/index.php b/public/report/index.php index 179c2bd..aef571e 100644 --- a/public/report/index.php +++ b/public/report/index.php @@ -5,6 +5,11 @@ include_once "../../src/partials.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } @@ -53,7 +58,8 @@ if ($contents == "") { - <?php echo $report == null ? "Send a message to MODS" : "A message to MODS" ?> - alright.party + <?php echo ($report == null ? "Send a message to MODS" : "A message to MODS") . ' - ' . INSTANCE_NAME ?> + diff --git a/public/report/list.php b/public/report/list.php index 087eb55..34ddceb 100644 --- a/public/report/list.php +++ b/public/report/list.php @@ -5,6 +5,11 @@ include_once "../../src/partials.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } @@ -25,7 +30,7 @@ $reports = $stmt->fetchAll(PDO::FETCH_ASSOC); - Report list - alright.party + Report list - <?php echo INSTANCE_NAME ?> diff --git a/public/report/send.php b/public/report/send.php index e5a77be..ab136e1 100644 --- a/public/report/send.php +++ b/public/report/send.php @@ -4,6 +4,11 @@ include_once "../../src/config.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } diff --git a/public/system/emotes/index.php b/public/system/emotes/index.php index f49ff97..1c16152 100644 --- a/public/system/emotes/index.php +++ b/public/system/emotes/index.php @@ -43,7 +43,7 @@ if ($emote_id > 0) { - System panel - alright.party + System panel - <?php echo INSTANCE_NAME ?> diff --git a/public/system/index.php b/public/system/index.php index aa959c0..601339b 100644 --- a/public/system/index.php +++ b/public/system/index.php @@ -21,7 +21,7 @@ $db = new PDO(DB_URL, DB_USER, DB_PASS); - System panel - alright.party + System panel - <?php echo INSTANCE_NAME ?> diff --git a/public/users.php b/public/users.php index 8b62a8a..fbedb4d 100644 --- a/public/users.php +++ b/public/users.php @@ -52,7 +52,7 @@ if ($id == "" && $alias_id == "") { - User list - alright.party + User list - <?php echo INSTANCE_NAME ?> @@ -307,7 +307,7 @@ if ($is_json) { - <?php echo $user->username() ?> - alright.party + <?php echo sprintf("%s - %s", $user->username(), INSTANCE_NAME) ?> -- cgit v1.2.3