(obj1.className=="itemshown") ? obj1.className="itemhidden" : obj1.className="itemshown";
(obj1.className=="itemshown") ? obj2.innerHTML="<img border='0' src='images/open.gif' alt='[–]'>" : obj2.innerHTML="<img border='0' src='images/closed.gif' alt='[+]'>";
}
+
+// Show the logs for the current module in the right
+function show_logs() {
+ var url = ''+window.parent.frames[1].location;
+ var sl1 = url.indexOf('//');
+ var mod = '';
+ if (sl1 > 0) {
+ var sl2 = url.indexOf('/', sl1+2);
+ if (sl2 > 0) {
+ var sl3 = url.indexOf('/', sl2+1);
+ if (sl3 > 0) {
+ mod = url.substring(sl2+1, sl3);
+ } else {
+ mod = url.substring(sl2+1);
+ }
+ }
+ }
+if (mod) {
+ window.parent.frames[1].location = 'webminlog/search.cgi?tall=4&uall=1&fall=1&module='+mod;
+ }
+else {
+ alert('No Webmin module is selected to show logs for');
+ }
+}
</script>
</head>
<body>
print "<div class='leftlink'><hr></div>\n";
+# Show current module's log search, if logging
+if ($gconfig{'log'} && &foreign_available("webminlog")) {
+ print "<div class='linkwithicon'><img src=images/logs.gif>\n";
+ print "<div class='aftericon'><a target=right href='webminlog/' onClick='show_logs(); return false;'>$text{'left_logs'}</a></div></div>\n";
+ }
+
# Show info link
print "<div class='linkwithicon'><img src=images/gohome.gif>\n";
print "<div class='aftericon'><a target=right href='right.cgi?open=system&open=status'>$text{'left_home'}</a></div></div>\n";
print &text('index_nologfiles', '/webmin/edit_log.cgi'),"<p>\n";
}
-print "<form action=search.cgi>\n";
-print "<table border>\n";
-print "<tr $tb> <td><b>$text{'index_header'}</b></td> </tr>\n";
-print "<tr $cb> <td>\n";
+print &ui_form_start("search.cgi");
+print &ui_table_start($text{'index_header'}, undef, 2);
@ulist = sort { $a->{'name'} cmp $b->{'name'} } &acl::list_users();
@canulist = grep { &can_user($_->{'name'}) } @ulist;
}
else {
# Show user selectors
- print &ui_radio("uall", 1, [ [ 1, $text{'index_uall'}."<br>" ],
- [ 0, $text{'index_user'} ] ]),"\n";
- print "<select name=user>\n";
- foreach $u (@ulist) {
- next if (!&can_user($u->{'name'}));
- print "<option>$u->{'name'}\n";
- }
- print "</select><br>\n";
+ @unames = grep { &can_user($_) } map { $_->{'name'} } @ulist;
+ @opts = ( [ 1, $text{'index_uall'}."<br>" ],
+ [ 0, $text{'index_user'}." ".
+ &ui_select("user", undef, \@unames)."<br>" ] );
if ($access_users{'*'}) {
- print "<input name=uall type=radio value=2> $text{'index_nuser'}\n";
- print "<select name=nuser>\n";
- foreach $u (@ulist) {
- print "<option>$u->{'name'}\n";
- }
- print "</select>\n";
+ push(@opts, [ 2, $text{'index_nuser'}." ".
+ &ui_select("nuser", undef, \@unames) ]);
}
- print "<p>\n";
+ print &ui_table_row($text{'index_susers'},
+ &ui_radio("uall", 1, \@opts));
}
-print "<input name=mall type=radio value=1 checked> $text{'index_mall'}<br>\n";
-print "<input name=mall type=radio value=0> $text{'index_module'}\n";
-print "<select name=module>\n";
+# Modules to search
foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos()) {
next if (!&can_mod($m->{'dir'}));
$mdir = &module_root_directory($m->{'dir'});
- print "<option value=$m->{'dir'}>$m->{'desc'}\n"
- if (-r "$mdir/log_parser.pl" &&
- &check_os_support($m));
+ if (-r "$mdir/log_parser.pl" && &check_os_support($m)) {
+ push(@mods, [ $m->{'dir'}, $m->{'desc'} ]);
+ }
}
-print "</select><p>\n";
+@opts = ( [ 1, $text{'index_mall'}."<br>" ],
+ [ 0, $text{'index_module'}." ".
+ &ui_select("module", $in{'module'}, \@mods) ] );
+print &ui_table_row($text{'index_smods'},
+ &ui_radio("mall", 1, \@opts));
-print "<input name=tall type=radio value=1> $text{'index_tall'}<br>\n";
-print "<input name=tall type=radio value=2 checked> $text{'index_today'}<br>\n";
-print "<input name=tall type=radio value=3> $text{'index_yesterday'}<br>\n";
-print "<input name=tall type=radio value=0>\n";
-print &text('index_time', &time_input('from'), &time_input('to')),"<p>\n";
+# Dates to search
+print &ui_table_row($text{'index_stimes'},
+ &ui_radio("tall", 2,
+ [ [ 1, $text{'index_tall'}."<br>" ],
+ [ 2, $text{'index_today'}."<br>" ],
+ [ 3, $text{'index_yesterday'}."<br>" ],
+ [ 4, $text{'index_week'}."<br>" ],
+ [ 0, &text('index_time', &time_input('from'),
+ &time_input('to')) ] ]));
+# Search modified files
if ($gconfig{'logfiles'}) {
- print "<input name=fall type=radio value=1 checked> $text{'index_fall'}<br>\n";
- print "<input name=fall type=radio value=0> $text{'index_file'}\n";
- print "<input name=file size=30><p>\n";
+ print &ui_table_row($text{'index_sfile'},
+ &ui_radio("fall", 1,
+ [ [ 1, $text{'index_fall'}."<br>" ],
+ [ 0, $text{'index_file'}." ".
+ &ui_textbox("file", undef, 40) ] ]));
}
+# Remote host
if ($config{'host_search'}) {
- print "<input name=wall type=radio value=1 checked> $text{'index_wall'}<br>\n";
- print "<input name=wall type=radio value=0> $text{'index_whost'}\n";
- print "<input name=webmin size=30><p>\n";
+ print &ui_table_row($text{'index_shost'},
+ &ui_radio("wall", 1,
+ [ [ 1, $text{'index_wall'}."<br>" ],
+ [ 0, $text{'index_whost'}." ".
+ &ui_textbox("webmin", undef, 30) ] ]));
}
-print "<div align=right>\n";
-print "<input type=submit value='$text{'index_search'}'></div>\n";
-print "</td> </tr></table>\n";
-print "</form>\n";
+print &ui_table_end();
+print &ui_form_end([ [ undef, $text{'index_search'} ] ]);
&ui_print_footer("/", $text{'index'});
# Parse entered time ranges
if ($in{'tall'} == 2) {
+ # Today
@now = localtime(time());
$from = timelocal(0, 0, 0, $now[3], $now[4], $now[5]);
$to = timelocal(59, 59, 23, $now[3], $now[4], $now[5]);
$in{'tall'} = 0;
}
elsif ($in{'tall'} == 3) {
+ # Yesterday
@now = localtime(time()-24*60*60);
$from = timelocal(0, 0, 0, $now[3], $now[4], $now[5]);
$to = timelocal(59, 59, 23, $now[3], $now[4], $now[5]);
$in{'tall'} = 0;
}
+elsif ($in{'tall'} == 4) {
+ # Over the last week
+ @week = localtime(time()-7*24*60*60);
+ $from = timelocal(0, 0, 0, $week[3], $week[4], $week[5]);
+ $to = time();
+ $in{'tall'} = 0;
+ }
elsif ($in{'tall'} == 0) {
+ # Some time range
$from = &parse_time('from');
$to = &parse_time('to');
$to = $to ? $to + 24*60*60 - 1 : time();