Handle hostnames with upper-case letters
[webmin.git] / mysql / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'mysql-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 ($action eq 'stop') {
12         return $text{'log_stop'};
13         }
14 elsif ($action eq 'start') {
15         return $text{'log_start'};
16         }
17 elsif ($action eq 'cnf') {
18         return $text{'log_cnf'};
19         }
20 elsif ($action eq 'kill') {
21         return &text('log_kill', $object);
22         }
23 elsif ($action eq 'vars') {
24         return &text('log_vars', $object);
25         }
26 elsif ($type eq 'db') {
27         return &text("log_${type}_${action}", "<tt>$object</tt>");
28         }
29 elsif ($type eq 'dbs' || $type eq 'users' || $type eq 'hosts' ||
30        $type eq 'cprivs' || $type eq 'tprivs' || $type eq 'dbprivs') {
31         return &text("log_${type}_${action}", $object);
32         }
33 elsif ($type eq 'table' || $type eq 'index' || $type eq 'view') {
34         return &text("log_${type}_${action}", "<tt>$object</tt>",
35                      "<tt>$p->{'db'}</tt>");
36         }
37 elsif ($type eq 'tables') {
38         return &text("log_${type}_${action}", $object,
39                      "<tt>$p->{'db'}</tt>");
40         }
41 elsif ($type eq 'field') {
42         $p->{'size'} =~ s/\s+$//;
43         return &text("log_${type}_${action}", "<tt>$object</tt>",
44                      "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>",
45                      "<tt>$p->{'type'}$p->{'size'}</tt>");
46         }
47 elsif ($type eq 'fields') {
48         return &text("log_${type}_${action}", $object,
49                      "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>");
50         }
51 elsif ($type eq 'data') {
52         return &text("log_${type}_${action}", "<tt>$object</tt>",
53                      "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>");
54         }
55 elsif ($action eq 'exec') {
56         return &text($long ? 'log_exec_l' : 'log_exec', "<tt>$object</tt>",
57                      "<tt>".&html_escape($p->{'cmd'})."</tt>");
58         }
59 elsif ($type eq 'user' || $type eq 'perm' || $type eq 'host' ||
60        $type eq 'tpriv' || $type eq 'cpriv') {
61         $p->{'user'} = $text{'log_anon'}
62                 if ($p->{'user'} eq '-' || $p->{'user'} eq '%');
63         $p->{'db'} = $text{'log_any'}
64                 if ($p->{'db'} eq '-' || $p->{'db'} eq '%');
65         $p->{'host'} = $text{'log_any'}
66                 if ($p->{'host'} eq '-' || $p->{'host'} eq '%');
67         local $t = "log_${type}_${action}";
68         if ($long && $text{$t.'_l'}) { $t .= '_l'; }
69         return &text($t, "<tt>$p->{'user'}</tt>",
70                      "<tt>$p->{'host'}</tt>", "<tt>$p->{'db'}</tt>",
71                      "<tt>$p->{'table'}</tt>", "<tt>$p->{'field'}</tt>");
72         }
73 elsif ($action eq 'backup') {
74         return &text($object ? ($long ? 'log_backup_l' : 'log_backup')
75                              : ($long ? 'log_backup_all_l' : 'log_backup_all'),
76                      "<tt>$object</tt>",
77                      "<tt>".&html_escape($p->{'file'})."</tt>");
78         }
79 elsif ($action eq 'execfile') {
80         return &text($p->{'mode'} ? 'log_execupload' : 'log_execfile',
81                      "<tt>".&html_escape($p->{'file'})."</tt>");
82         }
83 elsif ($action eq 'import') {
84         return &text($p->{'mode'} ? 'log_importupload' : 'log_importfile',
85                      "<tt>".&html_escape($p->{'file'})."</tt>");
86         }
87 elsif ($action eq 'set') {
88         return &text('log_set', $object);
89         }
90 elsif ($action eq 'root') {
91         return $text{'log_root'};
92         }
93 else {
94         return undef;
95         }
96 }
97