Allow selecting the last 100 logged in users

This commit is contained in:
grandeljay 2022-06-21 08:30:17 +02:00
parent d15cca047c
commit 7840ee2cb7
2 changed files with 30 additions and 4 deletions

View file

@ -0,0 +1,5 @@
$(function() {
$('.ui.dropdown').dropdown();
});

View file

@ -13,9 +13,13 @@ $page = new Page(__FILE__, __('Login as'), 100);
if (isset($_POST['email'])) {
$email = $_POST['email'];
$user = $database->query('SELECT * FROM `users`
WHERE `email` = "' . $email . '";')
->fetch();
$user = $database
->query(
'SELECT *
FROM `users`
WHERE `email` = "' . $email . '";'
)
->fetch();
$success = false !== $user;
@ -27,6 +31,18 @@ if (isset($_POST['email'])) {
$page->header();
$page->bodyStart();
$page->navigation();
/**
* Recent users
*/
$users = $database
->query(
' SELECT *
FROM `users`
ORDER BY `last_login` DESC
LIMIT 100;'
)
->fetchAll();
?>
<main>
<div class="ui container">
@ -46,7 +62,12 @@ $page->navigation();
<form class="ui form" method="POST">
<div class="field">
<label><?= __('Email') ?></label>
<input type="email" name="email" placeholder="john.doe@domain.tld" />
<select class="ui fluid search selection dropdown" name="email">
<?php foreach ($users as $user) { ?>
<option value="<?= $user['email'] ?>"><?= $user['email'] ?></option>
<?php } ?>
</select>
</div>
<input class="ui primary button"