2 # Functions for parsing this module's logs
6 # parse_webmin_log(user, script, action, type, object, ¶ms)
7 # Converts logged information from this module into human-readable form
10 local ($user, $script, $action, $type, $object, $p, $long) = @_;
11 if ($action eq 'stop') {
12 return $text{'log_stop'};
14 elsif ($action eq 'start') {
15 return $text{'log_start'};
17 elsif ($action eq 'cnf') {
18 return $text{'log_cnf'};
20 elsif ($action eq 'kill') {
21 return &text('log_kill', $object);
23 elsif ($action eq 'vars') {
24 return &text('log_vars', $object);
26 elsif ($type eq 'db') {
27 return &text("log_${type}_${action}", "<tt>$object</tt>");
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);
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>");
37 elsif ($type eq 'tables') {
38 return &text("log_${type}_${action}", $object,
39 "<tt>$p->{'db'}</tt>");
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>");
47 elsif ($type eq 'fields') {
48 return &text("log_${type}_${action}", $object,
49 "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>");
51 elsif ($type eq 'data') {
52 return &text("log_${type}_${action}", "<tt>$object</tt>",
53 "<tt>$p->{'table'}</tt>", "<tt>$p->{'db'}</tt>");
55 elsif ($action eq 'exec') {
56 return &text($long ? 'log_exec_l' : 'log_exec', "<tt>$object</tt>",
57 "<tt>".&html_escape($p->{'cmd'})."</tt>");
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>");
73 elsif ($action eq 'backup') {
74 return &text($object ? ($long ? 'log_backup_l' : 'log_backup')
75 : ($long ? 'log_backup_all_l' : 'log_backup_all'),
77 "<tt>".&html_escape($p->{'file'})."</tt>");
79 elsif ($action eq 'execfile') {
80 return &text($p->{'mode'} ? 'log_execupload' : 'log_execfile',
81 "<tt>".&html_escape($p->{'file'})."</tt>");
83 elsif ($action eq 'import') {
84 return &text($p->{'mode'} ? 'log_importupload' : 'log_importfile',
85 "<tt>".&html_escape($p->{'file'})."</tt>");
87 elsif ($action eq 'set') {
88 return &text('log_set', $object);
90 elsif ($action eq 'root') {
91 return $text{'log_root'};