From df783376d2b3bdd8fe5e0e558fa781f40babd7f3 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 22 Apr 2025 02:56:09 +0500 Subject: feat: users --- public/index.php | 2 +- public/static/img/icons/clock.png | Bin 0 -> 882 bytes public/static/img/icons/door_in.png | Bin 0 -> 693 bytes public/static/img/icons/emoticon_happy.png | Bin 0 -> 731 bytes public/static/img/icons/heart.png | Bin 0 -> 749 bytes public/static/img/icons/star.png | Bin 0 -> 670 bytes public/static/img/icons/user.png | Bin 0 -> 741 bytes public/static/style.css | 88 ++++-- public/users.php | 418 +++++++++++++++++++++++++++++ 9 files changed, 478 insertions(+), 30 deletions(-) create mode 100644 public/static/img/icons/clock.png create mode 100644 public/static/img/icons/door_in.png create mode 100644 public/static/img/icons/emoticon_happy.png create mode 100644 public/static/img/icons/heart.png create mode 100644 public/static/img/icons/star.png create mode 100644 public/static/img/icons/user.png create mode 100644 public/users.php (limited to 'public') diff --git a/public/index.php b/public/index.php index 5619208..a9b88bd 100644 --- a/public/index.php +++ b/public/index.php @@ -15,7 +15,7 @@ include_once "../src/config.php";
Emotes - Users + Users Upload Account Chat clients diff --git a/public/static/img/icons/clock.png b/public/static/img/icons/clock.png new file mode 100644 index 0000000..e2672c2 Binary files /dev/null and b/public/static/img/icons/clock.png differ diff --git a/public/static/img/icons/door_in.png b/public/static/img/icons/door_in.png new file mode 100644 index 0000000..41676a0 Binary files /dev/null and b/public/static/img/icons/door_in.png differ diff --git a/public/static/img/icons/emoticon_happy.png b/public/static/img/icons/emoticon_happy.png new file mode 100644 index 0000000..6b7336e Binary files /dev/null and b/public/static/img/icons/emoticon_happy.png differ diff --git a/public/static/img/icons/heart.png b/public/static/img/icons/heart.png new file mode 100644 index 0000000..d9ee53e Binary files /dev/null and b/public/static/img/icons/heart.png differ diff --git a/public/static/img/icons/star.png b/public/static/img/icons/star.png new file mode 100644 index 0000000..b88c857 Binary files /dev/null and b/public/static/img/icons/star.png differ diff --git a/public/static/img/icons/user.png b/public/static/img/icons/user.png new file mode 100644 index 0000000..79f35cc Binary files /dev/null and b/public/static/img/icons/user.png differ diff --git a/public/static/style.css b/public/static/style.css index 86013be..cb9a996 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -1,11 +1,14 @@ :root { - --background-color: #d7dfcd; + --background-color: #c4d1b5; --background-color-hover: #e4eed8; --background-color-disabled: #bec6b3; - --border-color: #b0b9a5; + --border-color: #95a186; - --foreground-color: #7f9c3c; - --foreground-color-hover: #4b5632; + --background-color-2: #cfdfbd; + --border-color-2: #849275; + + --foreground-color: #425514; + --foreground-color-hover: #1c220c; } * { @@ -15,14 +18,34 @@ font-family: Arial, Helvetica, sans-serif; } +h1 { + font-size: 26px; +} + +h2 { + font-size: 20px; +} + +h3 { + font-size: 16px; +} + div { display: unset; } +table { + text-align: left; +} + table.vertical th { text-align: right; } +table.vertical.left th { + text-align: left; +} + table.vertical th, table.vertical td { padding: 2px; @@ -50,9 +73,6 @@ form { gap: 4px; } -.row { - flex-direction: row; -} .container { width: 100%; @@ -66,7 +86,7 @@ form { flex-direction: column; } -section.content { +.content { flex-grow: 1; display: flex; flex-direction: column; @@ -79,15 +99,6 @@ section.content { flex-direction: row; } -.big-gap { - gap: 32px; -} - -.center { - justify-content: center; - align-items: center; -} - /** ------------ COUNTER @@ -236,12 +247,6 @@ button.purple:hover, flex-grow: 1; } -.row { - display: flex; - flex-direction: row; - align-items: center; -} - .right { justify-content: flex-end; } @@ -282,6 +287,16 @@ button.purple:hover, padding: 16px; } +.box .content .box { + background: var(--background-color-2); + border-color: var(--border-color-2); +} + +.box .content a.box:hover { + background: linear-gradient(0deg, var(--background-color-hover), var(--background-color-2)); + cursor: pointer; +} + .box hr { border-color: var(--border-color); border-width: 1px; @@ -358,14 +373,29 @@ a.box:hover { gap: 16px; } -.accman h1 { - font-size: 26px; +.row { + display: flex; + flex-direction: row; } -.accman h2 { - font-size: 20px; +.column { + display: flex; + flex-direction: column; } -.accman h3 { - font-size: 16px; +.flex { + flex-grow: 1; +} + +.small-gap { + gap: 8px; +} + +.big-gap { + gap: 32px; +} + +.center { + justify-content: center; + align-items: center; } \ No newline at end of file diff --git a/public/users.php b/public/users.php new file mode 100644 index 0000000..73f1d54 --- /dev/null +++ b/public/users.php @@ -0,0 +1,418 @@ +prepare("SELECT id, username, joined_at, last_active_at FROM users ORDER BY last_active_at DESC LIMIT ? OFFSET ?"); + $stmt->bindParam(1, $limit, PDO::PARAM_INT); + $stmt->bindParam(2, $offset, PDO::PARAM_INT); + $stmt->execute(); + + $all_user_count = $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 = $stmt->fetch()[0]; + +// getting status +$status = 1; + +// getting favorite reaction +$fav_reaction = 1; + +// 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 activitylast_active_at()); + echo ' UTC">about ' . format_timestamp($diff) . " agoOnline
Contributed emotes
Favorite reaction + '; + } else { + echo 'Coal '; + } + ?> +
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...

"; + } + ?> +
+
+
+
+
+
+ + + \ No newline at end of file -- cgit v1.2.3