line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#############################################################################
|
2
|
|
|
|
|
|
|
## Name: AutoSession.pm
|
3
|
|
|
|
|
|
|
## Purpose: AutoSession
|
4
|
|
|
|
|
|
|
## Author: Graciliano M. P.
|
5
|
|
|
|
|
|
|
## Modified by:
|
6
|
|
|
|
|
|
|
## Created: 20/5/2003
|
7
|
|
|
|
|
|
|
## RCS-ID:
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2003 Graciliano M. P.
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself
|
11
|
|
|
|
|
|
|
#############################################################################
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package AutoSession ;
|
14
|
|
|
|
|
|
|
our $VERSION = '0.01' ;
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
7857
|
use strict qw(vars) ;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
17
|
1
|
|
|
1
|
|
7
|
no warnings ;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
687
|
use AutoSession::TieHandle ;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
20
|
1
|
|
|
1
|
|
633
|
use AutoSession::Driver ;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use overload (
|
23
|
1
|
|
|
|
|
7
|
'%{}' => '_OVER_get_hash' ,
|
24
|
|
|
|
|
|
|
'fallback' => 1 ,
|
25
|
1
|
|
|
1
|
|
1928
|
) ;
|
|
1
|
|
|
|
|
1390
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
81
|
use vars qw($AUTOLOAD $WITH_HPL $DEF_EXPIRE $DEF_IDSIZE) ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1315
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$DEF_EXPIRE = 60*60 ;
|
30
|
|
|
|
|
|
|
$DEF_IDSIZE = 32 ;
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
##########
|
33
|
|
|
|
|
|
|
# IMPORT #
|
34
|
|
|
|
|
|
|
##########
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub import {
|
37
|
1
|
|
|
1
|
|
6
|
my $class = shift ;
|
38
|
1
|
50
|
|
|
|
2223
|
if ($_[0] =~ /HPL/i) { $WITH_HPL = 1 ;}
|
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
############
|
42
|
|
|
|
|
|
|
# AUTOLOAD #
|
43
|
|
|
|
|
|
|
############
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub AUTOLOAD {
|
46
|
7
|
|
|
7
|
|
683
|
my $this = shift ;
|
47
|
7
|
50
|
|
|
|
27
|
if (! $$this->{driver}) { return ;}
|
|
0
|
|
|
|
|
0
|
|
48
|
7
|
|
|
|
|
592
|
my ($sub) = ( $AUTOLOAD =~ /^\w+:+([\w:]+)/s ) ;
|
49
|
7
|
|
|
|
|
51
|
$$this->{driver}->$sub(@_) ;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#######
|
53
|
|
|
|
|
|
|
# NEW #
|
54
|
|
|
|
|
|
|
#######
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new {
|
57
|
1
|
|
|
1
|
1
|
100
|
my $class = shift ;
|
58
|
1
|
|
|
|
|
7
|
my ( %args ) = @_ ;
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
3
|
my $saver = {} ;
|
61
|
1
|
|
|
|
|
4
|
my $this = \$saver ;
|
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
3
|
bless($this,$class) ;
|
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
10
|
$$this->{driver} = AutoSession::Driver->new(@_) ;
|
66
|
|
|
|
|
|
|
|
67
|
1
|
50
|
|
|
|
6
|
if (! $$this->{driver}) { return undef ;}
|
|
0
|
|
|
|
|
0
|
|
68
|
|
|
|
|
|
|
|
69
|
1
|
|
50
|
|
|
11
|
my $name = $args{name} || 'SESSION' ;
|
70
|
1
|
|
|
|
|
4
|
$name =~ s/\W//gs ;
|
71
|
1
|
|
|
|
|
4
|
$name = uc($name) ;
|
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
3
|
$$this->{name} = $name ;
|
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
10
|
$this->check_expired ;
|
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
7
|
return( $this ) ;
|
78
|
|
|
|
|
|
|
}
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
######
|
81
|
|
|
|
|
|
|
# ID #
|
82
|
|
|
|
|
|
|
######
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub id {
|
85
|
1
|
|
|
1
|
1
|
7
|
my $this = shift ;
|
86
|
1
|
|
|
|
|
6
|
return $$this->{driver}->{id} ;
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
########
|
90
|
|
|
|
|
|
|
# NAME #
|
91
|
|
|
|
|
|
|
########
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub name {
|
94
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
95
|
0
|
|
|
|
|
0
|
return $$this->{name} ;
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
##########
|
99
|
|
|
|
|
|
|
# DRIVER #
|
100
|
|
|
|
|
|
|
##########
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub driver {
|
103
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
104
|
0
|
|
|
|
|
0
|
return uc($$this->{driver}->{type}) ;
|
105
|
|
|
|
|
|
|
}
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#############
|
108
|
|
|
|
|
|
|
# DIRECTORY #
|
109
|
|
|
|
|
|
|
#############
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub directory {
|
112
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
113
|
0
|
|
|
|
|
0
|
return $$this->{driver}->{dir} ;
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
############
|
117
|
|
|
|
|
|
|
# AUTOLOAD #
|
118
|
|
|
|
|
|
|
############
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub autoload {
|
121
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
122
|
0
|
|
|
|
|
0
|
return $$this->{autoload} ;
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
##########
|
126
|
|
|
|
|
|
|
# EXISTS #
|
127
|
|
|
|
|
|
|
##########
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub exists {
|
130
|
0
|
|
|
0
|
0
|
0
|
my $this = shift ;
|
131
|
0
|
0
|
|
|
|
0
|
if ( $this->exist_id ) { return 1 ;}
|
|
0
|
|
|
|
|
0
|
|
132
|
0
|
|
|
|
|
0
|
return undef ;
|
133
|
|
|
|
|
|
|
}
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
###############
|
136
|
|
|
|
|
|
|
# COOKIE_LINE #
|
137
|
|
|
|
|
|
|
###############
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub cookie_line {
|
140
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
141
|
0
|
|
|
|
|
0
|
my $name = $this->name ;
|
142
|
0
|
|
|
|
|
0
|
my $id = $this->id ;
|
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
my $line = qq`Set-Cookie: AutoSession=$name:$id` ;
|
145
|
0
|
|
|
|
|
0
|
return( $line ) ;
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
############
|
149
|
|
|
|
|
|
|
# HASH_REF #
|
150
|
|
|
|
|
|
|
############
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub hash_ref {
|
153
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ;
|
154
|
0
|
|
|
|
|
0
|
return $$this->{driver}{tree} ;
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
##################
|
158
|
|
|
|
|
|
|
# _OVER_GET_HASH #
|
159
|
|
|
|
|
|
|
##################
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _OVER_get_hash {
|
162
|
6
|
|
|
6
|
|
129
|
my $this = shift ;
|
163
|
|
|
|
|
|
|
|
164
|
6
|
50
|
|
|
|
25
|
if ( $$this->{driver}{closed} ) { return( {} ) ;}
|
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
|
166
|
6
|
100
|
|
|
|
19
|
if ( ! $$this->{hash} ) {
|
167
|
1
|
|
|
|
|
1
|
my %hash ;
|
168
|
1
|
|
|
|
|
4
|
$$this->{hash} = \%hash ;
|
169
|
1
|
|
|
|
|
593
|
tie(%hash, 'AutoSession::TieHandle' , $$this->{driver}) ;
|
170
|
1
|
|
|
|
|
7
|
$$this->{driver}->load ;
|
171
|
|
|
|
|
|
|
}
|
172
|
|
|
|
|
|
|
|
173
|
6
|
|
|
|
|
51
|
return( $$this->{hash} ) ;
|
174
|
|
|
|
|
|
|
}
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
###########
|
177
|
|
|
|
|
|
|
# DESTROY #
|
178
|
|
|
|
|
|
|
###########
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub DESTROY {
|
181
|
1
|
|
|
1
|
|
2
|
my $this = shift ;
|
182
|
|
|
|
|
|
|
|
183
|
1
|
50
|
|
|
|
11
|
$this->check_expired if $$this->{driver} ;
|
184
|
|
|
|
|
|
|
|
185
|
1
|
|
|
|
|
5
|
delete $$this->{driver} ;
|
186
|
|
|
|
|
|
|
|
187
|
1
|
|
|
|
|
4
|
untie $$this->{hash} ;
|
188
|
1
|
|
|
|
|
152
|
delete $$this->{hash} ;
|
189
|
|
|
|
|
|
|
}
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
#######
|
192
|
|
|
|
|
|
|
# END #
|
193
|
|
|
|
|
|
|
#######
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1;
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
__END__
|