summaryrefslogtreecommitdiff
path: root/libs/last_login.php
blob: 5a8887e617dcf6c117a1c172d814a3a82c5ec34c (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
31
32
<?php
require 'Utils/Config.class.php';
$Config = new Config();


$datas = array();

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

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

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

echo json_encode($datas);