14 |
|
|
15 |
use Data::Dumper; |
use Data::Dumper; |
16 |
|
|
17 |
|
my $debug = 1; |
18 |
|
|
19 |
my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die; |
my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die; |
20 |
my $cgi = new CGI::Lite; |
my $cgi = new CGI::Lite; |
21 |
my $mws = MWS->new('global.conf'); |
my $mws = MWS->new('global.conf'); |
70 |
my $url = $r->url->path; |
my $url = $r->url->path; |
71 |
|
|
72 |
# XXX LOG |
# XXX LOG |
73 |
print $r->method," ",$url,Dumper($param); |
print $r->method," ",$url,"\n",Dumper($param),"\n" if ($debug); |
74 |
|
|
75 |
# template file name (use ?format=html as default) |
# template file name (use ?format=html as default) |
76 |
my $tpl_file = 'master.'; |
my $tpl_file = 'master.'; |
83 |
|
|
84 |
if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) { |
if ($param->{'search_val'} && $param->{'search_fld'} && !$param->{'search'}) { |
85 |
$param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'}; |
$param->{'search'} = $param->{'search_fld'}.":".$param->{'search_val'}; |
86 |
|
} elsif ($param->{'search'}) { |
87 |
|
($param->{'search_fld'}, $param->{'search_val'}) = split(/:/,$param->{'search'},2); |
88 |
} |
} |
89 |
|
|
90 |
my $tpl_var = { |
my $tpl_var = { |
101 |
my @res = $mws->fetch_all_results(); |
my @res = $mws->fetch_all_results(); |
102 |
|
|
103 |
$tpl_var->{results} = \@res; |
$tpl_var->{results} = \@res; |
104 |
|
$tpl_var->{total_hits} = $mws->{total_hits}; |
105 |
|
|
106 |
|
|
107 |
# |
# |
108 |
# ?show_id=XXXXxxxx___message_id___xxxxXXXX |
# ?show_id=XXXXxxxx___message_id___xxxxXXXX |
109 |
} elsif ($param->{'show_id'}) { |
} elsif ($param->{'show_id'}) { |
110 |
|
|
111 |
|
$mws->reset_counters; |
112 |
my $row = $mws->fetch_result_by_id($param->{'show_id'}); |
my $row = $mws->fetch_result_by_id($param->{'show_id'}); |
113 |
$tpl_var->{message} = $row; |
$tpl_var->{message} = $row; |
114 |
} |
} |
115 |
|
|
116 |
|
print Dumper($mws->{counter}); |
117 |
|
|
118 |
|
# push counters to template |
119 |
|
foreach my $f (qw(from to cc bcc)) { |
120 |
|
my $h = $mws->counter($f) || next; |
121 |
|
my @a; |
122 |
|
foreach my $k (sort { $h->{$b}->{usage} <=> $h->{$a}->{usage} } keys %$h) { |
123 |
|
push @a, $h->{$k}; |
124 |
|
} |
125 |
|
$tpl_var->{counters}->{$f} = [ @a ] if (@a); |
126 |
|
} |
127 |
|
|
128 |
$tt->process($tpl_file, $tpl_var, \$html) || die $tt->error(); |
$tt->process($tpl_file, $tpl_var, \$html) || die $tt->error(); |
129 |
|
|
130 |
# |
# |
164 |
sub subject_search_filter { |
sub subject_search_filter { |
165 |
my $s = shift; |
my $s = shift; |
166 |
# remove re: fdw: [list] preffixes from e-mail |
# remove re: fdw: [list] preffixes from e-mail |
167 |
while ( $s =~ s/^\s*\[(?:re|fwd):\s+(.+)\]\s*$/$1/ig || |
while ( $s =~ s/^\s*\[(?:re|fwd|fw):\s+(.+)\]\s*$/$1/ig || |
168 |
$s =~ s/^\s*(?:re|fwd):\s+(.+?)\s*$/$1/ig || |
$s =~ s/^\s*(?:re|fwd|fw):\s+(.+?)\s*$/$1/ig || |
169 |
$s =~ s/^\[\w+\]\s*//ig |
$s =~ s/^\[\S+\]\s*//ig || |
170 |
|
$s =~ s/^\[[^@]+@\w+\.\w+\s*:\s+(.+)\s*\]\s*$/$1/g || |
171 |
|
$s =~ s/\(fwd\)\s*$//ig || |
172 |
|
$s =~ s/\"//g |
173 |
) { }; |
) { }; |
174 |
return $s; |
return $s; |
175 |
} |
} |