8e5d1f661e1b5a8515e182690c96a8312bbcfb92
[minimedit.git] / login / visits.php
1 <?php
2 $logins = [];
3 foreach (glob('profile/*') as $userdir) {
4         $logins[] = [
5                 'login' => basename($userdir),
6                 'name' => @file_get_contents("$userdir/name.txt"),
7                 'seen' => @filemtime("$userdir/last.log"),
8                 'admin' => @file_exists("$userdir/.admin"),
9         ];
10 }
11
12 if (@$_GET['order'] == 'seen') {
13         array_multisort(array_column($logins, 'seen'), SORT_DESC, SORT_NUMERIC, $logins);
14 }
15
16 print "<ul class=cols>\n";
17 foreach ($logins as $profile) {
18         printf('<li><a href="%s">%s</a>',
19                 '/login/edit/'.$profile['login'],
20                 $profile['name'] ?: $profile['login']
21         );
22         if ($profile['seen']) {
23                 printf(' <small class="date">%s</small>', strftime('%F %H:%M', $profile['seen']));
24         }
25         if (!empty($profile['admin'])) {
26                 print ' <em>(beheerder)</em>';
27         }
28         print "</li>\n";
29 }
30 print "</ul>\n\n";