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([$id]); $user = null; if ($row = $stmt->fetch()) { $user = new User($row); } if ($user == null) { header("Location: /404.php"); 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.ext 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 = [ "id" => $set["id"], "name" => $set["name"], "size" => $set["size"], "emotes" => $em_stmt->fetchAll(PDO::FETCH_ASSOC) ]; 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 = 1; // 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 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...

"; } ?>