| 1 | package CGI::Wiki::Plugin::SpamMonkey; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 2 | our $VERSION = '0.03'; | |||||||||||
| 5 | |||||||||||||
| 6 | 2 | ▶ | use base 'CGI::Wiki::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use SpamMonkey; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | ▶ | use Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 2 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||
| 11 | 2 | my ($class) = @_; | |||||||||||
| 12 | 2 | my $newhome; | |||||||||||
| 13 | 2 | ▶ | if (!exists $ENV{HOME}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 14 | $newhome = $ENV{HOMEDRIVE} . $ENV{HOMEPATH} | ||||||||||||
| 15 | 0 | ▶ | if exists $ENV{HOMEDRIVE}; # Win XP/2000 | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | } | ||||||||||||
| 17 | 2 | ▶ | local $ENV{HOME} = $newhome if $newhome; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | 2 | my $monkey = SpamMonkey->new( rule_dir => "/etc/mail/spamassassin/"); | |||||||||||
| 19 | 2 | $monkey->ready; | |||||||||||
| 20 | 2 | my $self = bless ({ monkey => $monkey}, $class); | |||||||||||
| 21 | |||||||||||||
| 22 | 2 | return $self; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 3 | ▶ | sub is_spam { | ||||||||||
|
Subroutine
is_spam: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 26 | 3 | my ($self,%args) = @_; | |||||||||||
| 27 | |||||||||||||
| 28 | 3 | ▶ | my $content = $args{content} || ''; | ||||||||||
|
Condition100%2/2
$args{'content'} || ''
MC/DC100%1/1
$args{'content'} || ''
$args{'content'}
Truth table100%2/2
A
A= $args{'content'}
| |||||||||||||
| 29 | 3 | ▶ | $content .= Dumper($args{metadata}) if exists $args{metadata}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | |||||||||||||
| 31 | 3 | my $result = $self->{monkey}->test($content); | |||||||||||
| 32 | 3 | 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 | 2 | 1; | |||||||||||
| 97 | |||||||||||||