Added online users list to the frontpage.
This commit is contained in:
parent
5f1e354e91
commit
0998e5d69c
2 changed files with 28 additions and 0 deletions
|
@ -61,9 +61,23 @@ $changelog = Cache::instance()->get('index:changelog:v1', function () {
|
||||||
')->fetchAll(PDO::FETCH_ASSOC);
|
')->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}, 1800);
|
}, 1800);
|
||||||
|
|
||||||
|
$onlineUsers = Cache::instance()->get('index:online:v1', function () {
|
||||||
|
return Database::query('
|
||||||
|
SELECT
|
||||||
|
u.`user_id`, u.`username`,
|
||||||
|
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
||||||
|
FROM `msz_users` as u
|
||||||
|
LEFT JOIN `msz_roles` as r
|
||||||
|
ON r.`role_id` = u.`display_role`
|
||||||
|
WHERE u.`last_seen` >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||||
|
ORDER BY u.`last_seen` DESC
|
||||||
|
')->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}, 30);
|
||||||
|
|
||||||
echo tpl_render('home.index', [
|
echo tpl_render('home.index', [
|
||||||
'users_count' => $statistics['users'],
|
'users_count' => $statistics['users'],
|
||||||
'last_user' => $statistics['lastUser'],
|
'last_user' => $statistics['lastUser'],
|
||||||
|
'online_users' => $onlineUsers,
|
||||||
'featured_changelog' => $changelog,
|
'featured_changelog' => $changelog,
|
||||||
'featured_news' => $news,
|
'featured_news' => $news,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -20,6 +20,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="container__title">Online users</div>
|
||||||
|
<div class="container__content">
|
||||||
|
{% if online_users < 1 %}
|
||||||
|
No one was online in the last 5 minutes.
|
||||||
|
{% else %}
|
||||||
|
Online users in the last 5 minutes:<br>
|
||||||
|
{% for user in online_users %}
|
||||||
|
<a href="/profile.php?u={{ user.user_id }}" class="index__stats__emphasis index__stats__link" style="{{ user.user_colour|html_colour }}">{{ user.username }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="container__title container__title--link" href="/changelog.php">Changelog</a>
|
<a class="container__title container__title--link" href="/changelog.php">Changelog</a>
|
||||||
<div class="changelog__content">
|
<div class="changelog__content">
|
||||||
|
|
Loading…
Add table
Reference in a new issue