From c01cdba706b5253a4af0bd5448c13c2e990b9086 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 25 Apr 2025 14:10:18 +0500 Subject: feat: get user by alias_id --- public/users.php | 17 ++++++++++++++--- 1 file 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) { - " class="box"> + " class="box">
' . $set_row["name"] . '

'; -- cgit v1.2.3