diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-25 14:10:18 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-25 14:10:18 +0500 |
| commit | c01cdba706b5253a4af0bd5448c13c2e990b9086 (patch) | |
| tree | a7081a094969c716e553890600535b91b6949a16 | |
| parent | d93351e0e5fffde6922f38d19a5848273aef6c40 (diff) | |
feat: get user by alias_id
| -rw-r--r-- | public/users.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/public/users.php b/public/users.php index f388dab..dfa259c 100644 --- a/public/users.php +++ b/public/users.php @@ -10,10 +10,11 @@ session_start(); $is_json = isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json"; $id = $_GET["id"] ?? ""; +$alias_id = $_GET["alias_id"] ?? ""; $db = new PDO(DB_URL, DB_USER, DB_PASS); -if ($id == "") { +if ($id == "" && $alias_id == "") { $page = $_GET["p"] ?? "0"; $limit = 50; $offset = $page * $limit; @@ -103,8 +104,18 @@ if ($id == "") { exit; } +$stmt = null; + +if ($id != "") { $stmt = $db->prepare("SELECT * FROM users WHERE id = ?"); -$stmt->execute([$id]); + $stmt->execute([intval($id)]); +} else if ($alias_id != "") { + $stmt = $db->prepare("SELECT u.* FROM users u + INNER JOIN connections co ON (co.alias_id = ? AND co.platform = 'twitch') + WHERE co.user_id = u.id + "); + $stmt->execute([intval($alias_id)]); +} $user = null; @@ -338,7 +349,7 @@ if ($is_json) { <?php if (!empty($emote_sets)) { foreach ($emote_sets as $set_row) { ?> - <a href="/emotesets/<?php echo $set_row["id"] ?>" class="box"> + <a href="/emotesets?id=<?php echo $set_row["id"] ?>" class="box"> <div> <?php echo '<p>' . $set_row["name"] . '</p>'; |
