From e9192b3d42660a5781101df4357d276318151e8a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:14:41 -0500 Subject: cgi-bin & lib --- lib/lastlog.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/lastlog.pm (limited to 'lib/lastlog.pm') 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} [now]" unless (length($lastlog_text)); + + return $lastlog_text; + } + +1; + -- cgit v1.2.3-70-g09d2