Handle hostnames with upper-case letters
[webmin.git] / useradmin / list_logins.cgi
1 #!/usr/local/bin/perl
2 # list_logins.cgi
3 # Display the last login locations, tty, login time and duration
4
5 require './user-lib.pl';
6 &ReadParse();
7 if (&foreign_check("mailboxes")) {
8         &foreign_require("mailboxes");
9         }
10
11 # Work out who we can list for
12 $u = $in{'username'};
13 if (!$access{'logins'}) {
14         &error($text{'logins_elist'});
15         }
16 elsif ($access{'logins'} ne "*") {
17         $u || &error($text{'logins_elist'});
18         local @ul = split(/\s+/, $access{'logins'});
19         &indexof($u,@ul) >= 0 ||
20                 &error(&text('logins_elistu', $u));
21         }
22
23 &ui_print_header(undef, $text{'logins_title'}, "", "list_logins");
24
25 # Build the table data
26 @table = ( );
27 foreach $l (&list_last_logins($u, $config{'last_count'})) {
28         $tm = defined(&mailboxes::parse_mail_date) ?
29                 &mailboxes::parse_mail_date($l->[3]) : undef;
30         push(@table, [
31                 $u ? ( ) : ( "<tt>".&html_escape($l->[0])."</tt>" ),
32                 &html_escape($l->[2]) || $text{'logins_local'},
33                 &html_escape($l->[1]),
34                 &html_escape($tm ? &make_date($tm) : $l->[3]),
35                 $l->[4] ? ( &html_escape($l->[4]),
36                             &html_escape($l->[5]) )
37                         : ( "<i>$text{'logins_still'}</i>", "" ),
38                 ]);
39         }
40
41 # Show the table
42 if ($u) {
43         print &ui_subheading(&text('logins_head', &html_escape($u)));
44         }
45 print &ui_columns_table(
46         [ $u ? ( ) : ( $text{'user'} ), $text{'logins_from'},
47           $text{'logins_tty'}, $text{'logins_in'}, $text{'logins_out'},
48           $text{'logins_for'} ],
49         100,
50         \@table,
51         undef,
52         0,
53         undef,
54         $text{'logins_none'},
55         );
56
57 &ui_print_footer("", $text{'index_return'});
58