| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Webqq::Client::Util; |
|
2
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
39
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Encode; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
56
|
|
|
4
|
1
|
|
|
1
|
|
17072
|
use Encode::Locale; |
|
|
1
|
|
|
|
|
3360
|
|
|
|
1
|
|
|
|
|
440
|
|
|
5
|
|
|
|
|
|
|
our @EXPORT_OK = qw(console console_stderr hash truncate code2state code2client) ; |
|
6
|
|
|
|
|
|
|
sub console{ |
|
7
|
0
|
|
|
0
|
0
|
|
my $bytes = join "",@_; |
|
8
|
0
|
|
|
|
|
|
print encode("locale",decode("utf8",$bytes)); |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
sub console_stderr{ |
|
11
|
0
|
|
|
0
|
0
|
|
my $bytes = join "",@_; |
|
12
|
0
|
|
|
|
|
|
print STDERR encode("locale",decode("utf8",$bytes)); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#腾讯hash函数js代码 http://pidginlwqq.sinaapp.com/hash.js |
|
16
|
|
|
|
|
|
|
#感谢[PERL学习交流 @小狼]贡献代码 |
|
17
|
|
|
|
|
|
|
sub hash { |
|
18
|
0
|
|
|
0
|
0
|
|
my $ptwebqq = shift; |
|
19
|
0
|
|
|
|
|
|
my $uin = shift; |
|
20
|
0
|
|
|
|
|
|
my $a = $ptwebqq . "password error"; |
|
21
|
0
|
|
|
|
|
|
my $i = ""; |
|
22
|
0
|
|
|
|
|
|
my @E = (); |
|
23
|
0
|
|
|
|
|
|
while(1){ |
|
24
|
0
|
0
|
|
|
|
|
if(length($i)<= length($a) ){ |
|
25
|
0
|
|
|
|
|
|
$i .= $uin; |
|
26
|
0
|
0
|
|
|
|
|
last if length($i) == length($a); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
else{ |
|
29
|
0
|
|
|
|
|
|
$i = substr($i,0,length($a)); |
|
30
|
0
|
|
|
|
|
|
last; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
for(my $c=0;$c
|
|
35
|
0
|
|
|
|
|
|
$E[$c] = ord(substr($i,$c,1)) ^ ord(substr($a,$c,1)); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
|
|
|
|
|
my @a= ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"); |
|
38
|
0
|
|
|
|
|
|
$i = "" ; |
|
39
|
0
|
|
|
|
|
|
for(my $c=0;$c<@E;$c++){ |
|
40
|
0
|
|
|
|
|
|
$i .= $a[ $E[$c] >>4 & 15 ]; |
|
41
|
0
|
|
|
|
|
|
$i .= $a[ $E[$c] & 15 ]; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
0
|
|
|
|
|
|
return $i; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub truncate { |
|
47
|
0
|
|
|
0
|
0
|
|
my $out_and_err = shift; |
|
48
|
0
|
|
|
|
|
|
my %p = @_; |
|
49
|
0
|
|
0
|
|
|
|
my $max_bytes = $p{max_bytes} || 200; |
|
50
|
0
|
|
0
|
|
|
|
my $max_lines = $p{max_lines} || 10; |
|
51
|
0
|
|
|
|
|
|
my $is_truncated = 0; |
|
52
|
0
|
0
|
|
|
|
|
if(length($out_and_err)>$max_bytes){ |
|
53
|
0
|
|
|
|
|
|
$out_and_err = substr($out_and_err,0,$max_bytes); |
|
54
|
0
|
|
|
|
|
|
$is_truncated = 1; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
0
|
|
|
|
|
|
my @l =split /\n/,$out_and_err,$max_lines+1; |
|
57
|
0
|
0
|
|
|
|
|
if(@l>$max_lines){ |
|
58
|
0
|
|
|
|
|
|
$out_and_err = join "\n",@l[0..$max_lines-1]; |
|
59
|
0
|
|
|
|
|
|
$is_truncated = 1; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
0
|
0
|
|
|
|
|
return $out_and_err. ($is_truncated?"\n(已截断)":""); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
sub code2state { |
|
64
|
0
|
|
|
0
|
0
|
|
my %c = qw( |
|
65
|
|
|
|
|
|
|
10 online |
|
66
|
|
|
|
|
|
|
20 offline |
|
67
|
|
|
|
|
|
|
30 away |
|
68
|
|
|
|
|
|
|
40 hidden |
|
69
|
|
|
|
|
|
|
50 busy |
|
70
|
|
|
|
|
|
|
60 callme |
|
71
|
|
|
|
|
|
|
70 silent |
|
72
|
|
|
|
|
|
|
); |
|
73
|
0
|
|
0
|
|
|
|
return $c{$_[0]} || "online"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
sub code2client { |
|
76
|
0
|
|
|
0
|
0
|
|
my %c = qw( |
|
77
|
|
|
|
|
|
|
1 pc |
|
78
|
|
|
|
|
|
|
21 mobile |
|
79
|
|
|
|
|
|
|
24 iphone |
|
80
|
|
|
|
|
|
|
41 web |
|
81
|
|
|
|
|
|
|
); |
|
82
|
0
|
|
0
|
|
|
|
return $c{$_[0]} || 'unknown'; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |