line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
################################################################################### |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de |
5
|
|
|
|
|
|
|
# Embperl - Copyright (c) 2008-2014 Gerald Richter |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
8
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the Perl README file. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
11
|
|
|
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
12
|
|
|
|
|
|
|
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# $Id: Embperl.pm 1578075 2014-03-16 14:01:14Z richter $ |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
################################################################################### |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Embperl; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
require Cwd ; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require Exporter; |
24
|
|
|
|
|
|
|
require DynaLoader; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
27693
|
use Embperl::Syntax ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
931
|
|
27
|
1
|
|
|
1
|
|
3323
|
use Embperl::Recipe ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
64
|
|
28
|
1
|
|
|
1
|
|
1162
|
use Embperl::Constant ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
60
|
|
29
|
1
|
|
|
1
|
|
1567
|
use Embperl::Util ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
30
|
1
|
|
|
1
|
|
1346
|
use Embperl::Out ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
31
|
1
|
|
|
1
|
|
1155
|
use Embperl::Log ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
32
|
1
|
|
|
1
|
|
1095
|
use Embperl::App ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
14
|
use strict ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
72
|
|
35
|
1
|
|
|
|
|
2049
|
use vars qw( |
36
|
|
|
|
|
|
|
@ISA |
37
|
|
|
|
|
|
|
$VERSION |
38
|
|
|
|
|
|
|
$cwd |
39
|
|
|
|
|
|
|
$req_rec |
40
|
|
|
|
|
|
|
$srv_rec |
41
|
|
|
|
|
|
|
$importno |
42
|
|
|
|
|
|
|
%initparam |
43
|
|
|
|
|
|
|
$modperl |
44
|
|
|
|
|
|
|
$modperl2 |
45
|
|
|
|
|
|
|
$modperlapi |
46
|
|
|
|
|
|
|
$req |
47
|
|
|
|
|
|
|
$app |
48
|
1
|
|
|
1
|
|
8
|
) ; |
|
1
|
|
|
|
|
3
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$VERSION = '2.5.0' ; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ($modperl = $ENV{MOD_PERL}) |
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
$modperl =~ m#/(\d+)\.(\d+)# ; |
59
|
|
|
|
|
|
|
$modperl2 = 1 if ($1 == 2 || ($1 == 1 && $2 >= 99)) ; |
60
|
|
|
|
|
|
|
$modperlapi = $ENV{MOD_PERL_API_VERSION} || 1 ; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if ($ENV{PERL_DL_NONLAZY} |
64
|
|
|
|
|
|
|
&& substr($ENV{GATEWAY_INTERFACE} || '', 0, 8) ne 'CGI-Perl' |
65
|
|
|
|
|
|
|
&& defined &DynaLoader::boot_DynaLoader) |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
$ENV{PERL_DL_NONLAZY} = '0'; |
68
|
|
|
|
|
|
|
DynaLoader::boot_DynaLoader ('DynaLoader'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if ($modperl2) |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
if ($modperlapi >= 2) |
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
require Apache2::ServerRec ; |
76
|
|
|
|
|
|
|
require Apache2::ServerUtil ; |
77
|
|
|
|
|
|
|
require Apache2::RequestRec ; |
78
|
|
|
|
|
|
|
require Apache2::RequestUtil ; |
79
|
|
|
|
|
|
|
require Apache2::SubRequest ; |
80
|
|
|
|
|
|
|
require APR::Table ; |
81
|
|
|
|
|
|
|
$srv_rec = Apache2::ServerUtil -> server ; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else |
84
|
|
|
|
|
|
|
{ |
85
|
|
|
|
|
|
|
if (($modperl =~ /_(\d+)/) && $1 < 15) |
86
|
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
require Apache::Server ; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
require Apache::ServerRec ; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
require Apache::ServerUtil ; |
94
|
|
|
|
|
|
|
require Apache::RequestRec ; |
95
|
|
|
|
|
|
|
require Apache::RequestUtil ; |
96
|
|
|
|
|
|
|
require Apache::SubRequest ; |
97
|
|
|
|
|
|
|
$srv_rec = Apache -> server ; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
elsif ($modperl) |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
require Apache ; |
103
|
|
|
|
|
|
|
$srv_rec = Apache -> server ; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
if (!defined(&Embperl::Init)) |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
bootstrap Embperl $VERSION ; |
109
|
|
|
|
|
|
|
Boot ($VERSION) ; |
110
|
|
|
|
|
|
|
Init ($srv_rec, \%initparam) ; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$cwd = Cwd::fastcwd(); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
tie *Embperl::LOG, 'Embperl::Log' ; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1 ; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
####################################################################################### |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub Execute |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
{ |
126
|
58
|
|
|
58
|
0
|
104
|
my $_ep_param = shift ; |
127
|
|
|
|
|
|
|
|
128
|
58
|
|
|
|
|
377
|
local $SIG{__WARN__} = \&Warn ; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# when called inside a Embperl Request, Execute the component only |
131
|
58
|
50
|
|
|
|
213
|
return Embperl::Req::ExecuteComponent ($_ep_param, @_) if ($req) ; |
132
|
|
|
|
|
|
|
|
133
|
58
|
50
|
|
|
|
174
|
$_ep_param = { inputfile => $_ep_param, param => [@_]} if (!ref $_ep_param) ; |
134
|
|
|
|
|
|
|
|
135
|
58
|
|
|
|
|
99
|
local $req_rec ; |
136
|
58
|
50
|
33
|
|
|
438
|
if ($modperl && !exists ($_ep_param -> {req_rec})) |
|
|
50
|
33
|
|
|
|
|
137
|
|
|
|
|
|
|
{ |
138
|
|
|
|
|
|
|
eval |
139
|
0
|
|
|
|
|
0
|
{ |
140
|
0
|
0
|
|
|
|
0
|
if ($modperlapi < 2) |
141
|
|
|
|
|
|
|
{ |
142
|
0
|
|
|
|
|
0
|
$req_rec = Apache -> request ; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else |
145
|
|
|
|
|
|
|
{ |
146
|
0
|
|
|
|
|
0
|
$req_rec = Apache2::RequestUtil -> request ; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} ; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
elsif (exists ($_ep_param -> {req_rec}) && defined ($_ep_param -> {req_rec})) |
151
|
|
|
|
|
|
|
{ |
152
|
0
|
|
|
|
|
0
|
$req_rec = $_ep_param -> {req_rec} ; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
58
|
|
|
|
|
96
|
my $_ep_rc ; |
156
|
|
|
|
|
|
|
{ |
157
|
58
|
|
|
|
|
81
|
$_ep_rc = Embperl::Req::ExecuteRequest (undef, $_ep_param) ; |
|
58
|
|
|
|
|
11592
|
|
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
58
|
|
|
|
|
564
|
return $_ep_rc ; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
####################################################################################### |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub handler |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
{ |
168
|
0
|
|
|
0
|
0
|
0
|
local $SIG{__WARN__} = \&Warn ; |
169
|
0
|
|
|
|
|
0
|
$req_rec = $_[0] ; |
170
|
0
|
0
|
|
|
|
0
|
if ($modperlapi < 2) |
171
|
|
|
|
|
|
|
{ |
172
|
0
|
|
|
|
|
0
|
Apache -> request ($req_rec) ; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
else |
175
|
|
|
|
|
|
|
{ |
176
|
0
|
|
|
|
|
0
|
Apache2::RequestUtil -> request ($req_rec) ; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
0
|
my $rc = Embperl::Req::ExecuteRequest ($_[0]) ; |
180
|
0
|
|
|
|
|
0
|
return $rc ; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
####################################################################################### |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub Warn |
186
|
|
|
|
|
|
|
{ |
187
|
75
|
|
|
75
|
0
|
227
|
local $^W = 0 ; |
188
|
75
|
|
|
|
|
105
|
my $msg = $_[0] ; |
189
|
75
|
|
|
|
|
119
|
chop ($msg) ; |
190
|
|
|
|
|
|
|
|
191
|
75
|
|
|
|
|
875
|
my $lineno = getlineno () ; |
192
|
75
|
|
|
|
|
248
|
my $Inputfile = Sourcefile () ; |
193
|
75
|
50
|
|
|
|
236
|
if ($msg =~ /Embperl\.pm/) |
194
|
|
|
|
|
|
|
{ |
195
|
0
|
|
|
|
|
0
|
$msg =~ s/at (.*?) line (\d*)/at $Inputfile in block starting at line $lineno/ ; |
196
|
|
|
|
|
|
|
} |
197
|
75
|
|
|
|
|
12385
|
logerror (Embperl::Constant::rcPerlWarn, $msg); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
####################################################################################### |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub PreLoadFiles |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
{ |
206
|
1
|
|
|
1
|
0
|
3
|
my $files = $initparam{preloadfiles} ; |
207
|
1
|
|
|
|
|
3
|
delete $initparam{preloadfiles} ; |
208
|
|
|
|
|
|
|
|
209
|
1
|
50
|
33
|
|
|
6
|
if ($files && ref $files eq 'ARRAY') |
210
|
|
|
|
|
|
|
{ |
211
|
0
|
|
|
|
|
0
|
foreach my $file (@$files) |
212
|
|
|
|
|
|
|
{ |
213
|
0
|
0
|
|
|
|
0
|
if (ref $file) |
214
|
|
|
|
|
|
|
{ |
215
|
0
|
|
|
|
|
0
|
Execute ({%$file, import => 0}) ; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
else |
218
|
|
|
|
|
|
|
{ |
219
|
0
|
|
|
|
|
0
|
Execute ({inputfile => $file, import => 0}) ; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
####################################################################################### |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
package Embperl::Req ; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
####################################################################################### |
230
|
|
|
|
|
|
|
|
231
|
1
|
|
|
1
|
|
10
|
use strict ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2495
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
if ($Embperl::modperl) |
234
|
|
|
|
|
|
|
{ |
235
|
|
|
|
|
|
|
if (!$Embperl::modperl2) |
236
|
|
|
|
|
|
|
{ |
237
|
|
|
|
|
|
|
eval 'use Apache::Constants qw(&OPT_EXECCGI &DECLINED &OK &FORBIDDEN)' ; |
238
|
|
|
|
|
|
|
die "use Apache::Constants failed: $@" if ($@); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
elsif ($Embperl::modperlapi >= 2) |
241
|
|
|
|
|
|
|
{ |
242
|
|
|
|
|
|
|
eval 'use Apache2::Const qw(&OPT_EXECCGI &DECLINED &OK &FORBIDDEN)' ; |
243
|
|
|
|
|
|
|
die "use Apache2::Const failed: $@" if ($@); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
else |
246
|
|
|
|
|
|
|
{ |
247
|
|
|
|
|
|
|
eval 'use Apache::Const qw(&OPT_EXECCGI &DECLINED &OK &FORBIDDEN)' ; |
248
|
|
|
|
|
|
|
die "use Apache::Const failed: $@" if ($@); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
####################################################################################### |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub ExecuteComponent |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
{ |
257
|
43
|
|
|
43
|
|
70
|
my $_ep_param = shift ; |
258
|
43
|
|
|
|
|
46
|
my $rc ; |
259
|
|
|
|
|
|
|
|
260
|
43
|
100
|
|
|
|
1004
|
if (!ref $_ep_param) |
|
|
50
|
|
|
|
|
|
261
|
|
|
|
|
|
|
{ |
262
|
2
|
|
|
|
|
51
|
$rc = $Embperl::req -> execute_component ({ inputfile => $_ep_param, param => [@_]}) ; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
elsif ($_ep_param -> {object}) |
265
|
|
|
|
|
|
|
{ |
266
|
0
|
|
|
|
|
0
|
my $c = $Embperl::req -> setup_component ($_ep_param) ; |
267
|
0
|
|
|
|
|
0
|
my $rc = $c -> run ; |
268
|
0
|
|
|
|
|
0
|
my $package = $c -> curr_package ; |
269
|
0
|
|
|
|
|
0
|
$c -> cleanup ; |
270
|
0
|
0
|
|
|
|
0
|
if (!$rc) |
271
|
|
|
|
|
|
|
{ |
272
|
0
|
|
|
|
|
0
|
my $object = {} ; |
273
|
0
|
|
|
|
|
0
|
bless $object, $package ; |
274
|
0
|
|
|
|
|
0
|
return $object ; |
275
|
|
|
|
|
|
|
} |
276
|
0
|
|
|
|
|
0
|
return undef ; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
else |
279
|
|
|
|
|
|
|
{ |
280
|
41
|
|
|
|
|
1521
|
$rc = $Embperl::req -> execute_component ($_ep_param) ; |
281
|
|
|
|
|
|
|
} |
282
|
43
|
50
|
|
|
|
3175
|
Embperl::exit() if ($Embperl::req -> had_exit) ; |
283
|
|
|
|
|
|
|
|
284
|
43
|
|
|
|
|
126
|
return $rc ; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
####################################################################################### |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub get_multipart_formdata |
290
|
|
|
|
|
|
|
{ |
291
|
0
|
|
|
0
|
|
|
my ($self) = @_ ; |
292
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
my $dbgForm = $self -> config -> debug & Embperl::Constant::dbgForm ; |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# just let CGI.pm read the multipart form data, see cgi docu |
296
|
0
|
0
|
|
|
|
|
if ($Embperl::modperl2) |
297
|
|
|
|
|
|
|
{ |
298
|
0
|
0
|
|
|
|
|
if ($Embperl::modperlapi < 2) |
299
|
|
|
|
|
|
|
{ |
300
|
|
|
|
|
|
|
require Apache::compat # Apache::compat is needed for CGI.pm |
301
|
0
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
else |
303
|
|
|
|
|
|
|
{ |
304
|
|
|
|
|
|
|
require Apache2::compat # Apache::compat is needed for CGI.pm |
305
|
0
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
} |
307
|
0
|
|
|
|
|
|
require CGI ; |
308
|
|
|
|
|
|
|
|
309
|
0
|
|
|
|
|
|
my $cgi = new CGI ; |
310
|
0
|
|
|
|
|
|
my $fdat = $self -> thread -> form_hash ; |
311
|
0
|
|
|
|
|
|
$self -> param -> cgi ($cgi) ; # keep it until then end of the request |
312
|
|
|
|
|
|
|
# otherwsie templ files be |
313
|
|
|
|
|
|
|
# destroyed in CGI.pm 3.01+ |
314
|
0
|
|
|
|
|
|
my $ffld = $self -> thread -> form_array ; |
315
|
0
|
|
|
|
|
|
@$ffld = $cgi->param; |
316
|
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
$self -> log ("[$$]FORM: Read multipart formdata, length=$ENV{CONTENT_LENGTH}\n") if ($dbgForm) ; |
318
|
0
|
|
|
|
|
|
my $params ; |
319
|
0
|
|
|
|
|
|
foreach ( @$ffld ) |
320
|
|
|
|
|
|
|
{ |
321
|
|
|
|
|
|
|
# the param_fetch needs CGI.pm 2.43 |
322
|
0
|
|
|
|
|
|
$params = $cgi->param_fetch( -name => $_ ) ; |
323
|
|
|
|
|
|
|
#$params = $cgi->{$_} ; |
324
|
0
|
0
|
|
|
|
|
if ($#$params > 0) |
325
|
|
|
|
|
|
|
{ |
326
|
0
|
|
|
|
|
|
$fdat->{ $_ } = join ("\t", @$params) ; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
else |
329
|
|
|
|
|
|
|
{ |
330
|
0
|
|
|
|
|
|
$fdat->{ $_ } = $params -> [0] ; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
0
|
0
|
|
|
|
|
$self -> log ("[$$]FORM: $_=$fdat->{$_}\n") if ($dbgForm) ; |
334
|
|
|
|
|
|
|
|
335
|
0
|
0
|
|
|
|
|
if (ref($fdat->{$_}) eq 'Fh') |
336
|
|
|
|
|
|
|
{ |
337
|
0
|
|
|
|
|
|
$fdat->{"-$_"} = $cgi -> uploadInfo($fdat->{$_}) ; |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
####################################################################################### |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub SetupSession |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
{ |
349
|
0
|
|
|
0
|
|
|
my ($req_rec, $uid, $sid, $appparam) = @_ ; |
350
|
|
|
|
|
|
|
|
351
|
0
|
|
|
|
|
|
my ($rc, $thread, $app) = Embperl::InitAppForRequest ($req_rec, $appparam) ; |
352
|
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
my $cookie_name = $app -> config -> cookie_name ; |
354
|
0
|
0
|
|
|
|
|
my $debug = $appparam?$appparam -> {debug} & Embperl::Constant::dbgSession:0 ; |
355
|
0
|
0
|
|
|
|
|
if (!$uid) |
356
|
|
|
|
|
|
|
{ |
357
|
0
|
|
0
|
|
|
|
my $cookie_val = $ENV{HTTP_COOKIE} || ($req_rec?$req_rec->headers_in -> {'Cookie'}:undef) ; |
358
|
|
|
|
|
|
|
|
359
|
0
|
0
|
0
|
|
|
|
if ((defined ($cookie_val) && ($cookie_val =~ /$cookie_name=(.*?)(\;|\s|$)/)) || ($ENV{QUERY_STRING} =~ /$cookie_name=.*?:(.*?)(\;|\s|&|$)/) || $ENV{EMBPERL_UID} ) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
360
|
|
|
|
|
|
|
{ |
361
|
0
|
|
|
|
|
|
$uid = $1 ; |
362
|
0
|
0
|
|
|
|
|
print Embperl::LOG "[$$]SES: Received user session id $1\n" if ($debug) ; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
0
|
0
|
|
|
|
|
if (!$sid) |
368
|
|
|
|
|
|
|
{ |
369
|
0
|
0
|
|
|
|
|
if (($ENV{QUERY_STRING} =~ /${cookie_name}=(.*?)(\;|\s|&|:|$)/)) |
370
|
|
|
|
|
|
|
{ |
371
|
0
|
|
|
|
|
|
$sid = $1 ; |
372
|
0
|
0
|
|
|
|
|
print Embperl::LOG "[$$]SES: Received state session id $1\n" if ($debug) ; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
0
|
0
|
|
|
|
|
$app -> user_session -> setid ($uid) if ($uid) ; |
377
|
0
|
0
|
|
|
|
|
$app -> state_session -> setid ($sid) if ($sid) ; |
378
|
|
|
|
|
|
|
|
379
|
0
|
0
|
|
|
|
|
return wantarray?($app -> udat, $app -> mdat, $app -> sdat):$app -> udat ; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
####################################################################################### |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
sub GetSession |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
{ |
388
|
0
|
|
0
|
0
|
|
|
my $r = shift || Embperl::CurrReq () ; |
389
|
|
|
|
|
|
|
|
390
|
0
|
0
|
|
|
|
|
if ($r -> session_mgnt) |
391
|
|
|
|
|
|
|
{ |
392
|
0
|
0
|
|
|
|
|
return wantarray?($r -> app -> udat, $r -> app -> mdat, $r -> app -> sdat):$r -> app -> udat ; |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
else |
395
|
|
|
|
|
|
|
{ |
396
|
0
|
|
|
|
|
|
return undef ; # No session Management |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
####################################################################################### |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub DeleteSession |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
{ |
405
|
0
|
|
0
|
0
|
|
|
my $r = shift || Embperl::CurrReq () ; |
406
|
0
|
|
|
|
|
|
my $disabledelete = shift ; |
407
|
|
|
|
|
|
|
|
408
|
0
|
|
|
|
|
|
my $udat = $r -> app -> user_session ; |
409
|
0
|
0
|
|
|
|
|
if (!$disabledelete) # Delete session data |
410
|
|
|
|
|
|
|
{ |
411
|
0
|
|
|
|
|
|
$udat -> delete ; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
else |
414
|
|
|
|
|
|
|
{ |
415
|
0
|
|
|
|
|
|
$udat-> {data} = {} ; # for make test only |
416
|
0
|
|
|
|
|
|
$udat->{initial_session_id} = "!DELETE" ; |
417
|
|
|
|
|
|
|
} |
418
|
0
|
|
|
|
|
|
$udat->{status} = 0; |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
####################################################################################### |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub RefreshSession |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
{ |
427
|
0
|
|
0
|
0
|
|
|
my $r = shift || Embperl::CurrReq () ; |
428
|
|
|
|
|
|
|
|
429
|
0
|
0
|
|
|
|
|
$r -> session_mgnt ($r -> session_mgnt | 4) if ($r -> session_mgnt) ; # resend cookie |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
####################################################################################### |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
sub CleanupSession |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
{ |
437
|
0
|
|
|
0
|
|
|
my ($req_rec, $appparam) = @_ ; |
438
|
|
|
|
|
|
|
|
439
|
0
|
|
|
|
|
|
my ($rc, $thread, $app) = Embperl::InitAppForRequest ($req_rec, $appparam) ; |
440
|
|
|
|
|
|
|
|
441
|
0
|
|
|
|
|
|
foreach my $obj ($app -> user_session, $app -> state_session, $app -> app_session) |
442
|
|
|
|
|
|
|
{ |
443
|
0
|
0
|
|
|
|
|
$obj -> cleanup if ($obj) ; |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
####################################################################################### |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub SetSessionCookie |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
{ |
454
|
0
|
|
|
0
|
|
|
my ($req_rec, $appparam) = @_ ; |
455
|
|
|
|
|
|
|
|
456
|
0
|
|
|
|
|
|
my ($rc, $thread, $app) = Embperl::InitAppForRequest ($req_rec, $appparam) ; |
457
|
0
|
|
|
|
|
|
my $udat = $app -> user_session ; |
458
|
0
|
|
0
|
|
|
|
$req_rec ||= Apache -> request ; |
459
|
|
|
|
|
|
|
|
460
|
0
|
0
|
0
|
|
|
|
if ($udat && $req_rec) |
461
|
|
|
|
|
|
|
{ |
462
|
0
|
|
|
|
|
|
my ($initialid, $id, $modified) = $udat -> getids ; |
463
|
|
|
|
|
|
|
|
464
|
0
|
|
|
|
|
|
my $name = $app -> config -> cookie_name ; |
465
|
0
|
|
|
|
|
|
my $domain = $app -> config -> cookie_domain ; |
466
|
0
|
|
|
|
|
|
my $path = $app -> config -> cookie_path ; |
467
|
0
|
|
|
|
|
|
my $expires = $app -> config -> cookie_expires ; |
468
|
0
|
|
|
|
|
|
my $secure = $app -> config -> cookie_secure ; |
469
|
0
|
0
|
|
|
|
|
my $domainstr = $domain?"; domain=$domain":''; |
470
|
0
|
0
|
|
|
|
|
my $pathstr = $path ?"; path=$path":''; |
471
|
0
|
0
|
|
|
|
|
my $expiresstr = $expires?"; expires=$expires":'' ; |
472
|
0
|
0
|
|
|
|
|
my $securestr = $secure?"; secure":'' ; |
473
|
|
|
|
|
|
|
|
474
|
0
|
0
|
0
|
|
|
|
if ($id || $initialid) |
475
|
|
|
|
|
|
|
{ |
476
|
0
|
|
|
|
|
|
$req_rec -> header_out ("Set-Cookie" => "$name=$id$domainstr$pathstr$expiresstr$securestr") ; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
####################################################################################### |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
sub export |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
{ |
488
|
0
|
|
|
0
|
|
|
my ($r, $caller) = @_ ; |
489
|
|
|
|
|
|
|
|
490
|
0
|
|
|
|
|
|
my $package = $r -> component -> curr_package ; |
491
|
1
|
|
|
1
|
|
9
|
no strict ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
376
|
|
492
|
0
|
|
|
|
|
|
my $exports = \%{"$package\:\:_ep_exports"} ; |
|
0
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
494
|
0
|
|
|
|
|
|
print Embperl::LOG "[$$]IMP: Create Imports for $caller from $package\n" ; |
495
|
|
|
|
|
|
|
|
496
|
0
|
|
|
|
|
|
foreach $k (keys %$exports) |
497
|
|
|
|
|
|
|
{ |
498
|
0
|
|
|
|
|
|
*{"$caller\:\:$k"} = $exports -> {$k} ; #\&{"$package\:\:$k"} ; |
|
0
|
|
|
|
|
|
|
499
|
0
|
|
|
|
|
|
print Embperl::LOG "[$$]IMP: Created Import for $package\:\:$k -> $caller\n" ; |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
1
|
|
|
1
|
|
7
|
use strict ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
150
|
|
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
####################################################################################### |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
package Apache::Embperl; |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
*handler2 = \&Embperl::handler ; |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
package HTML::Embperl; |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
*handler2 = \&Embperl::handler ; |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
package XML::Embperl; |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
*handler2 = \&Embperl::handler ; |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
1 ; |