line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::IP::Record; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
41
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
626
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = 1.51; |
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
37
|
use Geo::IP; # |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
851
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
38
|
use vars qw/$pp/; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
877
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# here are the missing functions if the C API is used |
12
|
|
|
|
|
|
|
sub latitude { |
13
|
|
|
|
|
|
|
my $gir = shift; |
14
|
|
|
|
|
|
|
return sprintf( "%.4f", $gir->_latitude ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub longitude { |
18
|
|
|
|
|
|
|
my $gir = shift; |
19
|
|
|
|
|
|
|
return sprintf( "%.4f", $gir->_longitude ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
BEGIN { |
23
|
7
|
|
33
|
7
|
|
289
|
$pp = !defined(&Geo::IP::Record::city) |
24
|
|
|
|
|
|
|
|| $Geo::IP::GEOIP_PP_ONLY; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
7
|
50
|
50
|
7
|
1
|
47
|
eval <<'__PP__' if $pp; |
|
7
|
50
|
|
7
|
1
|
15
|
|
|
7
|
50
|
|
7
|
1
|
213
|
|
|
7
|
|
|
12
|
|
37
|
|
|
7
|
|
|
1
|
|
15
|
|
|
7
|
|
|
1
|
|
501
|
|
|
7
|
|
|
1
|
|
37
|
|
|
7
|
|
|
1
|
|
13
|
|
|
7
|
|
|
|
|
1715
|
|
|
12
|
|
|
|
|
101
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
for ( qw: country_code country_code3 country_name |
30
|
|
|
|
|
|
|
region region_name city |
31
|
|
|
|
|
|
|
postal_code dma_code area_code |
32
|
|
|
|
|
|
|
continent_code metro_code : ) { |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
no strict qw/ refs /; |
35
|
|
|
|
|
|
|
no warnings qw/ redefine /; |
36
|
|
|
|
|
|
|
my $m = $_; # looks bogus, but it is not! it is a copy not a alias |
37
|
|
|
|
|
|
|
*$_ = sub { $_[0]->{$m} }; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# for the case warnings are globaly enabled with perl -w and the CAPI is absent |
41
|
|
|
|
|
|
|
no warnings qw/ redefine /; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub longitude {sprintf('%.4f', $_[0]->{longitude})} |
44
|
|
|
|
|
|
|
sub latitude {sprintf('%.4f', $_[0]->{latitude})} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my $TIME_ZONE; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
local $_ = ; # skip first line |
50
|
|
|
|
|
|
|
while () { |
51
|
|
|
|
|
|
|
chomp; |
52
|
|
|
|
|
|
|
next if /^\s*$/; |
53
|
|
|
|
|
|
|
my ( $country, $region, $timezone ) = split /,/, $_, 3; |
54
|
|
|
|
|
|
|
$TIME_ZONE->{$country}->{ $region || '' } = $timezone; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# called from Geo::IP |
58
|
|
|
|
|
|
|
sub _time_zone { |
59
|
|
|
|
|
|
|
my ( undef, $country, $region ) = @_; |
60
|
|
|
|
|
|
|
return undef unless $country; |
61
|
|
|
|
|
|
|
return undef unless defined $TIME_ZONE->{$country}; |
62
|
|
|
|
|
|
|
$region ||= ''; |
63
|
|
|
|
|
|
|
return |
64
|
|
|
|
|
|
|
defined $TIME_ZONE->{$country}->{$region} |
65
|
|
|
|
|
|
|
? $TIME_ZONE->{$country}->{$region} |
66
|
|
|
|
|
|
|
: $TIME_ZONE->{$country}->{''}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
sub time_zone { |
69
|
|
|
|
|
|
|
my ( $self ) = @_; |
70
|
|
|
|
|
|
|
my ( $country, $region ) = ( $self->country_code, $self->region ); |
71
|
|
|
|
|
|
|
return $self->_time_zone( $country, $region ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__PP__ |
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__DATA__ |