From 29477e67ede12347b153e2255325327374e1b073 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 9 Dec 2025 01:43:12 +0500 Subject: feat: new configuration --- emotes/delete.php | 2 +- emotes/index.php | 16 +- emotes/rate.php | 4 +- emotes/setmanip.php | 10 +- emotes/upload.php | 596 ++++++++++++++++++++++++++-------------------------- 5 files changed, 314 insertions(+), 314 deletions(-) (limited to 'emotes') diff --git a/emotes/delete.php b/emotes/delete.php index 159e293..03b6dec 100644 --- a/emotes/delete.php +++ b/emotes/delete.php @@ -16,7 +16,7 @@ if (!isset($_POST["id"])) { $emote_id = $_POST["id"]; $user_id = $_SESSION["user_id"]; -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); $stmt = $db->prepare("SELECT uploaded_by, code FROM emotes WHERE id = ?"); $stmt->execute([$emote_id]); diff --git a/emotes/index.php b/emotes/index.php index 80a8c1d..3999d8e 100644 --- a/emotes/index.php +++ b/emotes/index.php @@ -8,7 +8,7 @@ include "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php"; authorize_user(); -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); $user_id = $_SESSION["user_id"] ?? ""; @@ -126,7 +126,7 @@ if (CLIENT_REQUIRES_JSON) { <?php - echo ($emote != null ? "Emote " . $emote->get_code() : "Emotes") . ' - ' . INSTANCE_NAME + echo ($emote != null ? "Emote " . $emote->get_code() : "Emotes") . ' - ' . CONFIG['instance']['name'] ?> @@ -302,9 +302,9 @@ if (CLIENT_REQUIRES_JSON) { if ($row = $stmt->fetch()) { echo 'You gave '; + echo 'title="' . CONFIG['rating']['names'][$row["rate"]] . '">'; } else { - foreach (RATING_NAMES as $key => $value) { + foreach (CONFIG['rating']['names'] as $key => $value) { echo '
'; echo ''; echo ""; @@ -316,7 +316,7 @@ if (CLIENT_REQUIRES_JSON) { } } } - if (REPORTS_ENABLE && $_SESSION["user_role"]["permission_report"]) { + if (CONFIG['reports']['enable'] && $_SESSION["user_role"]["permission_report"]) { echo "Report emote"; } } @@ -348,7 +348,7 @@ if (CLIENT_REQUIRES_JSON) { Uploader '; } - if (RATING_ENABLE): ?> + if (CONFIG['rating']['enable']): ?> Rating get_rating()["total"] < RATING_EMOTE_MIN_VOTES) { + if ($emote->get_rating()["total"] < CONFIG['rating']['minvotes']) { echo 'Not rated (' . $emote->get_rating()["total"] . ')'; } else { diff --git a/emotes/rate.php b/emotes/rate.php index fbea404..2e862f9 100644 --- a/emotes/rate.php +++ b/emotes/rate.php @@ -4,7 +4,7 @@ include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/utils.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php"; -if (!RATING_ENABLE) { +if (!CONFIG['rating']['enable']) { generate_alert("/404.php", "Emote ratings are disabled", 403); exit; } @@ -26,7 +26,7 @@ if ($id == 0 || $rate == 0) { exit; } -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); // checking if emote exists $stmt = $db->prepare("SELECT id FROM emotes WHERE id = ?"); diff --git a/emotes/setmanip.php b/emotes/setmanip.php index cf8add6..d6a5f4f 100644 --- a/emotes/setmanip.php +++ b/emotes/setmanip.php @@ -18,7 +18,7 @@ if (!isset($_POST["id"], $_POST["action"], $_POST["emote_set_id"])) { exit; } -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); // checking emote $emote_id = $_POST["id"]; @@ -62,7 +62,7 @@ switch ($action) { $stmt = $db->prepare("INSERT INTO emote_set_contents(emote_set_id, emote_id, added_by) VALUES (?, ?, ?)"); $stmt->execute([$emote_set_id, $emote_id, $user_id]); - if (ACCOUNT_LOG_ACTIONS) { + if (CONFIG['account']['log']) { $db->prepare("INSERT INTO actions(user_id, action_type, action_payload) VALUES (?, ?, ?)") ->execute([$user_id, "EMOTESET_ADD", json_encode($payload)]); } @@ -82,7 +82,7 @@ switch ($action) { exit; } - if (ACCOUNT_LOG_ACTIONS) { + if (CONFIG['account']['log']) { $db->prepare("INSERT INTO actions(user_id, action_type, action_payload) VALUES (?, ?, ?)") ->execute([$user_id, "EMOTESET_REMOVE", json_encode($payload)]); } @@ -98,7 +98,7 @@ switch ($action) { exit; } - $value = str_safe($_POST["value"], EMOTE_NAME_MAX_LENGTH); + $value = str_safe($_POST["value"], CONFIG['emote']['maxnamelength']); $stmt = $db->prepare("SELECT esc.code AS alias_code, e.code FROM emote_set_contents esc INNER JOIN emotes e ON e.id = esc.emote_id @@ -121,7 +121,7 @@ switch ($action) { $stmt = $db->prepare("UPDATE emote_set_contents SET code = ? WHERE emote_set_id = ? AND emote_id = ?"); $stmt->execute([$value, $emote_set_id, $emote_id]); - if (ACCOUNT_LOG_ACTIONS) { + if (CONFIG['account']['log']) { $db->prepare("INSERT INTO actions(user_id, action_type, action_payload) VALUES (?, ?, ?)") ->execute([$user_id, "EMOTESET_ALIAS", json_encode($payload)]); } diff --git a/emotes/upload.php b/emotes/upload.php index 01ae1ee..e509345 100644 --- a/emotes/upload.php +++ b/emotes/upload.php @@ -4,27 +4,27 @@ include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/captcha.php"; -if (!EMOTE_UPLOAD) { +if (!CONFIG['emote']['upload']) { generate_alert("/404.php", "Emote upload is disabled", 403); exit; } authorize_user(); -if (!ANONYMOUS_UPLOAD && isset($_SESSION["user_role"]) && !$_SESSION["user_role"]["permission_upload"]) { +if (!CONFIG['anonymous']['upload'] && isset($_SESSION["user_role"]) && !$_SESSION["user_role"]["permission_upload"]) { generate_alert("/404.php", "Not enough permissions", 403); exit; } $uploaded_by = null; -$uploader_name = ANONYMOUS_DEFAULT_NAME; +$uploader_name = CONFIG['anonymous']['defaultname']; if (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"]) { $uploaded_by = $_SESSION["user_id"] ?? null; - $uploader_name = $_SESSION["user_name"] ?? ANONYMOUS_DEFAULT_NAME; + $uploader_name = $_SESSION["user_name"] ?? CONFIG['anonymous']['defaultname']; } -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); function abort_upload(string $path, PDO $db, string $id) { @@ -39,152 +39,152 @@ function abort_upload(string $path, PDO $db, string $id) include "{$_SERVER['DOCUMENT_ROOT']}/lib/utils.php"; include "{$_SERVER['DOCUMENT_ROOT']}/lib/images.php"; -$max_width = EMOTE_MAX_SIZE[0]; -$max_height = EMOTE_MAX_SIZE[1]; +$max_width = CONFIG['emote']['maxsizex']; +$max_height = CONFIG['emote']['maxsizey']; if ($_SERVER['REQUEST_METHOD'] != "POST") { include "{$_SERVER['DOCUMENT_ROOT']}/lib/partials.php"; echo '' ?> - - - - Upload an emote - <?php echo INSTANCE_NAME ?> - - - - - -
-
- - - -
-
-
- -
- -

Image*

- - - - - -
- - -
- -

Emote name*

- - -
- -
-

test

+ + + + Upload an emote - <?php echo CONFIG['instance']['name'] ?> + + + + + +
+
+ + + +
+
+
+ - - - - - - - - - - - - - - - -
Emote source: -
Tags [?]: -
- -
- - +
+ +

Image*

+ + + + + +
+ + +
+ +

Emote name*

+ + +
+ +
+

test

+
+ + + + + + + + + + + + + + + +
Emote source: +
Tags [?]: +
+ +
+ + +
+ + +
+
- - +
-
- -
- -
- -
- -
- query("SELECT u.username, + +
+ +
+ query("SELECT u.username, CASE WHEN ub.badge_id IS NOT NULL THEN ub.badge_id WHEN r.badge_id IS NOT NULL THEN r.badge_id @@ -197,194 +197,194 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { ORDER BY RAND() LIMIT 3 "); - while ($row = $stmt->fetch()) { - echo '
'; + while ($row = $stmt->fetch()) { + echo '
'; - if ($row["badge_id"]) { - echo ' '; - } + if ($row["badge_id"]) { + echo ' '; + } - echo ''; - echo $row["username"]; - echo ': '; + echo ''; + echo $row["username"]; + echo ': '; - echo ''; + echo ''; - echo '
'; - } - ?> + echo '
'; + } + ?> +
+
-
-
-
- - - + - + - 0 && $count >= TAGS_MAX_COUNT) { + if (CONFIG['tags']['maxcount'] > 0 && $count >= CONFIG['tags']['maxcount']) { break; } - if (!preg_match(TAGS_CODE_REGEX, $tag)) { + if (!preg_match(CONFIG['tags']['regex'], $tag)) { continue; } @@ -526,7 +526,7 @@ $emote_data = [ "tags" => $tags_processed ]; -if (ACCOUNT_LOG_ACTIONS && $uploaded_by != null) { +if (CONFIG['account']['log'] && $uploaded_by != null) { $db->prepare("INSERT INTO actions(user_id, action_type, action_payload) VALUES (?, ?, ?)") ->execute([ $uploaded_by, -- cgit v1.2.3