| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebDAO::Session; |
|
2
|
|
|
|
|
|
|
#$Id$ |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
WebDAO::Session - Session interface to protocol specific function |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Session interface to device(HTTP protocol) specific function |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
16
|
5
|
|
|
5
|
|
26
|
use WebDAO; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
283
|
|
|
17
|
5
|
|
|
5
|
|
1360
|
use WebDAO::CV; |
|
|
5
|
|
|
|
|
81
|
|
|
|
5
|
|
|
|
|
215
|
|
|
18
|
5
|
|
|
5
|
|
1960
|
use WebDAO::Response; |
|
|
5
|
|
|
|
|
17
|
|
|
|
5
|
|
|
|
|
313
|
|
|
19
|
5
|
|
|
5
|
|
2554
|
use Encode qw(encode decode is_utf8); |
|
|
5
|
|
|
|
|
37590
|
|
|
|
5
|
|
|
|
|
369
|
|
|
20
|
5
|
|
|
5
|
|
43
|
use strict; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
107
|
|
|
21
|
5
|
|
|
5
|
|
31
|
use warnings; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
2676
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
mk_attr( |
|
24
|
|
|
|
|
|
|
Cgi_obj => undef, # request object |
|
25
|
|
|
|
|
|
|
Cgi_env => undef, |
|
26
|
|
|
|
|
|
|
U_id=> undef, |
|
27
|
|
|
|
|
|
|
Params => undef, |
|
28
|
|
|
|
|
|
|
_response_obj=> undef, #deprecated ? |
|
29
|
|
|
|
|
|
|
_is_absolute_url =>undef #deprecated ? |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
|
33
|
4
|
|
|
4
|
0
|
1574
|
my $class = shift; |
|
34
|
4
|
|
|
|
|
10
|
my $self = {}; |
|
35
|
4
|
|
|
|
|
8
|
my $stat; |
|
36
|
4
|
|
|
|
|
11
|
bless( $self, $class ); |
|
37
|
4
|
|
|
|
|
20
|
$self->_init(@_); |
|
38
|
4
|
|
|
|
|
51
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _init { |
|
43
|
|
|
|
|
|
|
#Parametrs is realm |
|
44
|
4
|
|
|
4
|
|
11
|
my $self = shift; |
|
45
|
4
|
|
|
|
|
10
|
my %args = @_; |
|
46
|
4
|
|
|
|
|
95
|
U_id $self undef; |
|
47
|
|
|
|
|
|
|
Cgi_obj $self $args{cv} |
|
48
|
4
|
|
33
|
|
|
39
|
|| new WebDAO::CV::; #create default controller |
|
49
|
4
|
|
|
|
|
67
|
my $cv = $self->Cgi_obj; # Store Cgi_obj in local var |
|
50
|
|
|
|
|
|
|
#create response object |
|
51
|
4
|
|
|
|
|
30
|
$self->_response_obj( |
|
52
|
|
|
|
|
|
|
new WebDAO::Response:: |
|
53
|
|
|
|
|
|
|
cv => $cv |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
25
|
Cgi_env $self ( |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
|
|
|
|
|
|
url => $cv->url( -base => 1 ), #http://eng.zag |
|
59
|
|
|
|
|
|
|
path_info => $cv->url( -absolute => 1, -path_info => 1 ), |
|
60
|
|
|
|
|
|
|
path_info_elments => [], |
|
61
|
|
|
|
|
|
|
file => "", |
|
62
|
|
|
|
|
|
|
base_url => $cv->url( -base => 1 ), #http://base.com |
|
63
|
|
|
|
|
|
|
accept => $cv->accept, |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
|
|
67
|
4
|
|
|
|
|
25
|
Params $self ( $self->_get_params() ); |
|
68
|
4
|
|
|
|
|
65
|
$self->Cgi_env->{path_info_elments} = $self->call_path($self->Cgi_env->{path_info}); |
|
69
|
|
|
|
|
|
|
#set default header |
|
70
|
4
|
|
|
|
|
21
|
$cv->set_header("Content-Type" => 'text/html; charset=utf-8'); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#Get cgi params; |
|
75
|
|
|
|
|
|
|
sub _get_params { |
|
76
|
7
|
|
|
7
|
|
15
|
my $self = shift; |
|
77
|
7
|
|
|
|
|
114
|
my $_cgi = $self->Cgi_obj(); |
|
78
|
7
|
|
|
|
|
18
|
my %params; |
|
79
|
7
|
|
|
|
|
26
|
foreach my $i ( $_cgi->param() ) { |
|
80
|
0
|
|
|
|
|
0
|
my @all = $_cgi->param($i); |
|
81
|
0
|
|
|
|
|
0
|
foreach my $value (@all) { |
|
82
|
0
|
0
|
|
|
|
0
|
next if ref $value; |
|
83
|
0
|
0
|
|
|
|
0
|
$value = decode( 'utf8', $value ) unless is_utf8($value); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
0
|
|
|
|
0
|
$params{$i} = scalar @all > 1 ? \@all : $all[0]; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
7
|
|
|
|
|
146
|
return \%params; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#Can be overlap if you choose another |
|
92
|
|
|
|
|
|
|
#alghoritm generate unique session ID (i.e cookie,http_auth) |
|
93
|
|
|
|
|
|
|
sub get_id { |
|
94
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
95
|
0
|
|
|
|
|
0
|
my $coo = U_id $self; |
|
96
|
0
|
0
|
|
|
|
0
|
return $coo if ($coo); |
|
97
|
0
|
|
|
|
|
0
|
return rand(100); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 call_path [$url] |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Return ref to array of element from $url or from CGI ENV |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub call_path { |
|
107
|
4
|
|
|
4
|
1
|
9
|
my $self = shift; |
|
108
|
4
|
|
50
|
|
|
70
|
my $url = shift || return $self->Cgi_env->{path_info_elments}; |
|
109
|
0
|
|
|
|
|
|
$url =~ s%^/%%; |
|
110
|
0
|
|
|
|
|
|
$url =~ s%/$%%; |
|
111
|
0
|
|
|
|
|
|
return [ grep { defined $_ } split( /\//, $url ) ]; |
|
|
0
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 set_absolute_url 1|0 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Set flag for build absolute pathes. Return previus value. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub set_absolute_url { |
|
122
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
123
|
0
|
|
|
|
|
|
my $value = shift; |
|
124
|
0
|
|
|
|
|
|
my $prev_value = $self->_is_absolute_url; |
|
125
|
0
|
0
|
|
|
|
|
$self->_is_absolute_url($value) if defined $value; |
|
126
|
0
|
|
|
|
|
|
return $prev_value; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub get_request { |
|
130
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
131
|
0
|
|
|
|
|
|
return $self->Cgi_obj; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#deprecated ??? use WebDAO::Engine::response |
|
135
|
|
|
|
|
|
|
sub response_obj { |
|
136
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
137
|
0
|
|
|
|
|
|
return $self->_response_obj; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub print { |
|
141
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
142
|
0
|
|
|
|
|
|
$self->Cgi_obj->print(@_); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub ExecEngine { |
|
146
|
0
|
|
|
0
|
0
|
|
my ( $self, $eng_ref,$path ) = @_; |
|
147
|
0
|
|
|
|
|
|
$eng_ref->_execute($self, $path); |
|
148
|
0
|
|
|
|
|
|
$eng_ref->__send_event__("_sess_ended"); # TODO: deprecated : delete this line |
|
149
|
0
|
|
|
|
|
|
$eng_ref->_commit(); |
|
150
|
0
|
|
|
|
|
|
$eng_ref->_destroy; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub destroy { |
|
154
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
155
|
0
|
|
|
|
|
|
$self->_response_obj(undef); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
1; |
|
158
|
|
|
|
|
|
|
__DATA__ |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
http://webdao.sourceforge.net |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Zahatski Aliaksandr, E<lt>zag@cpan.orgE<gt> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Copyright 2002-2012 by Zahatski Aliaksandr |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
173
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|