| 1 | package Web::Session::File; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Apache::Session; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Apache::Session::Lock::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Web::Session::Store::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Web::Session::Generate::SHA256; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Web::Session::Serialize::JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Web::Session::_common; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use constant SL => ( $^O and $^O =~ /(?:MSWin|Windows)/i ? '\\' : '/' ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=12.5
Branch: 1 branch
Condition33%1/3
$^O && ($^O =~ /(?:MSWin|Windows)/i ? '\\' : '/')
MC/DC0%0/2
$^O && ($^O =~ /(?:MSWin|Windows)/i ? '\\' : '/')
$^O
($^O =~ /(?:MSWin|Windows)/i ? '\\' : '/')
Truth table33%1/3
A && B
A= $^OB= ($^O =~ /(?:MSWin|Windows)/i ? '\\' : '/')
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | our $VERSION = '1.0.0'; | |||||||||||||||||||||||||||
| 15 | 5 | our @ISA = qw(Apache::Session Web::Session::_common); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 52 | ▶ | sub populate { | ||||||||||||||||||||||||||
|
Subroutine
populate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 52 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 52 | $self->{object_store} = new Web::Session::Store::File $self; | |||||||||||||||||||||||||||
| 21 | 52 | $self->{lock_manager} = new Apache::Session::Lock::File $self; | |||||||||||||||||||||||||||
| 22 | 52 | $self->{generate} = \&Web::Session::Generate::SHA256::generate; | |||||||||||||||||||||||||||
| 23 | 52 | $self->{validate} = \&Web::Session::Generate::SHA256::validate; | |||||||||||||||||||||||||||
| 24 | 52 | $self->{serialize} = \&Web::Session::Serialize::JSON::serialize; | |||||||||||||||||||||||||||
| 25 | 52 | $self->{unserialize} = \&Web::Session::Serialize::JSON::unserialize; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 52 | return $self; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 52 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 52 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 52 | $self->save; | |||||||||||||||||||||||||||
| 34 | 52 | $self->{object_store}->close; | |||||||||||||||||||||||||||
| 35 | 52 | $self->release_all_locks; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 51 | ▶ | sub get_key_from_all_sessions { | ||||||||||||||||||||||||||
|
Subroutine
get_key_from_all_sessions: called CC=11 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 51 | my ( $class, $args, $data ) = @_; | |||||||||||||||||||||||||||
| 40 | 51 | ▶ | $args->{Directory} ||= $Apache::Session::Store::File::Directory; | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{"Directory"} ||= $Apache::Session::Store::File::Directory
MC/DC0%0/2
$args->{"Directory"} ||= $Apache::Session::Store::File::Directory
$args->{"Directory"}
$Apache::Session::Store::File::Directory
Truth table33%1/3
A ||= B
A= $args->{"Directory"}B= $Apache::Session::Store::File::Directory
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 51 | ▶ | unless ( opendir DIR, $args->{Directory} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | die "Cannot open directory $args->{Directory}\n"; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | my @t = | ||||||||||||||||||||||||||||
| 46 | 51 | ▶ | grep { -f $args->{Directory} . SL . $_ and /^[A-Za-z0-9@\-]+$/ } | ||||||||||||||||||||||||||
|
Condition100%3/3
-f $args->{'Directory'} . '/' . $_ && /^[A-Za-z0-9\@\-]+$/
MC/DC100%2/2
-f $args->{'Directory'} . '/' . $_ && /^[A-Za-z0-9\@\-]+$/
-f $args->{'Directory'} . '/' . $_
/^[A-Za-z0-9\@\-]+$/
Truth table100%3/3
A && B
A= -f $args->{'Directory'} . '/' . $_B= /^[A-Za-z0-9\@\-]+$/
| |||||||||||||||||||||||||||||
| 47 | readdir(DIR); | ||||||||||||||||||||||||||||
| 48 | 51 | closedir DIR; | |||||||||||||||||||||||||||
| 49 | 51 | my %res; | |||||||||||||||||||||||||||
| 50 | 51 | for my $f (@t) { | |||||||||||||||||||||||||||
| 51 | 348 | eval { | |||||||||||||||||||||||||||
| 52 | 348 | ▶ | open F, $args->{Directory} . SL . $f or die $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 348 | my $row = join '', <F>; | |||||||||||||||||||||||||||
| 54 | 348 | ▶ | if ( ref($data) eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 55 | 248 | $res{$f} = | |||||||||||||||||||||||||||
| 56 | &$data( &Web::Session::Serialize::JSON::_unserialize($row), | ||||||||||||||||||||||||||||
| 57 | $f ); | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | elsif ($data) { | ||||||||||||||||||||||||||||
| 60 | 64 | ▶ | $data = [$data] unless ( ref($data) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 64 | my $tmp = &Web::Session::Serialize::JSON::_unserialize($row); | |||||||||||||||||||||||||||
| 62 | 64 | $res{$f}->{$_} = $tmp->{$_} foreach (@$data); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 36 | $res{$f} = | |||||||||||||||||||||||||||
| 66 | &Web::Session::Serialize::JSON::_unserialize($row); | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||
| 69 | 348 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | print STDERR "Error in session $f: $@\n"; | |||||||||||||||||||||||||||
| 71 | 0 | delete $res{$f}; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 51 | return \%res; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 5 | 1; | |||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||