Started work on webmin log search from left menu
authorJamie Cameron <jcameron@webmin.com>
Wed, 14 Nov 2007 01:53:08 +0000 (01:53 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 14 Nov 2007 01:53:08 +0000 (01:53 +0000)
blue-theme/images/logs.gif [new file with mode: 0644]
blue-theme/lang/en
blue-theme/left.cgi
webminlog/index.cgi
webminlog/lang/en
webminlog/search.cgi

diff --git a/blue-theme/images/logs.gif b/blue-theme/images/logs.gif
new file mode 100644 (file)
index 0000000..7bab606
Binary files /dev/null and b/blue-theme/images/logs.gif differ
index aeeadd3..d4e8208 100644 (file)
@@ -5,6 +5,7 @@ left_feedback=Send Feedback
 left_search_webmin=Search Webmin:
 left_search_usermin=Search Usermin:
 left_search=Search:
+left_logs=View Webmin logs
 
 right_header0=System Information
 right_host=System hostname
index b0eade4..653067e 100755 (executable)
@@ -31,6 +31,30 @@ function toggleview (id1,id2) {
                (obj1.className=="itemshown") ? obj1.className="itemhidden" : obj1.className="itemshown"; 
                (obj1.className=="itemshown") ? obj2.innerHTML="<img border='0' src='images/open.gif' alt='[&ndash;]'>" : 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>
@@ -79,6 +103,12 @@ if (-r "$root_directory/webmin_search.cgi") {
 
 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";
index ccb3c3c..fc3b87d 100755 (executable)
@@ -13,10 +13,8 @@ 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";
+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;
@@ -27,59 +25,62 @@ if (@canulist == 1) {
        }
 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'});
 
index 707c876..788ffa4 100644 (file)
@@ -8,6 +8,7 @@ index_module=In module
 index_tall=At any time
 index_today=For today only
 index_yesterday=For yesterday only
+index_week=During the last week
 index_time=Between $1 and $2
 index_search=Search
 index_return=search form
@@ -17,6 +18,11 @@ index_fall=Which modified any file
 index_file=That modified file
 index_wall=From any Webmin server
 index_whost=From server
+index_susers=Actions by Webmin users
+index_smods=Actions in module
+index_sfile=Actions that modified file
+index_stimes=Actions on dates
+index_shost=Source Webmin server
 
 search_title=Search Results
 search_date=Date
index 6f54178..5ac0fad 100755 (executable)
@@ -9,18 +9,28 @@ require 'timelocal.pl';
 
 # 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();