line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAttribute::CarrierDetector; |
2
|
27
|
|
|
27
|
|
995
|
use strict; |
|
27
|
|
|
|
|
56
|
|
|
27
|
|
|
|
|
1114
|
|
3
|
27
|
|
|
27
|
|
146
|
use warnings; |
|
27
|
|
|
|
|
1662
|
|
|
27
|
|
|
|
|
7900
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# this matching should be robust enough |
6
|
|
|
|
|
|
|
# detailed analysis is done in subclass's parse() |
7
|
|
|
|
|
|
|
our $DoCoMoRE = '^DoCoMo\/\d\.\d[ \/]'; |
8
|
|
|
|
|
|
|
our $JPhoneRE = '^(?i:J-PHONE\/\d\.\d)'; |
9
|
|
|
|
|
|
|
our $VodafoneRE = '^Vodafone\/\d\.\d'; |
10
|
|
|
|
|
|
|
our $VodafoneMotRE = '^MOT-'; |
11
|
|
|
|
|
|
|
our $SoftBankRE = '^SoftBank\/\d\.\d'; |
12
|
|
|
|
|
|
|
our $SoftBankCrawlerRE = '^Nokia[^\/]+\/\d\.\d'; |
13
|
|
|
|
|
|
|
our $EZwebRE = '^(?:KDDI-[A-Z]+\d+[A-Z]? )?UP\.Browser\\/'; |
14
|
|
|
|
|
|
|
our $AirHRE = '^Mozilla\/3\.0\((?:WILLCOM|DDIPOCKET)\;'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub detect { |
17
|
745
|
|
|
745
|
1
|
1172
|
my $user_agent = shift; |
18
|
|
|
|
|
|
|
|
19
|
745
|
50
|
|
|
|
15095
|
if (not defined $user_agent) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
return 'NonMobile'; |
21
|
|
|
|
|
|
|
} elsif ( $user_agent =~ /$DoCoMoRE/ ) { |
22
|
242
|
|
|
|
|
776
|
return 'DoCoMo'; |
23
|
|
|
|
|
|
|
} elsif ( $user_agent =~ /$JPhoneRE|$VodafoneRE|$VodafoneMotRE|$SoftBankRE|$SoftBankCrawlerRE/) { |
24
|
119
|
|
|
|
|
443
|
return 'ThirdForce'; |
25
|
|
|
|
|
|
|
} elsif ( $user_agent =~ /$EZwebRE/ ) { |
26
|
185
|
|
|
|
|
663
|
return 'EZweb'; |
27
|
|
|
|
|
|
|
} elsif ( $user_agent =~ /$AirHRE/ ) { |
28
|
21
|
|
|
|
|
88
|
return 'AirHPhone'; |
29
|
|
|
|
|
|
|
} else { |
30
|
178
|
|
|
|
|
659
|
return 'NonMobile'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |