line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# HTML::EP - A Perl based HTML extension. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright (C) 1998 Jochen Wiedmann |
7
|
|
|
|
|
|
|
# Am Eisteich 9 |
8
|
|
|
|
|
|
|
# 72555 Metzingen |
9
|
|
|
|
|
|
|
# Germany |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Phone: +49 7123 14887 |
12
|
|
|
|
|
|
|
# Email: joe@ispsoft.de |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# All rights reserved. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# You may distribute this module under the terms of either |
17
|
|
|
|
|
|
|
# the GNU General Public License or the Artistic License, as |
18
|
|
|
|
|
|
|
# specified in the Perl README file. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require 5.004; |
23
|
1
|
|
|
1
|
|
751
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
202
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
914
|
use CGI::Cookie (); |
|
1
|
|
|
|
|
2682
|
|
|
1
|
|
|
|
|
875
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package HTML::EP::Session::Cookie; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub encode { |
33
|
0
|
|
|
0
|
0
|
|
my($self, $in, $attr) = @_; |
34
|
0
|
|
|
|
|
|
my $out = Storable::nfreeze($in); |
35
|
0
|
0
|
|
|
|
|
if ($attr->{'zlib'}) { |
36
|
0
|
|
|
|
|
|
require Compress::Zlib; |
37
|
0
|
|
|
|
|
|
$out = Compress::Zlib::compress($out); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
0
|
|
|
|
|
if ($attr->{'base64'}) { |
40
|
0
|
|
|
|
|
|
require MIME::Base64; |
41
|
0
|
|
|
|
|
|
$out = MIME::Base64::encode_base64($out); |
42
|
|
|
|
|
|
|
} else { |
43
|
0
|
|
|
|
|
|
$out = unpack("H*", $out); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
$out; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub decode { |
49
|
0
|
|
|
0
|
0
|
|
my($self, $in, $attr) = @_; |
50
|
0
|
|
|
|
|
|
my $out; |
51
|
0
|
0
|
|
|
|
|
if ($attr->{'base64'}) { |
52
|
0
|
|
|
|
|
|
require MIME::Base64; |
53
|
0
|
|
|
|
|
|
$out = MIME::Base64::decode_base64($in); |
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
|
$out = pack("H*", $in); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
if ($attr->{'zlib'}) { |
58
|
0
|
|
|
|
|
|
require Compress::Zlib; |
59
|
0
|
|
|
|
|
|
$out = Compress::Zlib::uncompress($out); |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
Storable::thaw($out); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new { |
65
|
0
|
|
|
0
|
0
|
|
my($proto, $ep, $id, $attr) = @_; |
66
|
0
|
|
0
|
|
|
|
my $class = (ref($proto) || $proto); |
67
|
0
|
|
|
|
|
|
my $session = {}; |
68
|
0
|
|
|
|
|
|
bless($session, $class); |
69
|
0
|
|
|
|
|
|
my $freezed_session = $proto->encode($session, $attr); |
70
|
0
|
|
|
|
|
|
my %opts; |
71
|
0
|
|
|
|
|
|
$opts{'-name'} = $id; |
72
|
0
|
|
0
|
|
|
|
$opts{'-expires'} = $attr->{'expires'} || '+1h'; |
73
|
0
|
0
|
|
|
|
|
$opts{'-domain'} = $attr->{'domain'} if exists($attr->{'domain'}); |
74
|
0
|
0
|
|
|
|
|
$opts{'-path'} = $attr->{'path'} if exists($attr->{'path'}); |
75
|
0
|
|
|
|
|
|
my $cookie = CGI::Cookie->new(%opts, |
76
|
|
|
|
|
|
|
'-value' => $freezed_session); |
77
|
0
|
|
|
|
|
|
$ep->{'_ep_cookies'}->{$id} = $cookie; |
78
|
0
|
|
|
|
|
|
$opts{'zlib'} = $attr->{'zlib'}; |
79
|
0
|
|
|
|
|
|
$opts{'base64'} = $attr->{'base64'}; |
80
|
0
|
|
|
|
|
|
$session->{'_ep_data'} = \%opts; |
81
|
0
|
|
|
|
|
|
$session; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub Open { |
85
|
0
|
|
|
0
|
0
|
|
my($proto, $ep, $id, $attr) = @_; |
86
|
0
|
|
|
|
|
|
my $cgi = $ep->{'cgi'}; |
87
|
0
|
|
|
|
|
|
my $cookie = $cgi->cookie('-name' => $id); |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
return $proto->new($ep, $id, $attr) unless $cookie; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
0
|
|
|
|
my $class = (ref($proto) || $proto); |
92
|
0
|
|
|
|
|
|
my %opts; |
93
|
0
|
|
|
|
|
|
$opts{'-name'} = $id; |
94
|
0
|
|
0
|
|
|
|
$opts{'-expires'} = $attr->{'expires'} || '+1h'; |
95
|
0
|
0
|
|
|
|
|
$opts{'-domain'} = $attr->{'domain'} if exists($attr->{'domain'}); |
96
|
0
|
0
|
|
|
|
|
$opts{'-path'} = $attr->{'path'} if exists($attr->{'path'}); |
97
|
0
|
0
|
|
|
|
|
if (!$cookie) { |
98
|
0
|
|
|
|
|
|
die "Missing cookie $id." . |
99
|
|
|
|
|
|
|
" (Perhaps Cookies not enabled in the browser?)"; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
my $session = $proto->decode($cookie, $attr); |
102
|
0
|
|
|
|
|
|
bless($session, $class); |
103
|
0
|
|
|
|
|
|
$opts{'zlib'} = $attr->{'zlib'}; |
104
|
0
|
|
|
|
|
|
$opts{'base64'} = $attr->{'base64'}; |
105
|
0
|
|
|
|
|
|
$session->{'_ep_data'} = \%opts; |
106
|
0
|
|
|
|
|
|
$session; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub Store { |
110
|
0
|
|
|
0
|
0
|
|
my($self, $ep, $id, $locked) = @_; |
111
|
0
|
|
|
|
|
|
my $data = delete $self->{'_ep_data'}; |
112
|
0
|
|
|
|
|
|
my $freezed_session = $self->encode($self, $data); |
113
|
0
|
|
|
|
|
|
my $zlib = delete $data->{'zlib'}; |
114
|
0
|
|
|
|
|
|
my $base64 = delete $data->{'base64'}; |
115
|
0
|
|
|
|
|
|
my $cookie = CGI::Cookie->new(%$data, |
116
|
|
|
|
|
|
|
'-value' => $freezed_session); |
117
|
0
|
|
|
|
|
|
$ep->{'_ep_cookies'}->{$id} = $cookie; |
118
|
0
|
0
|
|
|
|
|
if ($locked) { |
119
|
0
|
0
|
|
|
|
|
$data->{'zlib'} = $zlib if defined $zlib; |
120
|
0
|
0
|
|
|
|
|
$data->{'base64'} = $base64 if defined $base64; |
121
|
0
|
|
|
|
|
|
$self->{'_ep_data'} = $data; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub Delete { |
127
|
0
|
|
|
0
|
0
|
|
my($self, $ep, $id) = @_; |
128
|
0
|
|
|
|
|
|
my $data = delete $self->{'_ep_data'}; |
129
|
0
|
|
|
|
|
|
my $cookie = CGI::Cookie->new('-name' => $id, |
130
|
|
|
|
|
|
|
'-expires' => '-1m', |
131
|
|
|
|
|
|
|
'-value' => ''); |
132
|
0
|
|
|
|
|
|
$self->{'_ep_cookies'}->{$id} = $cookie; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |