line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Wiki::Plugin::SpamMonkey; |
2
|
2
|
|
|
2
|
|
56185
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
121
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use base 'CGI::Wiki::Plugin'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1408
|
|
7
|
2
|
|
|
2
|
|
1821
|
use SpamMonkey; |
|
2
|
|
|
|
|
197715
|
|
|
2
|
|
|
|
|
29
|
|
8
|
2
|
|
|
2
|
|
13521
|
use Data::Dumper; |
|
2
|
|
|
|
|
17496
|
|
|
2
|
|
|
|
|
605
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
2
|
|
|
2
|
0
|
28
|
my ($class) = @_; |
12
|
2
|
|
|
|
|
4
|
my $newhome; |
13
|
2
|
50
|
|
|
|
13
|
if (!exists $ENV{HOME}) { |
14
|
0
|
0
|
|
|
|
0
|
$newhome = $ENV{HOMEDRIVE} . $ENV{HOMEPATH} |
15
|
|
|
|
|
|
|
if exists $ENV{HOMEDRIVE}; # Win XP/2000 |
16
|
|
|
|
|
|
|
} |
17
|
2
|
50
|
|
|
|
8
|
local $ENV{HOME} = $newhome if $newhome; |
18
|
2
|
|
|
|
|
19
|
my $monkey = SpamMonkey->new( rule_dir => "/etc/mail/spamassassin/"); |
19
|
2
|
|
|
|
|
24
|
$monkey->ready; |
20
|
2
|
|
|
|
|
34624
|
my $self = bless ({ monkey => $monkey}, $class); |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
13
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub is_spam { |
26
|
3
|
|
|
3
|
0
|
3123
|
my ($self,%args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
100
|
|
|
26
|
my $content = $args{content} || ''; |
29
|
3
|
50
|
|
|
|
12
|
$content .= Dumper($args{metadata}) if exists $args{metadata}; |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
24
|
my $result = $self->{monkey}->test($content); |
32
|
3
|
|
|
|
|
149421
|
return $result->is_spam; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
CGI::Wiki::Plugin::SpamMonkey - CGI::Wiki plugin for SpamMonkey |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use CGI::Wiki::Plugin::SpamMonkey; |
42
|
|
|
|
|
|
|
my $plugin = CGI::Wiki::Plugin::SpamMonkey->new; |
43
|
|
|
|
|
|
|
$wiki->register_plugin( plugin => $plugin ); |
44
|
|
|
|
|
|
|
... |
45
|
|
|
|
|
|
|
if ($plugin->is_spam( content => $content, metadata => \%metadata)) { |
46
|
|
|
|
|
|
|
$wiki->redirect( '/spamerror.html' ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
|
|
|
|
|
|
$wiki->commit(...); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module is a plugin for CGI::Wiki sites to interface with the SpamMonkey |
55
|
|
|
|
|
|
|
module. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 USAGE |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$plugin->is_spam( content => $content, metadata => \%metadata) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns a true value if the content or metadata is spam. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 BUGS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Please report any bugs to rt.cpan.org or post to |
66
|
|
|
|
|
|
|
bugs-cgi-wiki-plugin-spammonkey at rt.cpan.org |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SUPPORT |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This module, and other related modules are discussed on the mailing list: |
71
|
|
|
|
|
|
|
http://www.earth.li/cgi-bin/mailman/listinfo/cgi-wiki-dev |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Ivor Williams |
76
|
|
|
|
|
|
|
CPAN ID: IVORW |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
ivorw-openguides at xemaps.com |
79
|
|
|
|
|
|
|
http://openguides.org/ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This program is free software; you can redistribute |
84
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The full text of the license can be found in the |
87
|
|
|
|
|
|
|
LICENSE file included with this module. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
perl(1). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|