line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Session::Store::PHP; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
123
|
|
4
|
4
|
|
|
4
|
|
19
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
165
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.05; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
3341
|
use Apache::Session::File; |
|
4
|
|
|
|
|
97430
|
|
|
4
|
|
|
|
|
145
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
44
|
use Fcntl qw(:flock); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
562
|
|
10
|
4
|
|
|
4
|
|
24
|
use IO::File; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2666
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
9
|
|
|
9
|
0
|
15
|
my $class = shift; |
14
|
9
|
|
|
|
|
49
|
bless {}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _file { |
18
|
25
|
|
|
25
|
|
33
|
my($self, $session) = @_; |
19
|
25
|
|
50
|
|
|
71
|
my $directory = $session->{args}->{SavePath} || '/tmp'; |
20
|
25
|
|
|
|
|
57
|
my $file = $directory.'/sess_'.$session->{data}->{_session_id}; |
21
|
|
|
|
|
|
|
## taint safe |
22
|
25
|
|
|
|
|
94
|
( $file ) = $file =~ /^(.*)$/; |
23
|
25
|
|
|
|
|
232
|
return( $file ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub insert { |
27
|
3
|
|
|
3
|
0
|
158
|
my($self, $session) = @_; |
28
|
3
|
|
|
|
|
12
|
$self->_write($session, 1); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub update { |
32
|
4
|
|
|
4
|
0
|
258
|
my($self, $session) = @_; |
33
|
4
|
|
|
|
|
11
|
$self->_write($session, 0); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _write { |
37
|
7
|
|
|
7
|
|
10
|
my($self, $session, $check) = @_; |
38
|
|
|
|
|
|
|
|
39
|
7
|
50
|
66
|
|
|
32
|
if ($check && -e $self->_file($session)) { |
40
|
0
|
|
|
|
|
0
|
die "Object already exists in the data store"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
7
|
50
|
|
|
|
20
|
my $fh = IO::File->new(">".$self->_file($session)) |
44
|
|
|
|
|
|
|
or die "Could not open file: $!"; |
45
|
7
|
|
|
|
|
966
|
flock $fh, LOCK_EX; |
46
|
7
|
|
|
|
|
38
|
$fh->print($session->{serialized}); |
47
|
7
|
|
|
|
|
121
|
$fh->close; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub materialize { |
51
|
6
|
|
|
6
|
0
|
266
|
my($self, $session) = @_; |
52
|
6
|
|
|
|
|
15
|
my $file = $self->_file($session); |
53
|
6
|
50
|
|
|
|
91
|
-e $file or die "Object does not exist in the data store"; |
54
|
|
|
|
|
|
|
|
55
|
6
|
50
|
|
|
|
22
|
my $fh = IO::File->new($self->_file($session), O_RDWR|O_CREAT) |
56
|
|
|
|
|
|
|
or die "Could not open file: $!"; |
57
|
6
|
|
|
|
|
492
|
flock $fh, LOCK_EX; |
58
|
6
|
|
|
|
|
128
|
while (<$fh>) { |
59
|
6
|
|
|
|
|
40
|
$session->{serialized} .= $_; |
60
|
|
|
|
|
|
|
} |
61
|
6
|
|
|
|
|
93
|
close $fh; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub remove { |
65
|
3
|
|
|
3
|
0
|
2507
|
my($self, $session) = @_; |
66
|
3
|
|
|
|
|
10
|
my $file = $self->_file($session); |
67
|
3
|
50
|
|
|
|
323
|
unlink $file if -e $file; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |