diff options
Diffstat (limited to 'libs/last_login.php')
-rw-r--r-- | libs/last_login.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libs/last_login.php b/libs/last_login.php new file mode 100644 index 0000000..5a8887e --- /dev/null +++ b/libs/last_login.php @@ -0,0 +1,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);
\ No newline at end of file |