summaryrefslogtreecommitdiff
path: root/lib/lastlog.pm
blob: 94ffd99b929d51a9db0c1542962957cd4abe9ed1 (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
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;