summaryrefslogtreecommitdiff
path: root/libs/last_login.php
blob: 20637316e7fbe607084a0936f5bf9374c2921455 (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 '../autoload.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);