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(); $count_stmt = $db->prepare("SELECT COUNT(*) FROM users WHERE username LIKE ?"); $count_stmt->execute([$search]); $total_users = $count_stmt->fetch()[0]; $total_pages = ceil($total_users / $limit); 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 - <?= CONFIG['instance']['name'] ?>
'; echo ''; echo 'UsernameLast active'; 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 '' . $row["username"] . ''; echo "$last_active ago"; echo ''; } echo ''; } else { echo '

Nothing found...

'; } ?>
1) { echo '' ?>
prepare("SELECT u.id FROM users u INNER JOIN connections co ON co.alias_id = ? AND co.platform = ? WHERE co.user_id = u.id "); $stmt->execute([$alias_id, $platform]); if ($row = $stmt->fetch()) { $user = User::get_user_by_id($db, $row["id"]); } } // fetching user by internal id else if (isset($_GET["id"])) { $user = User::get_user_by_id($db, $_GET["id"]); } if (!$user) { generate_alert("/404.php", "The user you requested cannot be found", 404); exit; } // User preferences $stmt = $db->prepare("SELECT * FROM user_preferences WHERE id = ?"); $stmt->execute([$user->id]); $user_preferences = $stmt->fetch(PDO::FETCH_ASSOC); $public_profile = !$user_preferences["private_profile"] || $user->id == ($_SESSION["user_id"] ?? ""); // fetching emote sets $emote_sets = Emoteset::get_all_user_emotesets($db, $user->id); $active_emote_set = null; foreach ($emote_sets as $es) { if ($es->is_default) { $active_emote_set = $es; break; } } // gathering uploaded emotes $uploaded_emotes = []; if ($public_profile) { $stmt = $db->prepare("SELECT e.id, e.code, e.uploaded_by, e.source, e.visibility FROM emotes e WHERE e.uploaded_by = ? ORDER BY e.created_at ASC "); $stmt->execute([$user->id]); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { array_push($uploaded_emotes, Emote::from_array_with_user($row, $db)); } } // gathering actions $actions = []; if ($public_profile) { $stmt = $db->prepare("SELECT a.* FROM actions a WHERE a.user_id = ? ORDER BY a.created_at DESC LIMIT 15"); $stmt->execute([$user->id]); $actions = $stmt->fetchAll(PDO::FETCH_ASSOC); } // 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 $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]); $role = $stmt->fetch(PDO::FETCH_ASSOC) ?? null; // 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; // getting custom badge $stmt = $db->prepare("SELECT b.* FROM badges b INNER JOIN user_badges ub ON ub.user_id = ? WHERE b.id = ub.badge_id "); $stmt->execute([$user->id]); $custom_badge = null; if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $custom_badge = $row; } if ($is_json) { $user_data = (array) $user; unset($user_data["private_profile"]); $user_data["stats"] = [ "contributions" => $contributions, "favorite_reaction_id" => $fav_reactions, "favorite_emote_id" => $fav_emote ]; $user_data["active_emote_set_id"] = $active_emote_set->id; $user_data["emote_sets"] = $emote_sets; $user_data["uploaded_emotes"] = $uploaded_emotes; $user_data["actions"] = $actions; json_response([ "status_code" => 200, "message" => null, "data" => $user_data ]); exit; } ?> <?= sprintf("%s - %s", $user->username, CONFIG['instance']['name']) ?>
emotes)) { html_display_emotes($active_emote_set->emotes); } else { echo '

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

' : '

'); } } else { echo "

This user doesn't have active emote set.

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

' : '

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

"; } foreach ($actions as $action) { echo '
'; list($action_name, $preposition, $icon_name) = match ($action["action_type"]) { "EMOTESET_ADD" => ["added", "to", "yes.png"], "EMOTESET_REMOVE" => ["removed", "from", "no.png"], "EMOTESET_ALIAS" => ["renamed", "in", "pencil.png"], "EMOTE_CREATE" => ["created", null, "new_emote.png"], "EMOTE_DELETE" => ["deleted", null, "deleted_emote.png"], "EMOTE_RENAME" => ["renamed", null, "renamed_emote.png"] }; echo "
"; echo '
'; echo '

'; echo '' . $user->username . ' '; $payload = json_decode($action["action_payload"], true); list($action_root, $action_sub) = explode("_", $action["action_type"]); switch ($action_root) { case "EMOTESET": { $e_stmt = $db->prepare("SELECT COUNT(*) FROM emotes WHERE id = ?"); $e_stmt->execute([$payload["emote"]["id"]]); echo "$action_name emote rowCount() == 1) { echo '/emotes?id=' . $payload["emote"]["id"] . '">'; echo ' '; } else { echo '">'; } if (isset($payload["emote"]["original_code"])) { echo $payload["emote"]["original_code"] . ' to '; echo "rowCount() == 1) { echo '/emotes?id=' . $payload["emote"]["id"] . '">'; echo ' '; } else { echo '">'; } echo $payload["emote"]["code"] . ''; } else { echo $payload["emote"]["code"] . ''; } $es_stmt = $db->prepare("SELECT COUNT(*) FROM emote_sets WHERE id = ?"); $es_stmt->execute([$payload["emoteset"]["id"]]); echo " $preposition rowCount() == 1) { echo '/emotesets/?id=' . $payload["emoteset"]["id"]; } echo '">' . $payload["emoteset"]["name"] . ''; break; } case "EMOTE": { $e_stmt = $db->prepare("SELECT COUNT(*) FROM emotes WHERE id = ?"); $e_stmt->execute([$payload["emote"]["id"]]); echo "$action_name emote rowCount() == 1) { echo '/emotes?id=' . $payload["emote"]["id"] . '">'; echo ' '; } else { echo '">'; } echo $payload["emote"]["code"] . ''; break; } default: { echo "something that we don't know"; break; } } echo '

'; echo '[' . format_timestamp(time() - strtotime($action["created_at"])) . ' ago] '; echo '
'; } ?>