| 1 | package CGI::Lazy::ID; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use Digest::MD5; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Time::HiRes qw(gettimeofday); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use CGI::Lazy::Globals; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | #--------------------------------------------------------------------------------------- | ||||||||||||
| 10 | 0 | ▶ | sub generate { | ||||||||||
|
Subroutine
generate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 11 | 0 | 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 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 22 | 0 | my $class = shift; | |||||||||||
| 23 | 0 | my $session = shift; | |||||||||||
| 24 | |||||||||||||
| 25 | 0 | srand; | |||||||||||
| 26 | |||||||||||||
| 27 | 0 | bless {_session => $session}, $class; | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | #--------------------------------------------------------------------------------------- | ||||||||||||
| 31 | 0 | ▶ | sub session { | ||||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||
| 33 | 0 | return $self->{_session}; | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | #--------------------------------------------------------------------------------------- | ||||||||||||
| 37 | 0 | ▶ | sub valid { | ||||||||||
|
Subroutine
valid: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||
| 39 | 0 | ▶ | my $sessionID = shift || ''; | ||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 40 | |||||||||||||
| 41 | 0 | return $sessionID =~ m/^[\w\d-]{22}$/; | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 1 | 1 | |||||||||||
| 45 | |||||||||||||
| 46 | __END__ | ||||||||||||