line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BBS::Perm::Plugin::IP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
35551
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
6
|
1
|
|
|
1
|
|
6
|
use Encode; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
91
|
|
7
|
1
|
|
|
1
|
|
1623
|
use Regexp::Common qw/net/; |
|
1
|
|
|
|
|
5993
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
4242
|
use IP::QQWry; |
|
1
|
|
|
|
|
5233
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
538
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Glib qw/TRUE FALSE/; |
11
|
|
|
|
|
|
|
use Encode; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $qqwry = IP::QQWry->new; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
my ( $class, %opt ) = @_; |
17
|
|
|
|
|
|
|
$qqwry->set_db( $opt{qqwry} ) if $opt{qqwry}; |
18
|
|
|
|
|
|
|
my $widget = $opt{widget} || Gtk2::Statusbar->new; |
19
|
|
|
|
|
|
|
my $id = $widget->get_context_id('ip'); |
20
|
|
|
|
|
|
|
my $self = { ip => {} }; |
21
|
|
|
|
|
|
|
$self->{widget} = $widget; |
22
|
|
|
|
|
|
|
$self->{_id} = $id; |
23
|
|
|
|
|
|
|
$self->{_encoding} = $opt{encoding} || 'gbk'; |
24
|
|
|
|
|
|
|
$self->{_length} = $opt{length} || 80; |
25
|
|
|
|
|
|
|
bless $self, ref $class || $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub add { |
29
|
|
|
|
|
|
|
my ( $self, $input ) = @_; |
30
|
|
|
|
|
|
|
$input =~ s/\*/1/g; |
31
|
|
|
|
|
|
|
return if defined $self->{ip}{$input}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my @info; |
34
|
|
|
|
|
|
|
if ( @info = $qqwry->query($input) ) { |
35
|
|
|
|
|
|
|
$self->{ip}{$input} = [@info]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
|
|
|
|
|
|
$self->{ip}{$input} = []; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub remove { |
43
|
|
|
|
|
|
|
my ( $self, $ip ) = @_; |
44
|
|
|
|
|
|
|
delete $self->{ip}{$ip}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub ip { |
48
|
|
|
|
|
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
return $self->{ip}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub clear { |
53
|
|
|
|
|
|
|
shift->{ip} = {}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub show { |
57
|
|
|
|
|
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
my $show = q{}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
if ( $self->ip ) { |
61
|
|
|
|
|
|
|
for ( sort keys %{ $self->ip } ) { |
62
|
|
|
|
|
|
|
my $info = |
63
|
|
|
|
|
|
|
decode( $self->{_encoding}, join '', |
64
|
|
|
|
|
|
|
grep { $_ } @{ $self->ip->{$_} } ) |
65
|
|
|
|
|
|
|
|| q{}; |
66
|
|
|
|
|
|
|
$show .= $_ . ': ' . $info . "; "; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $length = $self->{_length}; |
70
|
|
|
|
|
|
|
$show = sprintf( "%${length}s", $show ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
$self->widget->pop( $self->_id ); |
73
|
|
|
|
|
|
|
$self->widget->push( $self->_id, $show ); |
74
|
|
|
|
|
|
|
return TRUE; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub AUTOLOAD { |
78
|
|
|
|
|
|
|
no strict 'refs'; |
79
|
|
|
|
|
|
|
our $AUTOLOAD; |
80
|
|
|
|
|
|
|
if ( $AUTOLOAD =~ /.*::(.*)/ ) { |
81
|
|
|
|
|
|
|
my $element = $1; |
82
|
|
|
|
|
|
|
*$AUTOLOAD = sub { return shift->{$element} }; |
83
|
|
|
|
|
|
|
goto &$AUTOLOAD; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub DESTROY { } |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |