Handle hostnames with upper-case letters
[webmin.git] / bind8 / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'bind8-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) = @_;
11 if ($type eq 'record') {
12         if ($p->{'type'} eq 'PTR') {
13                 return &text("log_${action}_record", $text{"type_$p->{'type'}"},
14                              "<tt>".&arpa_to_ip($p->{'name'})."</tt>",
15                              "<tt>".&arpa_to_ip($object)."</tt>");
16                 }
17         else {
18                 $p->{'name'} =~ s/\.$object\.*$//;
19                 if (($action eq "modify" || $action eq "create") &&
20                     $p->{'newvalues'}) {
21                         return &text("log_${action}_record_v",
22                                      $text{"type_$p->{'type'}"},
23                                      "<tt>$p->{'name'}</tt>",
24                                      "<tt>$object</tt>",
25                                      "<tt>$p->{'newvalues'}</tt>");
26                         }
27                 else {
28                         return &text("log_${action}_record",
29                                      $text{"type_$p->{'type'}"},
30                                      "<tt>$p->{'name'}</tt>",
31                                      "<tt>$object</tt>");
32                         }
33                 }
34         }
35 elsif ($type eq 'recs') {
36         return &text("log_${action}_recs", $object);
37         }
38 elsif ($type eq 'zones') {
39         return &text("log_${action}_zones", $object);
40         }
41 elsif ($type eq "host" || $type eq "group") {
42         return &text("log_${action}_${type}", "<tt>$object</tt>");
43         }
44 elsif ($action eq 'create') {
45         return &text("log_${type}", "<tt>$object</tt>");
46         }
47 elsif ($action eq 'delete') {
48         return &text("log_delete_${type}", "<tt>$object</tt>");
49         }
50 elsif ($action eq 'text') {
51         return &text("log_text", "<tt>$object</tt>");
52         }
53 elsif ($action eq 'soa') {
54         return &text("log_soa", "<tt>$object</tt>");
55         }
56 elsif ($action eq 'zonekeyon' || $action eq 'zonekeyoff' || $action eq 'sign') {
57         return &text("log_".$action, "<tt>$object</tt>");
58         }
59 elsif ($action eq 'opts') {
60         return &text("log_opts", "<tt>$object</tt>");
61         }
62 elsif ($action eq 'view') {
63         return &text("log_review", "<tt>$object</tt>");
64         }
65 elsif ($action eq 'move') {
66         return &text("log_move", "<tt>$object</tt>");
67         }
68 elsif ($action eq 'apply' && $type && $type ne '-') {
69         return &text("log_apply2", "<tt>$type</tt>");
70         }
71 elsif ($action eq 'freeze' || $action eq 'thaw') {
72         return &text("log_".$action, "<tt>$type</tt>");
73         }
74 elsif ($action eq 'mass') {
75         return &text("log_mass", $object);
76         }
77 elsif ($action eq 'manual') {
78         return &text("log_manual", "<tt>$object</tt>");
79         }
80 elsif ($text{"log_${action}"}) {
81         return $text{"log_${action}"};
82         }
83 else {
84         return undef;
85         }
86 }
87