prepare("SELECT id, username, joined_at, last_active_at FROM users WHERE username LIKE ? ORDER BY last_active_at DESC LIMIT ? OFFSET ?"); $stmt->bindParam(1, $search, PDO::PARAM_STR); $stmt->bindParam(2, $limit, PDO::PARAM_INT); $stmt->bindParam(3, $offset, PDO::PARAM_INT); $stmt->execute(); $all_user_count = $search ? $stmt->rowCount() : $db->query("SELECT COUNT(*) FROM users")->fetch()[0]; if ($is_json) { header("Content-Type: application/json"); echo json_encode([ "status_code" => 200, "message" => null, "data" => [ "all_user_count" => intval($all_user_count), "users" => $stmt->fetchAll(PDO::FETCH_ASSOC) ] ]); exit; } echo '' ?> User list - alright.party
rowCount() != 0) { echo ''; echo ''; echo ''; echo ''; while ($row = $stmt->fetch()) { $diff = time() - strtotime($row["last_active_at"]); $last_active = "moments"; if ($diff > 5) { $last_active = format_timestamp($diff); } echo ''; echo ''; echo ''; echo ""; echo ''; } echo '
UsernameLast active
' . $row["username"] . '$last_active ago
'; } else { echo '

Nothing found...

'; } ?>
prepare("SELECT * FROM users WHERE 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; if ($row = $stmt->fetch()) { $user = new User($row); } if ($user == null) { generate_alert("/404.php", "The user you requested cannot be found", 404); exit; } // --- EMOTE SETS --- // TODO: OPTIMIZE IT ASAP!!! $emote_sets = []; $active_emote_set = null; // gathering acquired emote sets $stmt = $db->prepare("SELECT emote_set_id, is_default FROM acquired_emote_sets WHERE user_id = ?"); $stmt->execute([$user->id()]); while ($row = $stmt->fetch()) { // getting more info about set $set_stmt = $db->prepare("SELECT id, name, size FROM emote_sets WHERE id = ?"); $set_stmt->execute([$row["emote_set_id"]]); $set = $set_stmt->fetch(); // getting info about emote set content $em_stmt = $db->prepare( "SELECT e.id, e.code, e.mime, e.ext, e.created_at, e.uploaded_by FROM emotes e INNER JOIN emote_set_contents AS esc ON esc.emote_set_id = ? WHERE esc.emote_id = e.id " . ($row["is_default"] ? '' : ' LIMIT 5') ); $em_stmt->execute([$row["emote_set_id"]]); $emote_set_emotes = $em_stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($emote_set_emotes as &$e) { if ($e["uploaded_by"]) { $uploaded_by_stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); $uploaded_by_stmt->execute([$e["uploaded_by"]]); $e["uploaded_by"] = $uploaded_by_stmt->fetch(PDO::FETCH_ASSOC); } } $emote_set = [ "id" => $set["id"], "name" => $set["name"], "size" => $set["size"], "emotes" => $emote_set_emotes ]; if ($row["is_default"]) { $active_emote_set = count($emote_sets); } array_push($emote_sets, $emote_set); } $active_emote_set = &$emote_sets[$active_emote_set]; // gathering uploaded emotes $stmt = $db->prepare("SELECT e.*, CASE WHEN EXISTS ( SELECT 1 FROM emote_set_contents ec INNER JOIN emote_sets es ON es.id = ec.emote_set_id WHERE ec.emote_id = e.id AND es.owner_id = ? ) THEN 1 ELSE 0 END AS is_in_user_set FROM emotes e WHERE e.uploaded_by = ? ORDER BY e.created_at ASC "); $stmt->execute([$user->id(), $user->id()]); $uploaded_emotes = $stmt->fetchAll(PDO::FETCH_ASSOC); // gathering actions // TODO: update it when we will have action logs $actions = []; // TODO: add functionality // calculating contributions $stmt = $db->prepare("SELECT COUNT(*) FROM emotes WHERE uploaded_by = ?"); $stmt->execute([$user->id()]); $contributions = intval($stmt->fetch()[0]); $stmt = $db->prepare("SELECT COUNT(*) FROM ratings WHERE user_id = ?"); $stmt->execute([$user->id()]); $contributions += intval($stmt->fetch()[0]); // getting status $status = "... i don't know who am i"; $stmt = $db->prepare("SELECT * FROM roles r INNER JOIN role_assigns ra ON ra.user_id = ? WHERE ra.role_id = r.id"); $stmt->execute([$user->id()]); if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $status = ''; $status .= $row["name"]; $status .= ''; } // getting reactions $stmt = $db->prepare("SELECT rate, COUNT(*) AS c FROM ratings WHERE user_id = ? GROUP BY rate ORDER BY c DESC"); $stmt->execute([$user->id()]); $fav_reactions = $stmt->fetchAll(PDO::FETCH_ASSOC); // getting favorite emote $fav_emote = 1; if ($is_json) { header("Content-type: application/json"); echo json_encode([ "status_code" => 200, "message" => null, "data" => [ "id" => intval($user->id()), "username" => $user->username(), "joined_at" => $user->joined_at(), "last_active_at" => $user->last_active_at(), "stats" => [ "status_id" => $status, "contributions" => $contributions, "favorite_reaction_id" => $fav_reaction, "favorite_emote_id" => $fav_emote ], "active_emote_set_id" => $active_emote_set["id"], "emote_sets" => $emote_sets, "uploaded_emotes" => $uploaded_emotes, "actions" => $actions ] ]); exit; } ?> <?php echo $user->username() ?> - alright.party

username() ?>

joined_at()); echo ' UTC">about ' . format_timestamp(time() - $user->joined_at()) . " ago"; ?> last_active_at(); if ($diff > 60) { echo '"; } else { echo ''; } ?> prepare("SELECT code, ext FROM emotes WHERE id = ?"); $stmt->execute([$fav_emote]); if ($row = $stmt->fetch()) { echo ''; echo ''; echo ''; } ?>
I am
Joined
Last activity last_active_at()); echo ' UTC">about ' . format_timestamp($diff) . " agoOnline
Contributions
Reactions '; } ?>
Favorite emote'; echo ""; echo $row["code"] . ' '; echo '
Send a message id() ?>">Report user'; } ?>
" class="box">
' . $set_row["name"] . '

'; if ($set_row["size"]) { echo '

' . $set_row["size"] . '

'; } ?>
'; } ?>
No emote sets found... ' . ((($_SESSION["user_id"] ?? "") == $id) ? 'Start adding emotes and you will have one! :)

' : '

'); } ?>
'; echo '' . $emote_row['; echo '

' . $emote_row["code"] . '

'; echo ''; } } else { echo '

No emotes found... ' . ((($_SESSION["user_id"] ?? "") == $id) ? 'Start adding emotes and they will appear here! :)

' : '

'); } ?>
'; echo '' . $emote_row['; echo '

' . $emote_row["code"] . '

'; echo ''; } ?>
This user has done nothing bad or good...

"; } ?>