line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Anonymouse; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
57381
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
82
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
70
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
7947
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
207124
|
|
|
2
|
|
|
|
|
99
|
|
7
|
2
|
|
|
2
|
|
26
|
use URI; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
8
|
2
|
|
|
2
|
|
11
|
use Carp (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
85
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
50
|
2
|
|
11
|
use constant DEBUG => $ENV{ WWW_ANONYMOUSE_DEBUG } || 0; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
384
|
|
13
|
2
|
|
|
2
|
|
11
|
use constant MAX_BYTES => 3072; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1388
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
4
|
|
|
4
|
1
|
5350
|
my ($class, %params) = @_; |
17
|
4
|
50
|
|
|
|
22
|
if ( $class eq __PACKAGE__ ) { |
18
|
0
|
|
|
|
|
0
|
Carp::croak __PACKAGE__, |
19
|
|
|
|
|
|
|
' is a virtual class; use the Email or News class'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
4
|
100
|
66
|
|
|
39
|
unless ( ref $params{ua} and $params{ua}->isa( q(LWP::UserAgent) ) ) { |
23
|
2
|
|
|
|
|
26
|
$params{ua} = LWP::UserAgent->new( agent => __PACKAGE__.'/'.$VERSION ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
7422
|
return bless \%params, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub error { |
30
|
0
|
|
|
0
|
1
|
|
return $_[0]->{error}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _ua_content_cb { |
34
|
0
|
|
|
0
|
|
|
my ($data, $res, $proto) = @_; |
35
|
0
|
|
|
|
|
|
$res->add_content(\$data); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Abort the request if enough content is received to parse for status. |
38
|
0
|
0
|
|
|
|
|
die if length $res->content > MAX_BYTES; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub send { |
42
|
0
|
|
|
0
|
1
|
|
my ($self, %params) = @_; |
43
|
0
|
|
|
|
|
|
my %fields; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
unless ( $fields{qw( to )} = $params{qw( to )} ) { |
46
|
0
|
|
|
|
|
|
$self->{error} = qq(Missing field "to"); |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
for my $field ( qw( subject text ) ) { |
51
|
0
|
|
0
|
|
|
|
$fields{$field} = $params{$field} || ''; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $res = $self->{ua}->post( |
55
|
|
|
|
|
|
|
$self->_url, \%fields, ':read_size_hint' => MAX_BYTES, |
56
|
|
|
|
|
|
|
':content_cb' => \&_ua_content_cb, |
57
|
|
|
|
|
|
|
); |
58
|
0
|
0
|
|
|
|
|
unless ( $res->is_success ) { |
59
|
0
|
|
|
|
|
|
$self->{error} = $res->status_line; |
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# TODO: consider using HTML::TreeBuilder::XPath |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->{error} = 'Unknown error'; |
66
|
0
|
|
|
|
|
|
my $cref = $res->content_ref; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ( $$cref !~ /
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
69
|
|
|
|
|
|
|
elsif ( $$cref =~ /\G color="#FF0000">(?:Mixmaster-)?Error - ([^>]+?)\!?
|
70
|
0
|
|
|
|
|
|
$self->{error} = $1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
elsif ( $$cref =~ /\G>(?:Email|Posting) has been sent anonymously/ ) { |
73
|
0
|
|
|
|
|
|
$self->{error} = undef; |
74
|
0
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
2
|
|
280
|
BEGIN { |
81
|
|
|
|
|
|
|
package WWW::Anonymouse::Email; |
82
|
2
|
|
|
2
|
|
130
|
use base qw( WWW::Anonymouse ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
415
|
|
83
|
0
|
|
|
0
|
|
|
sub _url { 'http://anonymouse.org/cgi-bin/anon-email.cgi' } |
84
|
0
|
|
|
0
|
|
|
sub _referer { 'http://anonymouse.org/anonemail.html' } |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
2
|
|
59
|
BEGIN { |
88
|
|
|
|
|
|
|
package WWW::Anonymouse::News; |
89
|
2
|
|
|
2
|
|
11
|
use base qw( WWW::Anonymouse ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
243
|
|
90
|
0
|
|
|
0
|
|
|
sub _url { 'http://anonymouse.org/cgi-bin/anon-news.cgi' } |
91
|
0
|
|
|
0
|
|
|
sub _referer { 'http://anonymouse.org/anonnews.html' } |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |