Handle hostnames with upper-case letters
[webmin.git] / ldap-server / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'ldap-server-lib.pl';
5
6 # parse_webmin_log(user, script, action, type, object, &params)
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 'dn') {
12         # Changed some DN
13         $object =~ s/,\s+/,/g;
14         return &text('log_'.$action.'_dn',
15                      "<tt>".&html_escape($object)."</tt>");
16         }
17 elsif ($type eq 'dns') {
18         # Multi-DN operation
19         return &text('log_'.$action.'_dns', $object);
20         }
21 elsif ($type eq 'attr') {
22         # Changed some attribute of a DN
23         $p->{'dn'} =~ s/,\s+/,/g;
24         return &text($long ? 'log_'.$action.'_attr_l' : 'log_'.$action.'_attr',
25                      "<tt>".&html_escape($object)."</tt>",
26                      "<tt>".&html_escape($p->{'dn'})."</tt>",
27                      "<tt>".&html_escape($p->{'value'})."</tt>");
28         }
29 elsif ($type eq 'attrs') {
30         # Multi-attribute operation
31         $p->{'dn'} =~ s/,\s+/,/g;
32         return &text('log_'.$action.'_attrs', $object,
33                      "<tt>".&html_escape($p->{'dn'})."</tt>");
34         }
35 elsif ($type eq 'access') {
36         return &text('log_'.$action.'_access',
37                      $object eq '*' ? $text{'log_all'} :
38                      $object =~ /^dn(\.[^=]+)?=(.*)/ ?
39                         "<tt>".&html_escape("$2")."</tt>" :
40                         "<tt>".&html_escape($object)."</tt>");
41         }
42 elsif ($type eq 'accesses') {
43         return &text('log_'.$action.'_accesses', $object);
44         }
45 elsif ($action eq 'sfile' || $action eq 'sup' || $action eq 'sdown') {
46         return &text('log_'.$action, "<tt>".&html_escape($object)."</tt>");
47         }
48 elsif ($action eq 'boot') {
49         return $object ? $text{'log_bootup'} : $text{'log_bootdown'};
50         }
51 elsif ($action eq 'create') {
52         return &text('log_create', "<tt>".&html_escape($object)."</tt>");
53         }
54 else {
55         return $text{'log_'.$action};
56         }
57 }
58