+
+sub printactivelogins()
+{
+ # print active SSH logins (grep outpout of "who -s")
+ my $command = "who -s";
+ my @output = `$command`;
+ chomp(@output);
+
+ my $id = 0;
+
+ if ( scalar(@output) == 0 )
+ {
+ # no logins appeared
+ my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
+ print "<tr bgcolor='$table_colour'><td colspan='5'>$Lang::tr{'ssh no active logins'}</td></tr>\n";
+ } else {
+ # list active logins...
+
+ foreach my $line (@output)
+ {
+ my @arry = split(/\ +/, $line);
+
+ my $username = @arry[0];
+ my $logintime = join(' ', @arry[2..4]);
+ my $remoteip = @arry[5];
+ $remoteip =~ s/[()]//g;
+
+ # display more information about that IP adress...
+ my $ccode = &GeoIP::lookup($remoteip);
+ my $flag_icon = &GeoIP::get_flag_icon($ccode);
+
+ # get rDNS...
+ my $iaddr = inet_aton($remoteip);
+ my $rdns = gethostbyaddr($iaddr, AF_INET);
+ if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; };
+
+ my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
+
+ print <<END;
+ <tr bgcolor='$table_colour'>
+ <td>$username</td>
+ <td>$logintime</td>
+ <td align='center'><a href='ipinfo.cgi?ip=$remoteip'>$remoteip</a></td>
+ <td align='center'><a href='country.cgi#$ccode'><img src='$flag_icon' border='0' alt='$ccode' title='$ccode' /></a></td>
+ <td>$rdns</td>
+ </tr>
+END
+;
+ }
+ }
+}