From 29477e67ede12347b153e2255325327374e1b073 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 9 Dec 2025 01:43:12 +0500 Subject: feat: new configuration --- system/config.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++ system/emotes/index.php | 10 +- system/emotes/verdict.php | 4 +- system/index.php | 10 +- 4 files changed, 442 insertions(+), 12 deletions(-) create mode 100644 system/config.php (limited to 'system') diff --git a/system/config.php b/system/config.php new file mode 100644 index 0000000..4144b93 --- /dev/null +++ b/system/config.php @@ -0,0 +1,430 @@ + $sv) { + foreach ($sv as $k => &$v) { + if (is_bool($v) && !array_key_exists("{$sk}_$k", $_POST)) { + $c[$sk][$k] = false; + } + } + unset($v); + } + + foreach ($_POST as $k => $v) { + $parts = explode('_', $k); + $part_count = count($parts); + if ($part_count != 2) { + continue; + } + $section = $parts[0]; + $key = $parts[1]; + + if (!array_key_exists($section, $c)) { + $c[$section] = []; + } + + if ($v === 'on') { + $v = true; + } + + if (is_numeric($v)) { + $v += 0; + } + + $c[$section][$key] = $v; + } + + if (!file_put_contents(CFG_PATH, json_encode($c, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT))) { + http_response_code(500); + exit("Failed to write the configuration file."); + } + + generate_alert('/system/config.php', 'Saved!', 200); + exit(); +} + +?> + + + + Configuration - <?= CONFIG['instance']['name'] ?> + + + + + +
+
+ +
+

Instance configuration

+ +
+

This message confirms the instance is nearly ready. The configuration below shows the default + settings. Enter your database credentials to complete the setup.

+
+ +
+
+ +
+ + + + + +
Name
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
Name
User
Password
Host
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Allow emote upload>
Allow anonymous emote upload>
Default uploader name
RegEx filter for names
Default visibility + +
Max name length
Max comment length
Max sizeX: Y: + +
Store original uploaded file>
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enable account registration>
Max. cookie lifetime (in seconds)
RegEx filter for usernames
Username lengthMin: + Max:
Min. password length
Secret key length
Profile picture sizeX: + Y:
Profile banner sizeX: + Y:
Badge sizeX: + Y:
Enable public list>
Log actions>
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
Enable account registration via Twitch value="on"> +
Client ID +
Client secret +
Redirect URI +
+
+
+ +
+ +
+ + + + + + + + + + + + + +
Enable CAPTCHA value="on"> +
Force authorized users to solve CAPTCHA value="on"> +
SizeMin: + Max:
+
+
+ +
+ +
+ + + + + + + + + + + + + +
Enable rating value="on"> +
Names[?] +
Minimal amount of votes
+
+
+ +
+ +
+ + + + + + + + + + + + + +
Enable tags value="on"> +
RegEx filter +
Maximum amount of tags per emote.
+
+
+ +
+ +
+ + + + + +
Show emotesets public value="on"> +
+
+
+ +
+ +
+ + + + + + + + + +
Enable system dashboard for moderators value="on"> +
Enable manual emote approval value="on"> +
+
+
+ +
+ +
+ + + + + +
Enable reports value="on"> +
+
+
+ + +
+
+
+
+ + + \ No newline at end of file diff --git a/system/emotes/index.php b/system/emotes/index.php index d172482..79be71f 100644 --- a/system/emotes/index.php +++ b/system/emotes/index.php @@ -5,7 +5,7 @@ include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/utils.php"; -if (!MOD_EMOTES_APPROVE) { +if (!CONFIG['mod']['approve']) { generate_alert("/404.php", "Manual emote approval is disabled", 405); exit; } @@ -17,7 +17,7 @@ if (!authorize_user(true) || !$_SESSION["user_role"]["permission_approve_emotes" $current_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']); $emote_results = $db->prepare("SELECT e.*, CASE WHEN up.private_profile = FALSE OR up.id = ? THEN e.uploaded_by ELSE NULL END AS uploaded_by, CASE WHEN up.private_profile = FALSE OR up.id = ? THEN u.username ELSE NULL END AS uploader_name, @@ -65,7 +65,7 @@ if (isset($_GET["id"])) { - System panel - <?php echo INSTANCE_NAME ?> + System panel - <?php echo CONFIG['instance']['name'] ?> @@ -87,7 +87,7 @@ if (isset($_GET["id"])) { echo ' by '; if ($row["uploader_name"] == null) { - echo ANONYMOUS_DEFAULT_NAME . '*'; + echo CONFIG['anonymous']['defaultname'] . '*'; } else { echo $row["uploader_name"]; } @@ -174,7 +174,7 @@ if (isset($_GET["id"])) { Uploader prepare("SELECT id, code, uploaded_by FROM emotes WHERE id = ? AND visibility = 2 LIMIT 1"); $stmt->execute([$id]); diff --git a/system/index.php b/system/index.php index f5c1677..31291be 100644 --- a/system/index.php +++ b/system/index.php @@ -4,7 +4,7 @@ include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/accounts.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/alert.php"; include_once "{$_SERVER['DOCUMENT_ROOT']}/lib/config.php"; -if (!MOD_SYSTEM_DASHBOARD) { +if (!CONFIG['mod']['dashboard']) { generate_alert("/404.php", "System dashboard is disabled", 405); exit; } @@ -14,14 +14,14 @@ if (!authorize_user(true) || (!$_SESSION["user_role"]["permission_approve_emotes exit; } -$db = new PDO(DB_URL, DB_USER, DB_PASS); +$db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['database']['pass']); ?> - System panel - <?php echo INSTANCE_NAME ?> + System panel - <?php echo CONFIG['instance']['name'] ?> @@ -35,7 +35,7 @@ $db = new PDO(DB_URL, DB_USER, DB_PASS);
Emotes'; $results = $db->query("SELECT COUNT(*) FROM emotes WHERE visibility = 2")->fetch()[0]; @@ -47,7 +47,7 @@ $db = new PDO(DB_URL, DB_USER, DB_PASS); echo ''; } - if (REPORTS_ENABLE && $_SESSION["user_role"]["permission_report_review"]) { + if (CONFIG['reports']['enable'] && $_SESSION["user_role"]["permission_report_review"]) { echo 'Reports'; $results = $db->query("SELECT COUNT(*) FROM reports WHERE resolved_by IS NULL")->fetch()[0]; -- cgit v1.2.3