Handle hostnames with upper-case letters
[webmin.git] / webminlog / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display logging search form
4
5 use strict;
6 use warnings;
7 require './webminlog-lib.pl';
8 our (%text, %gconfig, %access_users, %in, %config);
9 &foreign_require("acl", "acl-lib.pl");
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
11
12 if (!$gconfig{'log'}) {
13         print &text('index_nolog', '/webmin/edit_log.cgi'),"<p>\n";
14         }
15 elsif (!$gconfig{'logfiles'}) {
16         print &text('index_nologfiles', '/webmin/edit_log.cgi'),"<p>\n";
17         }
18
19 print &ui_form_start("search.cgi");
20 print &ui_table_start($text{'index_header'}, undef, 2);
21
22 my @ulist = sort { $a->{'name'} cmp $b->{'name'} } &acl::list_users();
23 my @canulist = grep { &can_user($_->{'name'}) } @ulist;
24 if (@canulist == 1) {
25         # Can only show one user, so skip this field
26         print &ui_hidden("uall", 1),"\n";
27         }
28 else {
29         # Show user selectors
30         my @unames = grep { &can_user($_) } map { $_->{'name'} } @ulist;
31         my @opts = ( [ 1, $text{'index_uall'}."<br>" ],
32                      [ 0, $text{'index_user'}." ".
33                        &ui_select("user", undef, \@unames)."<br>" ] );
34         if ($access_users{'*'}) {
35                 push(@opts, [ 2, $text{'index_nuser'}." ".
36                                  &ui_select("nuser", undef, \@unames)."<br>" ]);
37                 push(@opts, [ 3, $text{'index_ouser'}." ".
38                                  &ui_textbox("ouser", undef, 20) ]);
39                 }
40         print &ui_table_row($text{'index_susers'},
41                             &ui_radio("uall", 1, \@opts));
42         }
43
44 # Modules to search
45 my @mods;
46 if (&can_mod("global")) {
47         push(@mods, [ "global", $text{'index_global'} ]);
48         }
49 foreach my $m (sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos()) {
50         next if (!&can_mod($m->{'dir'}));
51         my $mdir = &module_root_directory($m->{'dir'});
52         if (-r "$mdir/log_parser.pl" && &check_os_support($m)) {
53                 push(@mods, [ $m->{'dir'}, $m->{'desc'} ]);
54                 }
55         }
56 my @opts = ( [ 1, $text{'index_mall'}."<br>" ],
57              [ 0, $text{'index_module'}." ".
58                &ui_select("module", $in{'module'}, \@mods) ] );
59 print &ui_table_row($text{'index_smods'},
60                     &ui_radio("mall", 1, \@opts));
61
62 # Dates to search
63 print &ui_table_row($text{'index_stimes'},
64                     &ui_radio("tall", 2,
65                         [ [ 1, $text{'index_tall'}."<br>" ],
66                           [ 2, $text{'index_today'}."<br>" ],
67                           [ 3, $text{'index_yesterday'}."<br>" ],
68                           [ 4, $text{'index_week'}."<br>" ],
69                           [ 0, &text('index_time', &time_input('from'),
70                                                    &time_input('to')) ] ]));
71
72 # Search modified files and diff contents
73 if ($gconfig{'logfiles'}) {
74         print &ui_table_row($text{'index_sfile'},
75                 &ui_radio("fall", 1,
76                           [ [ 1, $text{'index_fall'}."<br>" ],
77                             [ 0, $text{'index_file'}." ".
78                                  &ui_textbox("file", undef, 40) ] ]));
79
80         print &ui_table_row($text{'index_sdiff'},
81                 &ui_radio("dall", 1,
82                           [ [ 1, $text{'index_dall'}."<br>" ],
83                             [ 0, $text{'index_diff'}." ".
84                                  &ui_textbox("diff", undef, 40) ] ]));
85         }
86
87 # Remote host
88 if ($config{'host_search'}) {
89         print &ui_table_row($text{'index_shost'},
90                 &ui_radio("wall", 1,
91                           [ [ 1, $text{'index_wall'}."<br>" ],
92                             [ 0, $text{'index_whost'}." ".
93                                  &ui_textbox("webmin", undef, 30) ] ]));
94         }
95
96 # Show full descriptions?
97 print &ui_table_row($text{'index_long'},
98         &ui_yesno_radio("long", 0));
99
100 print &ui_table_end();
101 print &ui_form_end([ [ undef, $text{'index_search'} ] ]);
102
103 &ui_print_footer("/", $text{'index'});
104
105 sub time_input
106 {
107 my ($name) = @_;
108 return &ui_date_input(undef, undef, undef,
109                       $name."_d", $name."_m", $name."_y").
110        &date_chooser_button($name."_d", $name."_m", $name."_y");
111 }
112