3 |
# based on post |
# based on post |
4 |
# http://www.mail-archive.com/libwww@perl.org/msg04750.html |
# http://www.mail-archive.com/libwww@perl.org/msg04750.html |
5 |
|
|
6 |
|
BEGIN { |
7 |
|
my $basedir = readlink($0) || $0; $basedir =~ s#/[^/]+$##; |
8 |
|
unshift(@INC, $basedir); |
9 |
|
} |
10 |
|
|
11 |
use strict; |
use strict; |
12 |
use warnings; |
use warnings; |
13 |
|
use MWS::SWISH; |
14 |
|
#use MWS::Plucene; |
15 |
use HTTP::Daemon; |
use HTTP::Daemon; |
16 |
use HTTP::Status; |
use HTTP::Status; |
17 |
use IO::String; |
use IO::String; |
18 |
use CGI::Lite; |
use CGI::Lite; |
19 |
use Template; |
use Template; |
|
use MWS; |
|
20 |
use URI::Escape; |
use URI::Escape; |
21 |
|
|
22 |
use Data::Dumper; |
use Data::Dumper; |
34 |
exit 1; |
exit 1; |
35 |
} |
} |
36 |
|
|
37 |
my $mws = MWS->new($config_file); |
my $mws = MWS::SWISH->new(config_file => $config_file); |
38 |
|
#my $mws = MWS::Plucene->new(config_file => $config_file, debug => $debug); |
39 |
|
|
40 |
my ($local_addr,$local_port) = ('127.0.0.1',6969); |
my ($local_addr,$local_port) = ('127.0.0.1',6969); |
41 |
|
|
42 |
my $listen = $mws->{config}->val('global', 'listen'); |
my $listen = $mws->{config}->val('global', 'listen'); |
43 |
if ($listen =~ m/:/) { |
|
44 |
($local_addr,$local_port) = split(/:/,$listen); |
print STDERR "using listen $listen\n" if ($listen); |
45 |
|
|
46 |
|
if ($listen && $listen =~ m/:/) { |
47 |
|
($local_addr,$local_port) = split(/:/,$listen,2); |
48 |
} elsif ($listen) { |
} elsif ($listen) { |
49 |
$local_addr = $listen; |
$local_addr = $listen; |
50 |
} |
} |
53 |
Reuse => 1, |
Reuse => 1, |
54 |
LocalAddr => $local_addr, |
LocalAddr => $local_addr, |
55 |
LocalPort => $local_port, |
LocalPort => $local_port, |
56 |
) || die "can't create HTTP::Daemon"; |
) || die "can't create HTTP::Daemon on $local_addr:$local_port: $!"; |
57 |
|
|
58 |
my $cgi = new CGI::Lite; |
my $cgi = new CGI::Lite; |
59 |
my $tt = Template->new({ |
my $tt = Template->new({ |
111 |
|
|
112 |
# XXX LOG |
# XXX LOG |
113 |
print $r->method," ",$url,"\n"; |
print $r->method," ",$url,"\n"; |
114 |
print Dumper($param),"\n" if ($debug); |
print Dumper($param,$mws->{counter}),"\n" if ($debug); |
115 |
|
|
116 |
# is this static page? |
# is this static page? |
117 |
if ($static_html && -f "$static_html/$url") { |
if ($static_html && -f "$static_html/$url") { |
208 |
|
|
209 |
|
|
210 |
# push counters to template |
# push counters to template |
211 |
foreach my $f (qw(from to cc bcc)) { |
foreach my $f (qw(from to cc bcc folder)) { |
212 |
my $h = $mws->counter($f) || next; |
my $h = $mws->counter($f) || next; |
213 |
my @a; |
my @a; |
214 |
foreach my $k (sort { $h->{$b}->{usage} <=> $h->{$a}->{usage} } keys %$h) { |
foreach my $k (sort { $h->{$b}->{usage} <=> $h->{$a}->{usage} } keys %$h) { |
271 |
$text =~ s/(\s*--+\s*Forwarded\s+message.+\s*--+.*)$//si; |
$text =~ s/(\s*--+\s*Forwarded\s+message.+\s*--+.*)$//si; |
272 |
|
|
273 |
# remove signature |
# remove signature |
274 |
$text =~ s/[\n\r]+--\s*[\n\r]+.*$//s; |
$text =~ s/(?:^|[\n\r]+)*--\s*[\n\r]+.*$//s; |
275 |
|
$text =~ s/(?:^|[\n\r]+)*_____+[\n\r]+.*$//s; |
276 |
|
|
277 |
# compress cr/lf |
# compress cr/lf |
278 |
$text =~ s/[\n\r]+/\n/gs; |
$text =~ s/[\n\r]+/\n/gs; |
304 |
# remove signature |
# remove signature |
305 |
if ($text =~ s/([\n\r]+)(--\s*[\n\r]+.*)$//s) { |
if ($text =~ s/([\n\r]+)(--\s*[\n\r]+.*)$//s) { |
306 |
$sig = "$1#-#signature##$2##signature#-#"; |
$sig = "$1#-#signature##$2##signature#-#"; |
307 |
|
} elsif ($text =~s/(^|[\n\r]+)*(_____+[\n\r]+.*)$//s) { |
308 |
|
$sig = "$1#-#signature##$2##signature#-#"; |
309 |
} |
} |
310 |
|
|
311 |
# find quoted text |
# find quoted text |