summaryrefslogtreecommitdiff
path: root/lib/lastlog.pm
diff options
context:
space:
mode:
authorJules Laplace <carbon@melanarchy.org>2013-08-02 17:14:41 -0500
committerJules Laplace <carbon@melanarchy.org>2013-08-02 17:14:41 -0500
commite9192b3d42660a5781101df4357d276318151e8a (patch)
tree059eb6ace6147cf9559af74ed1ab5e221c80e280 /lib/lastlog.pm
parent79670053c7247d3a49b607960efd284e93f057e5 (diff)
cgi-bin & lib
Diffstat (limited to 'lib/lastlog.pm')
-rw-r--r--lib/lastlog.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/lastlog.pm b/lib/lastlog.pm
new file mode 100644
index 0000000..94ffd99
--- /dev/null
+++ b/lib/lastlog.pm
@@ -0,0 +1,29 @@
+sub lastlog
+ {
+ my ($whoami) = @_;
+ my $lastlog_data = get_lastlog();
+ my $lastlog_text = "";
+
+ for (my $i = 0; $i < @$lastlog_data; $i++)
+ {
+ my $lastlog = $lastlog_data->[$i];
+
+ last if ($LASTLOG_ONLY_FIRST_DAY && (time - $lastlog->{lastseen}) > 86400);
+
+ $lastlog_text .= ", " if ($i > 0);
+ $lastlog_text .= message_link($lastlog->{username});
+
+ if ((time - $lastlog->{lastseen}) > 4)
+ {
+ $lastlog_text .= " [".(get_age($lastlog->{lastseen}))."]";
+ # $lastlog_text .= " $lastlog->{last_hostname}" if ($DEBUG); # ...previously kept track of host
+ }
+ }
+
+ return "$whoami->{username} [<b>now</b>]" unless (length($lastlog_text));
+
+ return $lastlog_text;
+ }
+
+1;
+