#!/usr/local/bin/perl
# index.cgi
# Display logging search form

require './webminlog-lib.pl';
&foreign_require("acl", "acl-lib.pl");
&header($text{'index_title'}, "", undef, 0, 1);
print "<hr>\n";

if (!$gconfig{'log'}) {
	print &text('index_nolog', '/webmin/edit_log.cgi'),"<p>\n";
	}
elsif (!$gconfig{'logfiles'}) {
	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";

@ulist = &foreign_call("acl", "list_users");
print "<input name=uall type=radio value=1 checked> $text{'index_uall'}<br>\n";
print "<input name=uall type=radio value=0> $text{'index_user'}\n";
print "<select name=user>\n";
foreach $u (@ulist) {
	print "<option>$u->{'name'}\n";
	}
print "</select><br>\n";
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><p>\n";

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";
foreach $m (sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos()) {
	print "<option value=$m->{'dir'}>$m->{'desc'}\n"
		if (-r "$root_directory/$m->{'dir'}/log_parser.pl" &&
		    &check_os_support($m));
	}
print "</select><p>\n";

print "<input name=tall type=radio value=1 checked> $text{'index_tall'}<br>\n";
print "<input name=tall type=radio value=2> $text{'index_today'}<br>\n";
print "<input name=tall type=radio value=0>\n";
print &text('index_time', &time_input('from'), &time_input('to')),"<p>\n";

print "<div align=right>\n";
print "<input type=submit value='$text{'index_search'}'></div>\n";
print "</td> </tr></table>\n";
print "</form>\n";

print "<hr>\n";
&footer("/", $text{'index'});

sub time_input
{
local $rv = "<input name=$_[0]_d size=2>/";
$rv .= "<select name=$_[0]_m>";
for($i=0; $i<12; $i++) {
	$rv .= "<option value=$i>".$text{"smonth_".($i+1)}."\n";
	}
$rv .= "</select>/<input name=$_[0]_y size=4>";
$rv .= " ".&date_chooser_button("$_[0]_d", "$_[0]_m", "$_[0]_y");
return $rv;
}

