summaryrefslogtreecommitdiff
path: root/libs/last_login.php
blob: e93bbf893be379b0f273ec649a07f5dac83dc1a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require 'Utils/Config.class.php';
$Config = new Config();


$datas = array();

if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1";"$5, $4, $8, $6}\'', $users)))
{
    $datas[] = array(
        'user' => 'N.A',
        'date' => 'N.A',
    );
}
else
{
    $max = $Config->get('last_login:max');

    for ($i = 1; $i < count($users) && $i <= $max; $i++)
    {
        list($user, $date) = explode(';', $users[$i]);

        $datas[] = array(
            'user' => $user,
            'date' => $date,
        );
    }
}

echo json_encode($datas);