Webqq/Client/Method/_check_verify_code.pm

filter: Statementstmt 11.4% 4 / 35 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 1 / 2 Podpod n/a totaltotal 9.0% 5 / 55 CC 10 SCAR 46.1
CC
10
Cov
8%
_check_verify_code
110.0
BEGIN
1.0
CRAP 100.1
« Webqq/Client/Plugin/SendMsgFromSocket.pm ↑ Summary Webqq/Client.pm »
1 1 ▶use Webqq::Client::Util qw(console);
Subroutine BEGIN: called CC=1 SCAR=0.0
2 0 ▶sub Webqq::Client::_check_verify_code{
Subroutine _check_verify_code: not called CC=10 SCAR=47.0
3 0 console "检查验证码...\n";
4 0 my $self = shift;
5 0 my $ua = $self->{ua};
6 0 my $api_url = 'https://ssl.ptlogin2.qq.com/check';
7 0 ▶ my @headers = $self->{type} eq 'webqq'? (Referer=>'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=5&mibao_css=m_webqq&appid=1003903&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20140612002')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
8 : (Referer=>'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=16&mibao_css=m_webqq&appid=501004106&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20131024001')
9 ;
10  
11 0 ▶ my $query_string_ul = $self->{type} eq 'webqq'? 'http%3A%2F%2Fweb2.qq.com%2Floginproxy.html'
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
12 : 'http%3A%2F%2Fw.qq.com%2Fproxy.html'
13 ;
14 my @query_string = (
15 uin => $self->{qq_param}{qq},
16 appid => $self->{qq_param}{g_appid},
17 js_ver => $self->{qq_param}{g_pt_version},
18 js_type => 0,
19 login_sig => $self->{qq_param}{g_login_sig},
20 0 u1 => $query_string_ul,
21 r => rand(),
22 );
23
24 0 ▶ if($self->{type} eq 'smartqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "smartqq") 0 0 0
25 0 unshift @query_string,(
26 pt_tea => 1,
27 );
28 }
29
30 0 my @query_string_pairs;
31 0 ▶ push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
Branch: 1 branch
BranchTrueFalseTotal
@query_string and do { push @query_string_pairs, shift(@query_string) . '=' . shift(@query_string) } 0 0 0
32  
33 0 $ua->cookie_jar()->set_cookie(0,"chkuin",$self->{qq_param}{qq},"/","ptlogin2.qq.com",);
34  
35 0 ▶ for(my $i=1;$i<=$self->{ua_retry_times};$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"ua_retry_times"}) 0 0 0
36 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
37 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) 0 0 0
38 0 my $content = $response->content();
39 0 ▶ print $content,"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
40 0 my %d = ();
41 0 @d{qw( retcode cap_cd md5_salt verifysession isRandSalt)} = $content=~/'(.*?)'/g ;
42 0 $d{md5_salt} =~ s/\\\\x/\x/g;
43 #$self->{qq_param}{md5_salt} = eval qq{"$d{md5_salt}"};
44 0 $self->{qq_param}{md5_salt} = $d{md5_salt};
45 0 $self->{qq_param}{cap_cd} = $d{cap_cd};
46 0 $self->{qq_param}{verifysession} = $d{verifysession};
47 0 $self->{qq_param}{isRandSalt} = $d{isRandSalt};
48 0 ▶ if($d{retcode} ==0){
Branch: 2 branches
BranchTrueFalseTotal
if ($d{'retcode'} == 0) { } 0 0 0
elsif ($d{'retcode'} == 1) { } 0 0 0
49 0 console "检查结果: 很幸运,本次登录不需要验证码\n";
50 0 $self->{qq_param}{verifycode} = $d{cap_cd};
51 }
52 elsif($d{retcode} == 1){
53 0 console "检查结果: 需要输入图片验证码\n";
54 0 $self->{qq_param}{is_need_img_verifycode} = 1
55 }
56
57 0 return 1;
58 }
59 }
60 0 return 0;
61 }
62 1 1;
« Webqq/Client/Plugin/SendMsgFromSocket.pm ↑ Summary Webqq/Client.pm »