left_search_webmin=Search Webmin:
left_search_usermin=Search Usermin:
left_search=Search:
-left_logs=View Webmin logs
+left_logs=View Module's Logs
right_header0=System Information
right_host=System hostname
}
}
if (mod) {
- window.parent.frames[1].location = 'webminlog/search.cgi?tall=4&uall=1&fall=1&module='+mod;
+ window.parent.frames[1].location = 'webminlog/search.cgi?tall=4&uall=1&fall=1&mall=0&module='+mod;
}
else {
alert('No Webmin module is selected to show logs for');
A description of the search is now shown for searches that didn't match anything.
---- Changes since 1.350 ----
Rollback actions can themselves now be rolled back.
+---- Changes since 1.380 ----
+Re-designed the UI to use Webmin standard layout and functions.
+Added a field for searching based on the contents of commands run or file changes made.
[ 0, &text('index_time', &time_input('from'),
&time_input('to')) ] ]));
-# Search modified files
+# Search modified files and diff contents
if ($gconfig{'logfiles'}) {
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) ] ]));
+
+ print &ui_table_row($text{'index_sdiff'},
+ &ui_radio("dall", 1,
+ [ [ 1, $text{'index_dall'}."<br>" ],
+ [ 0, $text{'index_diff'}." ".
+ &ui_textbox("diff", undef, 40) ] ]));
}
# Remote host
index_susers=Actions by Webmin users
index_smods=Actions in module
index_sfile=Actions that modified file
+index_sdiff=File change or command run
+index_dall=Any change
+index_diff=Changes containing
index_stimes=Actions on dates
index_shost=Source Webmin server
view_rollback2=Roll Back Selected Files
view_return=action details
view_input=Input to command
+view_anno=Log entry annotation
acl_mods=Can view logs in modules
acl_all=All
require './webminlog-lib.pl';
&ReadParse();
-
$act = &get_action($in{'id'});
+
+if ($in{'annosave'}) {
+ # Just saving an annotation
+ $in{'anno'} =~ s/\r//g;
+ &save_annotation($act, $in{'anno'});
+ &redirect($ENV{'HTTP_REFERER'} || "view.cgi?id=$in{'id'}");
+ }
+
$access{'rollback'} || &error($text{'rollback_ecannot'});
&can_user($act->{'user'}) || &error($text{'view_ecannot'});
&can_mod($act->{'module'}) || &error($text{'view_ecannot'});
&ReadParse();
&error_setup($text{'search_err'});
+# Use sensible defaults
+$in{'tall'} = 2 if (!defined($in{'tall'}));
+$in{'uall'} = 1 if (!defined($in{'uall'}));
+$in{'mall'} = 1 if (!defined($in{'mall'}));
+$in{'fall'} = 1 if (!defined($in{'fall'}));
+$in{'dall'} = 1 if (!defined($in{'dall'}));
+
# Parse entered time ranges
if ($in{'tall'} == 2) {
# Today
next if (!$in{'wall'} && $in{'webmin'} ne $act->{'webmin'});
# Check modified files
- if ($gconfig{'logfiles'} && !$in{'fall'}) {
+ if ($gconfig{'logfiles'} && (!$in{'fall'} || !$in{'dall'})) {
# Make sure the specified file was modified
local $found = 0;
foreach $d (&list_diffs($act)) {
- if ($d->{'object'} &&
- $d->{'object'} eq $in{'file'}) {
+ local $filematch = $in{'fall'} ||
+ $d->{'object'} &&
+ $d->{'object'} eq $in{'file'};
+ local $diffmatch = $in{'dall'} ||
+ $d->{'diff'} =~ /\Q$in{'diff'}\E/i;
+ if ($filematch && $diffmatch) {
$found++;
last;
}
local @cols;
local $desc = &get_action_description($act, 0);
+ local $anno = &get_annotation($act);
push(@cols, "<a href='view.cgi?id=$act->{'id'}".
"&return=".&urlize($in{'return'}).
"&returndesc=".&urlize($in{'returndesc'}).
"'>$desc</a>");
+ if ($anno) {
+ $cols[$#cols] .= " <img src=images/star.gif>";
+ }
push(@cols, $minfo->{'desc'}, $act->{'user'}, $act->{'ip'});
if ($config{'host_search'}) {
push(@cols, $act->{'webmin'});
&ui_print_header(undef, $text{'view_title'}, "");
@files = &list_files($act);
-if (@files) {
- print &ui_form_start("rollback.cgi");
- print &ui_hidden("id", $in{'id'});
- }
+print &ui_form_start("rollback.cgi");
+print &ui_hidden("id", $in{'id'});
-print &ui_table_start(&text('view_header', $act->{'id'}),
- "width=100%", 4);
+print &ui_hidden_table_start(&text('view_header', $act->{'id'}),
+ "width=100%", 4, "main", 1);
# This "" is needed to make the label show properly!
print &ui_table_row($text{'view_action'}."",
print &ui_table_row($text{'view_host'},
$act->{'webmin'});
}
-
-print &ui_table_end(),"<p>\n";
+print &ui_hidden_table_end("main"),"<p>\n";
+
+# Annotations for this log entry
+$text = &get_annotation($act);
+print &ui_hidden_table_start($text{'view_anno'}, "width=100%", 1, "anno",
+ $text ? 1 : 0);
+print &ui_table_row(undef,
+ &ui_textarea("anno", $text, 10, 80, "auto", 0,
+ "style='width:100%'")."<br>".
+ &ui_submit($text{'save'}, "annosave"));
+print &ui_hidden_table_end("anno"),"<p>\n";
# display modified files
$rbcount = 0;
+$i = 0;
foreach $d (&list_diffs($act)) {
local $t = $text{"view_type_".$d->{'type'}};
local $rb;
$rbcount++ if ($rb);
if ($t =~ /\$2/ || !$d->{'diff'}) {
# Diff is just a single line message
- print &ui_table_start($cbox.
+ print &ui_hidden_table_start($cbox.
&text("view_type_".$d->{'type'},
"<tt>$d->{'object'}</tt>",
"<tt>".&html_escape($d->{'diff'})."</tt>"),
- "width=100%", 2);
- print &ui_table_end();
+ "width=100%", 2, "diff$i", 1);
}
else {
# Show multi-line diff
- print &ui_table_start($cbox.&text("view_type_".$d->{'type'},
- "<tt>$d->{'object'}</tt>"),
- "width=100%", 2);
+ print &ui_hidden_table_start(
+ $cbox.&text("view_type_".$d->{'type'},
+ "<tt>$d->{'object'}</tt>"),
+ "width=100%", 2, "diff$i", 1);
print &ui_table_row(undef,
"<pre>".&html_escape($d->{'diff'})."</pre>", 2);
if ($d->{'input'}) {
"<b>".&text('view_input')."</b><br>".
"<pre>".&html_escape($d->{'input'})."</pre>",2);
}
- print &ui_table_end();
}
+ print &ui_hidden_table_end("diff$i");
+ $i++;
$anydiffs++;
}
if ($rbcount) {
if (@files && $rbcount) {
print &ui_form_end([ [ "rollback", $text{'view_rollback2'} ] ]);
}
+else {
+ print &ui_form_end();
+ }
&ui_print_footer($ENV{'HTTP_REFERER'}, $text{'search_return'},
"", $text{'index_return'});
return @rv;
}
+# get_annotation(&action)
+# Returns the text of the log annotation for this action
+sub get_annotation
+{
+local ($act) = @_;
+return &read_file_contents("$ENV{'WEBMIN_VAR'}/annotations/$act->{'id'}");
+}
+
+# save_annotation(&action, text)
+# Updates the annotation for some action
+sub save_annotation
+{
+local ($act, $text) = @_;
+local $dir = "$ENV{'WEBMIN_VAR'}/annotations";
+local $file = "$dir/$act->{'id'}";
+if ($text eq '') {
+ unlink($file);
+ }
+else {
+ &make_dir($dir, 0700) if (!-d $dir);
+ &open_tempfile(ANNO, ">$file");
+ &print_tempfile(ANNO, $text);
+ &close_tempfile(ANNO);
+ }
+}
+
# expand_base_dir(base)
# Finds files either under some dir, or starting with some path
sub expand_base_dir