summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-05-14 23:18:20 +0500
committerilotterytea <iltsu@alright.party>2025-05-14 23:19:32 +0500
commit44334d654977ed4ecd601c7a47127f91dea1517d (patch)
tree64b7c5c08c4a69af14dbae9b55566e202c6fe521
parentd461b5be189cb2f38a48e0e1d1e0ee6570b6e877 (diff)
feat: emote source
-rw-r--r--database.sql6
-rw-r--r--public/emotes/index.php15
-rw-r--r--public/emotes/upload.php16
-rw-r--r--public/system/emotes/index.php9
-rw-r--r--src/emote.php10
5 files changed, 50 insertions, 6 deletions
diff --git a/database.sql b/database.sql
index a92ad46..6ce0c96 100644
--- a/database.sql
+++ b/database.sql
@@ -138,6 +138,12 @@ CREATE TABLE IF NOT EXISTS actions (
);
-- -------------------------
+-- ALTERS
+-- -------------------------
+
+ALTER TABLE emotes ADD COLUMN IF NOT EXISTS source TEXT;
+
+-- -------------------------
-- INSERTIONS
-- -------------------------
diff --git a/public/emotes/index.php b/public/emotes/index.php
index 978515f..68ae983 100644
--- a/public/emotes/index.php
+++ b/public/emotes/index.php
@@ -77,7 +77,8 @@ function display_list_emotes(PDO &$db, string $search, string $sort_by, int $pag
$uploader,
$row["is_in_user_set"],
$row["rating"],
- $row["visibility"]
+ $row["visibility"],
+ $row["source"]
));
}
@@ -107,7 +108,8 @@ function display_emote(PDO &$db, string $id)
$row["uploaded_by"],
false,
["total" => $row["total_rating"], "average" => $row["average_rating"]],
- $row["visibility"]
+ $row["visibility"],
+ $row["source"]
);
}
}
@@ -476,6 +478,15 @@ if (CLIENT_REQUIRES_JSON) {
}
?></td>
</tr>
+ <?php if ($emote->get_source()): ?>
+ <tr>
+ <th>Source</th>
+ <td>
+ <a href="<?php echo $emote->get_source() ?>"
+ target="_blank"><?php echo $emote->get_source() ?></a>
+ </td>
+ </tr>
+ <?php endif; ?>
</table>
</section>
diff --git a/public/emotes/upload.php b/public/emotes/upload.php
index 2c37c26..a9d416c 100644
--- a/public/emotes/upload.php
+++ b/public/emotes/upload.php
@@ -100,10 +100,15 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") {
<p id="form-visibility-description" style="font-size: 10px;">test</p>
</div>
- <label for="notes">Approval notes (optional)</label>
+ <label for="notes">Approval notes</label>
<textarea name="notes" id="form-notes"></textarea>
<div>
+ <label class="inline" for="source">Emote source: </label>
+ <input name="source" id="form-source"></input>
+ </div>
+
+ <div>
<label for="tos" class="inline">Do you accept <a href="/rules.php" target="_BLANK">the
rules</a>?<span style="color:red;">*</span></label>
<input type="checkbox" name="tos" value="1" required>
@@ -323,6 +328,11 @@ if (empty($notes)) {
$notes = null;
}
+$source = str_safe($_POST["source"] ?? "", null);
+if (empty($source)) {
+ $source = null;
+}
+
$visibility = clamp(intval($_POST["visibility"], EMOTE_VISIBILITY_DEFAULT), 0, 2);
if (MOD_EMOTES_APPROVE && $visibility == 1 && EMOTE_VISIBILITY_DEFAULT != 1) {
@@ -333,8 +343,8 @@ if (MOD_EMOTES_APPROVE && $visibility == 1 && EMOTE_VISIBILITY_DEFAULT != 1) {
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$id = bin2hex(random_bytes(16));
-$stmt = $db->prepare("INSERT INTO emotes(id, code, notes, uploaded_by, visibility) VALUES (?, ?, ?, ?, ?)");
-$stmt->execute([$id, $code, $notes, $uploaded_by, $visibility]);
+$stmt = $db->prepare("INSERT INTO emotes(id, code, notes, source, uploaded_by, visibility) VALUES (?, ?, ?, ?, ?, ?)");
+$stmt->execute([$id, $code, $notes, $source, $uploaded_by, $visibility]);
$path = "../static/userdata/emotes/$id";
diff --git a/public/system/emotes/index.php b/public/system/emotes/index.php
index 9732bdb..9e88d83 100644
--- a/public/system/emotes/index.php
+++ b/public/system/emotes/index.php
@@ -179,6 +179,15 @@ if (isset($_GET["id"])) {
<th>Notes</th>
<td><?php echo isset($emote["notes"]) == true ? $emote["notes"] : '<i>Empty</i>' ?></td>
</tr>
+ <?php if ($emote["source"]): ?>
+ <tr>
+ <th>Source</th>
+ <td>
+ <a href="<?php echo $emote["source"] ?>"
+ target="_blank"><?php echo $emote["source"] ?></a>
+ </td>
+ </tr>
+ <?php endif; ?>
</table>
</section>
<!-- Mod actions on emote -->
diff --git a/src/emote.php b/src/emote.php
index ea9e52c..8e7da38 100644
--- a/src/emote.php
+++ b/src/emote.php
@@ -10,7 +10,9 @@ class Emote
public bool $is_in_user_set;
public int $visibility;
- function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set, $rating, $visibility)
+ public string|null $source;
+
+ function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set, $rating, $visibility, $source)
{
$this->id = $id;
$this->code = $code;
@@ -20,6 +22,7 @@ class Emote
$this->is_in_user_set = $is_in_user_set;
$this->rating = $rating;
$this->visibility = $visibility;
+ $this->source = $source;
}
function get_id()
@@ -61,6 +64,11 @@ class Emote
{
return $this->visibility;
}
+
+ function get_source()
+ {
+ return $this->source;
+ }
}
function html_random_emote(PDO &$db)