line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Lazy::ID; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Digest::MD5; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
6
|
1
|
|
|
1
|
|
7
|
use Time::HiRes qw(gettimeofday); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
7
|
1
|
|
|
1
|
|
184
|
use CGI::Lazy::Globals; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
805
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
sub generate { |
11
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my($s,$us)=gettimeofday(); |
14
|
0
|
|
|
|
|
|
my($v)=sprintf("%09d%06d%10d%06d%255s",rand(999999999),$us,$s,$$,$self->session->config->configfile); |
15
|
0
|
|
|
|
|
|
my $id = Digest::MD5::md5_base64($v); |
16
|
0
|
|
|
|
|
|
$id =~ tr{+/}{_-}; |
17
|
0
|
|
|
|
|
|
return $id; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------- |
21
|
|
|
|
|
|
|
sub new { |
22
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
23
|
0
|
|
|
|
|
|
my $session = shift; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
srand; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
bless {_session => $session}, $class; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------- |
31
|
|
|
|
|
|
|
sub session { |
32
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
33
|
0
|
|
|
|
|
|
return $self->{_session}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------- |
37
|
|
|
|
|
|
|
sub valid { |
38
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
39
|
0
|
|
0
|
|
|
|
my $sessionID = shift || ''; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $sessionID =~ m/^[\w\d-]{22}$/; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |