summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-22 13:15:31 +0500
committerilotterytea <iltsu@alright.party>2025-04-22 13:15:31 +0500
commit460d12ab7bb93daa6b03300fefdfccefb6d32d01 (patch)
tree9255b1a75f9cf31b4b6b87bcb1268a0b80df74fe
parentbb05b244f95bb6f507c9e825efd4da4d3d93662b (diff)
upd: combined single_page and multiple_page into one + updated emote url
-rw-r--r--public/emotes/index.php209
-rw-r--r--public/emotes/setmanip.php14
-rw-r--r--public/emotes/upload.php2
-rw-r--r--public/users.php2
-rw-r--r--src/alert.php2
-rw-r--r--src/emotes/multiple_page.php48
-rw-r--r--src/emotes/single_page.php169
7 files changed, 206 insertions, 240 deletions
diff --git a/public/emotes/index.php b/public/emotes/index.php
index b377430..5224433 100644
--- a/public/emotes/index.php
+++ b/public/emotes/index.php
@@ -2,6 +2,9 @@
include "../../src/emote.php";
include "../../src/accounts.php";
include_once "../../src/config.php";
+include "../../src/partials.php";
+include "../../src/utils.php";
+include "../../src/alert.php";
authorize_user();
@@ -85,27 +88,207 @@ function display_emote(int $id)
return $emote;
}
-$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
- $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
-$current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
-
-$id = parse_url($current_url, PHP_URL_PATH);
-$id = substr($id, 8);
-$id = str_replace("/", "", $id);
-
$emotes = null;
$emote = null;
-include "../../src/partials.php";
-include "../../src/utils.php";
-include "../../src/alert.php";
+$id = $_GET["id"] ?? "";
if ($id == "" || !is_numeric($id)) {
$page = intval($_GET["p"] ?? "0");
$limit = 50;
$emotes = display_list_emotes($page, $limit);
- include "../../src/emotes/multiple_page.php";
} else {
$emote = display_emote(intval($id));
- include "../../src/emotes/single_page.php";
}
+?>
+
+<html>
+
+<head>
+ <title><?php
+ echo empty($emotes) ? "Emote " . $emote->get_code() : "Emotes"
+ ?> - alright.party</title>
+ <link rel="stylesheet" href="/static/style.css">
+</head>
+
+<body>
+ <div class="container">
+ <div class="wrapper">
+ <?php html_navigation_bar() ?>
+
+ <section class="content row">
+ <section class="sidebar">
+ <?php html_navigation_search() ?>
+ </section>
+ <section class="content">
+ <?php display_alert() ?>
+ <section class="box">
+ <div class="box navtab">
+ <?php echo empty($emotes) ? "Emote - " . $emote->get_code() : "Emotes" ?>
+ </div>
+ <?php
+ if (empty($emotes)) { ?>
+ <div class="box content">
+ <div class="emote-showcase">
+ <img src="/static/userdata/emotes/<?php echo $emote->get_id() . '/' . '1x.' . $emote->get_ext() ?>"
+ alt="<?php echo $emote->get_code() ?>">
+ <img src="/static/userdata/emotes/<?php echo $emote->get_id() . '/' . '2x.' . $emote->get_ext() ?>"
+ alt="<?php echo $emote->get_code() ?>">
+ <img src="/static/userdata/emotes/<?php echo $emote->get_id() . '/' . '3x.' . $emote->get_ext() ?>"
+ alt="<?php echo $emote->get_code() ?>">
+ </div>
+ </div>
+ </section>
+ <section class="box items row">
+ <?php if (isset($_SESSION["user_id"])) {
+ echo '' ?>
+ <div class="items row left full">
+ <?php
+ $db = new PDO(DB_URL, DB_USER, DB_PASS);
+ $added = false;
+
+ if (isset($_SESSION["user_emote_set_id"])) {
+ $stmt = $db->prepare("SELECT id FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?");
+ $stmt->execute([$_SESSION["user_emote_set_id"], $emote->get_id()]);
+ $added = $stmt->rowCount() > 0;
+ }
+
+ $db = null;
+ ?>
+ <form action="/emotes/setmanip.php" method="POST">
+ <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
+ style="display: none;">
+ <?php
+ if ($added) { ?>
+ <input type="text" name="action" value="remove" style="display: none;">
+ <button type="submit" class="red">Remove from my channel</button>
+ <?php
+ } else { ?>
+ <input type="text" name="action" value="add" style="display: none;">
+ <button type="submit" class="green">Add to my channel</button>
+ <?php
+ }
+ ?>
+ </form>
+ </div>
+ <div class="items row right full">
+ <form action="/emotes/rate.php" method="POST">
+ <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
+ style="display: none;">
+ <input type="text" name="rate" value="5" style="display:none;">
+ <button type="submit" class="transparent gem"><img src="/static/img/icons/gem.png"
+ alt="GEM!" title="IT'S A GEM!"></button>
+ </form>
+ <form action="/emotes/rate.php" method="POST">
+ <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
+ style="display: none;">
+ <input type="text" name="rate" value="1" style="display:none;">
+ <button type="submit" class="transparent coal"><img src="/static/img/icons/coal.png"
+ alt="COAL!" title="IT'S A COAL!"></button>
+ </form>
+ <a class="button red" href="/emotes/report.php?id=<?php echo $emote->get_id() ?>">Report
+ emote</a>
+ </div>
+ <?php
+ } else {
+ echo '' ?>
+ <p><a href="/account/login">Log in</a> to get additional features...</p>
+ <?php
+ }
+ ?>
+ </section>
+
+ <section class="box">
+ <table class="vertical">
+ <tr>
+ <th>Uploader</th>
+ <td><?php
+ $username = "anonymous";
+ $link = "#";
+
+ if ($emote->get_uploaded_by()) {
+ $db = new PDO(DB_URL, DB_USER, DB_PASS);
+ $stmt = $db->prepare("SELECT username FROM users WHERE id = ?");
+ $stmt->execute([$emote->get_uploaded_by()]);
+
+ if ($row = $stmt->fetch()) {
+ $username = $row["username"];
+ $link = "/users.php?id=" . $emote->get_uploaded_by();
+ }
+
+ $db = null;
+ }
+
+ echo "<a href=\"$link\">";
+ echo $username;
+ echo "</a>";
+
+ echo ', <span title="';
+ echo date("M d, Y H:i:s", $emote->get_created_at());
+ echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago</span>";
+ ?></td>
+ </tr>
+ <tr>
+ <th>Rating</th>
+ <td>Not rated</td>
+ </tr>
+ </table>
+ </section>
+
+ <section class="box">
+ <div class="content">
+ <?php
+ $db = new PDO(DB_URL, DB_USER, DB_PASS);
+ $stmt = $db->prepare("SELECT users.id, users.username
+ FROM users
+ INNER JOIN emote_sets AS es ON es.owner_id = users.id
+ INNER JOIN emote_set_contents AS ec ON ec.emote_set_id = es.id
+ WHERE ec.emote_id = ?");
+
+ $stmt->execute([$emote->get_id()]);
+ $count = $stmt->rowCount();
+
+ $db = null;
+
+ if ($count > 0) {
+ echo "<p>Added in $count channels</p>";
+ } else {
+ echo "No one has added this emote yet... :'(";
+ }
+ ?>
+ <div class="items row">
+ <?php
+ while ($row = $stmt->fetch()) {
+ echo '<a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a>';
+ }
+ ?>
+ </div>
+ </div>
+ <?php
+ } else { ?>
+ <div class="box content items">
+ <?php
+ foreach ($emotes as $e) {
+ echo '<a class="box emote" href="emotes?id=' . $e->get_id() . '">';
+
+ if ($e->is_added_by_user()) {
+ echo '<img src="/static/img/icons/yes.png" class="emote-check" />';
+ }
+
+ echo '<img src="/static/userdata/emotes/' . $e->get_id() . '/2x.' . $e->get_ext() . '" alt="' . $e->get_code() . '"/>';
+ echo '<p>' . $e->get_code() . '</p>';
+ echo '</a>';
+ }
+ ?>
+ </div>
+ <?php
+ }
+ ?>
+ </section>
+ </section>
+ </section>
+ </div>
+ </div>
+</body>
+
+</html> \ No newline at end of file
diff --git a/public/emotes/setmanip.php b/public/emotes/setmanip.php
index 2c5d577..b5796c7 100644
--- a/public/emotes/setmanip.php
+++ b/public/emotes/setmanip.php
@@ -8,7 +8,7 @@ if (!authorize_user(true)) {
}
if (!isset($_POST["id"], $_POST["action"])) {
- generate_alert("/emotes/$emote_id", "Not enough POST fields");
+ generate_alert("/emotes", "Not enough POST fields");
exit;
}
@@ -19,7 +19,7 @@ $emote_id = $_POST["id"];
$stmt = $db->prepare("SELECT id FROM emotes WHERE id = ?");
$stmt->execute([$emote_id]);
if ($stmt->rowCount() == 0) {
- generate_alert("/emotes/$emote_id", "Emote not found", 404);
+ generate_alert("/emotes", "Emote not found", 404);
exit;
}
@@ -39,7 +39,7 @@ if ($row = $stmt->fetch()) {
if ($stmt->rowCount() == 0) {
$_SESSION["user_emote_set_id"] = "";
- generate_alert("/emotes/$emote_id", "Bad ownership permissions on active emoteset", 403);
+ generate_alert("/emotes?id=$emote_id", "Bad ownership permissions on active emoteset", 403);
exit;
}
}
@@ -63,7 +63,7 @@ $action = $_POST["action"];
if ($action == "add") {
if ($stmt->rowCount() != 0) {
- generate_alert("/emotes/$emote_id", "This emote has been already added!");
+ generate_alert("/emotes?id=$emote_id", "This emote has been already added!");
exit;
}
@@ -72,18 +72,18 @@ if ($action == "add") {
$db = null;
- generate_alert("/emotes/$emote_id", "This emote has been added to your set. Enjoy!", 200);
+ generate_alert("/emotes?id=$emote_id", "This emote has been added to your set. Enjoy!", 200);
} else {
if ($row = $stmt->fetch()) {
$stmt = $db->prepare("DELETE FROM emote_set_contents WHERE id = ?");
$stmt->execute([$row["id"]]);
} else {
- generate_alert("/emotes/$emote_id", "This emote wasn't added!");
+ generate_alert("/emotes?id=$emote_id", "This emote wasn't added!");
$db = null;
exit;
}
$db = null;
- generate_alert("/emotes/$emote_id", "This emote has been removed from your set.", 200);
+ generate_alert("/emotes?id=$emote_id", "This emote has been removed from your set.", 200);
} \ No newline at end of file
diff --git a/public/emotes/upload.php b/public/emotes/upload.php
index ad581ca..44d9161 100644
--- a/public/emotes/upload.php
+++ b/public/emotes/upload.php
@@ -127,7 +127,7 @@ if (isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/js
exit;
}
-header("Location: /emotes/$id", true, 307);
+header("Location: /emotes?id=$id", true, 307);
function echo_upload_page()
{
diff --git a/public/users.php b/public/users.php
index fae1e70..fdcbacf 100644
--- a/public/users.php
+++ b/public/users.php
@@ -308,7 +308,7 @@ if ($is_json) {
echo '<tr>';
echo '<th><img src="/static/img/icons/heart.png"> Favorite emote</th>';
echo '<td>';
- echo "<a href=\"/emotes/$fav_emote\">";
+ echo "<a href=\"/emotes?id=$fav_emote\">";
echo $row["code"] . ' <img src="/static/userdata/emotes/' . $fav_emote . '/1x.' . $row["ext"] . '" width="16" height="16">';
echo '</a></td></tr>';
}
diff --git a/src/alert.php b/src/alert.php
index 62f1887..62045d5 100644
--- a/src/alert.php
+++ b/src/alert.php
@@ -10,7 +10,7 @@ function generate_alert(string $path, string $error, int $status = 400)
"data" => null
]);
} else {
- header("Location: $path?error_status=$status&error_reason=$error");
+ header("Location: $path" . (str_contains($path, "?") ? "&" : "?") . "error_status=$status&error_reason=$error");
}
}
diff --git a/src/emotes/multiple_page.php b/src/emotes/multiple_page.php
deleted file mode 100644
index 25c4c9c..0000000
--- a/src/emotes/multiple_page.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<html>
-
-<head>
- <title>AlrightTV</title>
- <link rel="stylesheet" href="/static/style.css">
-</head>
-
-<body>
- <div class="container">
- <div class="wrapper">
- <?php html_navigation_bar(); ?>
- <main class="page">
- <section class="sidebar">
- <?php html_navigation_search(); ?>
- </section>
- <section class="content">
- <section class="box">
- <div class="box navtab">
- <?php echo isset($emotes) ? "Emotes" : "Emote" ?>
- </div>
- <div class="box content items">
- <?php
- if (isset($emotes)) {
- foreach ($emotes as $e) {
- echo "<a class=\"box emote\" href=\"/emotes/" . $e->get_id() . "\">";
-
- if ($e->is_added_by_user()) {
- echo '<img src="/static/img/icons/yes.png" class="emote-check" />';
- }
-
- echo "<img src=\"/static/userdata/emotes/" . $e->get_id() . "/2x." . $e->get_ext() . "\" alt=\"" . $e->get_code() . "\"/>";
- echo "<p>" . $e->get_code() . "</p>";
- echo "</a>";
- }
- } else {
- // info
- echo "";
- }
- ?>
- </div>
- </section>
- </section>
- </main>
- </div>
- </div>
-</body>
-
-</html> \ No newline at end of file
diff --git a/src/emotes/single_page.php b/src/emotes/single_page.php
deleted file mode 100644
index d1fc4e8..0000000
--- a/src/emotes/single_page.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-include_once "../../src/config.php";
-?>
-<html>
-
-<head>
- <title>AlrightTV</title>
- <link rel="stylesheet" href="/static/style.css">
-</head>
-
-<body>
- <div class="container">
- <div class="wrapper">
- <?php html_navigation_bar(); ?>
- <main class="page">
- <section class="sidebar">
- <?php html_navigation_search(); ?>
- </section>
- <section class="content">
- <?php display_alert() ?>
- <section class="box">
- <div class="box navtab">
- Emote - <?php echo $emote->get_code() ?>
- </div>
- <div class="box content">
- <div class="emote-showcase">
- <img src="<?php echo '/static/userdata/emotes/' . $emote->get_id() . '/' . '1x.' . $emote->get_ext() ?>"
- alt="<?php echo $emote->get_code() ?>">
- <img src="<?php echo '/static/userdata/emotes/' . $emote->get_id() . '/' . '2x.' . $emote->get_ext() ?>"
- alt="<?php echo $emote->get_code() ?>">
- <img src="<?php echo '/static/userdata/emotes/' . $emote->get_id() . '/' . '3x.' . $emote->get_ext() ?>"
- alt="<?php echo $emote->get_code() ?>">
- </div>
- </div>
- </section>
-
- <section class="box items row">
- <?php if (isset($_SESSION["user_id"])) {
- echo '' ?>
- <div class="items row left full">
- <?php
- $db = new PDO(DB_URL, DB_USER, DB_PASS);
- $added = false;
-
- if (isset($_SESSION["user_emote_set_id"])) {
- $stmt = $db->prepare("SELECT id FROM emote_set_contents WHERE emote_set_id = ? AND emote_id = ?");
- $stmt->execute([$_SESSION["user_emote_set_id"], $emote->get_id()]);
- $added = $stmt->rowCount() > 0;
- }
-
- $db = null;
- ?>
- <form action="/emotes/setmanip.php" method="POST">
- <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
- style="display: none;">
- <?php
- if ($added) { ?>
- <input type="text" name="action" value="remove" style="display: none;">
- <button type="submit" class="red">Remove from my channel</button>
- <?php
- } else { ?>
- <input type="text" name="action" value="add" style="display: none;">
- <button type="submit" class="green">Add to my channel</button>
- <?php
- }
- ?>
- </form>
- </div>
- <div class="items row right full">
- <form action="/emotes/rate.php" method="POST">
- <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
- style="display: none;">
- <input type="text" name="rate" value="5" style="display:none;">
- <button type="submit" class="transparent gem"><img src="/static/img/icons/gem.png"
- alt="GEM!" title="IT'S A GEM!"></button>
- </form>
- <form action="/emotes/rate.php" method="POST">
- <input type="text" name="id" value="<?php echo $emote->get_id() ?>"
- style="display: none;">
- <input type="text" name="rate" value="1" style="display:none;">
- <button type="submit" class="transparent coal"><img src="/static/img/icons/coal.png"
- alt="COAL!" title="IT'S A COAL!"></button>
- </form>
- <a class="button red" href="/emotes/report.php?id=<?php echo $emote->get_id() ?>">Report
- emote</a>
- </div>
- <?php
- } else {
- echo '' ?>
- <p><a href="/account/login">Log in</a> to get additional features...</p>
- <?php
- }
- ?>
- </section>
-
- <section class="box">
- <table class="vertical">
- <tr>
- <th>Uploader</th>
- <td><?php
- $username = "anonymous";
- $link = "#";
-
- if ($emote->get_uploaded_by()) {
- $db = new PDO(DB_URL, DB_USER, DB_PASS);
- $stmt = $db->prepare("SELECT username FROM users WHERE id = ?");
- $stmt->execute([$emote->get_uploaded_by()]);
-
- if ($row = $stmt->fetch()) {
- $username = $row["username"];
- $link = "/users.php?id=" . $emote->get_uploaded_by();
- }
-
- $db = null;
- }
-
- echo "<a href=\"$link\">";
- echo $username;
- echo "</a>";
-
- echo ', <span title="';
- echo date("M d, Y H:i:s", $emote->get_created_at());
- echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago</span>";
- ?></td>
- </tr>
- <tr>
- <th>Rating</th>
- <td>Not rated</td>
- </tr>
- </table>
- </section>
-
- <section class="box">
- <div class="content">
- <?php
- $db = new PDO(DB_URL, DB_USER, DB_PASS);
- $stmt = $db->prepare("SELECT users.id, users.username
- FROM users
- INNER JOIN emote_sets AS es ON es.owner_id = users.id
- INNER JOIN emote_set_contents AS ec ON ec.emote_set_id = es.id
- WHERE ec.emote_id = ?");
-
- $stmt->execute([$emote->get_id()]);
- $count = $stmt->rowCount();
-
- $db = null;
-
- if ($count > 0) {
- echo "<p>Added in $count channels</p>";
- } else {
- echo "No one has added this emote yet... :'(";
- }
- ?>
- <div class="items row">
- <?php
- while ($row = $stmt->fetch()) {
- echo '<a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a>';
- }
- ?>
- </div>
- </div>
- </section>
- </section>
- </main>
- </div>
- </div>
-</body>
-
-</html> \ No newline at end of file