Show page contents for logged actions
authorJamie Cameron <jcameron@webmin.com>
Sat, 6 Nov 2010 18:16:54 +0000 (11:16 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sat, 6 Nov 2010 18:16:54 +0000 (11:16 -0700)
mailboxes/folders-lib.pl
web-lib-funcs.pl
webminlog/CHANGELOG
webminlog/lang/en
webminlog/view.cgi
webminlog/webminlog-lib.pl

index 3a126eb..6cb3479 100755 (executable)
@@ -2548,7 +2548,7 @@ else {
 
 # disable_html_images(html, disable?, &urls)
 # Turn off some or all images in HTML email. Mode 0=Do nothing, 1=Offsite only,
-# 2=All images. Returns the number of images found.
+# 2=All images. Returns the URL of images found in &urls
 sub disable_html_images
 {
 local ($html, $dis, $urls) = @_;
index f5d81ed..bca753d 100755 (executable)
@@ -5239,6 +5239,7 @@ if ($miniserv::page_capture_out) {
                chmod(oct($gconfig{'logperms'}),
                      "$ENV{'WEBMIN_VAR'}/output/$id");
                }
+       $miniserv::page_capture_out = undef;
        }
 
 # Log to syslog too
@@ -5278,8 +5279,6 @@ if ($gconfig{'logsyslog'}) {
                eval { syslog("info", "%s", "[$info{'desc'}] $msg"); };
                }
        }
-
-print STDERR $miniserv::page_capture_out,"\n";
 }
 
 =head2 additional_log(type, object, data, [input])
index cd3ff04..5a73eb6 100644 (file)
@@ -24,3 +24,5 @@ Added an option to search for actions by non-Webmin users (such as those authent
 ---- Changes since 1.440 ----
 Added the list_webmin_log function, for other modules wanting to search the Webmin log.
 Converted commands in the module's API file to POD format, and added more details about each function.
+---- Changes since 1.520 ----
+Actions in Webmin which produce output (like deleting a user or creating a domain) now have that output logged, and it can be viewed on the Action Details page.
index 9133861..a1adf26 100644 (file)
@@ -82,6 +82,8 @@ view_rollback2=Roll Back Selected Files
 view_return=action details
 view_input=Input to command
 view_anno=Log entry annotation
+view_output=Webmin page contents
+view_files=Files changed and commands run
 view_raw=Raw log data
 view_rawname=Parameter name
 view_rawvalue=Parameter value
index f7ee116..392ba51 100755 (executable)
@@ -72,6 +72,19 @@ print &ui_table_row(undef,
        &ui_submit($text{'save'}, "annosave"));
 print &ui_hidden_table_end("anno");
 
+# Page output, if any
+$output = &get_action_output($act);
+if ($output && &foreign_check("mailboxes")) {
+       &foreign_require("mailboxes");
+       $output = &mailboxes::filter_javascript($output);
+       $output = &mailboxes::safe_urls($output);
+       $output = &mailboxes::disable_html_images($output, 1);
+       print &ui_hidden_table_start($text{'view_output'}, "width=100%", 1,
+                                    "output", 0);
+       print &ui_table_row(undef, $output, 2);
+       print &ui_hidden_table_end("output");
+       }
+
 # Raw log data, hidden by default
 print &ui_hidden_table_start($text{'view_raw'}, "width=100%", 1, "raw", 0);
 @tds = ( "width=20% ");
@@ -93,9 +106,10 @@ $rtable .= &ui_columns_end();
 print &ui_table_row(undef, $rtable, 2);
 print &ui_hidden_table_end("raw");
 
-# display modified files
+# display modified and commands run files
 $rbcount = 0;
 $i = 0;
+$fhtml = "";
 foreach $d (&list_diffs($act)) {
        local $t = $text{"view_type_".$d->{'type'}};
        local $rb;
@@ -108,7 +122,7 @@ foreach $d (&list_diffs($act)) {
        $rbcount++ if ($rb);
        if ($t =~ /\$2/ || !$d->{'diff'}) {
                # Diff is just a single line message
-               print &ui_hidden_table_start($cbox.
+               $fhtml .= &ui_hidden_table_start($cbox.
                      &text("view_type_".$d->{'type'},
                            "<tt>$d->{'object'}</tt>",
                            "<tt>".&html_escape($d->{'diff'})."</tt>"),
@@ -116,29 +130,31 @@ foreach $d (&list_diffs($act)) {
                }
        else {
                # Show multi-line diff
-               print &ui_hidden_table_start(
+               $fhtml .= &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,
+               $fhtml .= &ui_table_row(undef,
                        "<pre>".&html_escape($d->{'diff'})."</pre>", 2);
                if ($d->{'input'}) {
                        # And input too
-                       print &ui_table_row(undef,
+                       $fhtml .= &ui_table_row(undef,
                                "<b>".&text('view_input')."</b><br>".
                                "<pre>".&html_escape($d->{'input'})."</pre>",2);
                        }
                }
-       print &ui_hidden_table_end("diff$i");
+       $fhtml .= &ui_hidden_table_end("diff$i");
        $i++;
        $anydiffs++;
        }
 if ($rbcount) {
-       print &ui_links_row([ &select_all_link("r"),
-                             &select_invert_link("r") ]);
+       $fhtml .= &ui_links_row([ &select_all_link("r"),
+                                 &select_invert_link("r") ]);
        }
-
-print "<b>$text{'view_nofiles'}</b><p>\n" if (!$anydiffs);
+print &ui_hidden_table_start($text{'view_files'}, "width=100%", 1, "files", 0);
+$fhtml .= "<b>$text{'view_nofiles'}</b><p>\n" if (!$anydiffs);
+print &ui_table_row(undef, $fhtml, 2);
+print &ui_hidden_table_end("raw");
 
 # Show rollback button
 if (@files && $rbcount) {
index 2151ede..2c7885c 100755 (executable)
@@ -246,6 +246,17 @@ else {
        }
 }
 
+=head2 get_action_output(&action)
+
+Returns the text of the page that generated this action, or undef if none.
+
+=cut
+sub get_action_output
+{
+local ($act) = @_;
+return &read_file_contents("$ENV{'WEBMIN_VAR'}/output/$act->{'id'}");
+}
+
 =head2 expand_base_dir(base)
 
 Finds files either under some dir, or starting with some path in the same