Handle hostnames with upper-case letters
[webmin.git] / mailboxes / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'mailboxes-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 'delmail') {
12         return &text("log_delmail", $p->{'count'}, "<tt>$p->{'from'}</tt>");
13         }
14 elsif ($action eq 'movemail') {
15         return &text("log_movemail", $p->{'count'}, "<tt>$p->{'from'}</tt>",
16                      "<tt>$p->{'to'}</tt>");
17         }
18 elsif ($action eq 'copymail') {
19         return &text("log_copymail", $p->{'count'}, "<tt>$p->{'from'}</tt>",
20                      "<tt>$p->{'to'}</tt>");
21         }
22 elsif ($action eq 'send') {
23         return &text('log_send', &html_escape(&extract_email($p->{'to'})));
24         }
25 elsif ($action eq 'read') {
26         return &text('log_read', &html_escape($object));
27         }
28 else {
29         return undef;
30         }
31 }
32
33 sub extract_email
34 {
35 if ($_[0] =~ /([^<>"' \(\)]+\@[^<>"' \(\)]+)/) {
36         return $1;
37         }
38 elsif ($_[0] =~ /<(\S+)>/) {
39         return $1;
40         }
41 else {
42         return $_[0];
43         }
44 }
45