Handle hostnames with upper-case letters
[webmin.git] / qmailadmin / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'qmail-lib.pl';
5
6 # parse_webmin_log(user, script, action, type, object, &params, long)
7 # Converts logged information from this module into human-readable form
8 sub parse_webmin_log
9 {
10 local ($user, $script, $action, $type, $object, $p, $long) = @_;
11 if ($type eq 'alias') {
12         return &text("log_alias_$action",
13                      "<tt>".&html_escape($object)."</tt>");
14         }
15 elsif ($type eq 'virt') {
16         return &text($object ne '-' ? "log_virt_$action" :
17                 "log_virtall_$action", "<tt>".&html_escape($object)."</tt>");
18         }
19 elsif ($type eq 'route') {
20         return &text("log_route_$action",
21                      "<tt>".&html_escape($object)."</tt>");
22         }
23 elsif ($type eq 'assign') {
24         local $str = $object =~ /^=(\S*)/ ? $1 :
25                      $object =~ /^\+(\S*)/ ? "$1*" : "";
26         return &text("log_assign_$action", &html_escape($str));
27         }
28 elsif ($type eq 'aliases' || $type eq 'virts' || $type eq 'routes' ||
29        $type eq 'assigns') {
30         return &text("log_${action}_${type}", $object);
31         }
32 elsif ($action eq 'delmail') {
33         local @d = split(/\0/, $p->{'d'});
34         return &text("log_delmail", scalar(@d), "<tt>$p->{'user'}</tt>");
35         }
36 elsif ($action eq 'movemail') {
37         local @d = split(/\0/, $p->{'d'});
38         local $to = $p->{'move1'} ? $p->{'moveto1'} : $p->{'moveto2'};
39         return &text("log_movemail", scalar(@d), "<tt>$p->{'user'}</tt>",
40                      "<tt>$to</tt>");
41         }
42 elsif ($action eq 'send') {
43         return &text('log_send', &html_escape(&extract_email($p->{'to'})));
44         }
45 else {
46         return $text{"log_$action"};
47         }
48 }
49