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
|
2
|
|
|
2
|
|
7154
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
73
|
|
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
560
|
use HTML::EP (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
48
|
|
26
|
2
|
|
|
2
|
|
1297
|
use Storable (); |
|
2
|
|
|
|
|
4520
|
|
|
2
|
|
|
|
|
1586
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package HTML::EP::Session; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$HTML::EP::Session::VERSION = '0.1002'; |
32
|
|
|
|
|
|
|
@HTML::EP::Session::ISA = qw(HTML::EP); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _ep_session { |
35
|
0
|
|
|
0
|
|
|
my $self = shift; my $attr = shift; |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
0
|
|
|
|
my $class = $attr->{'class'} || 'HTML::EP::Session::DBI'; |
38
|
0
|
|
|
|
|
|
my $c = $class . '.pm'; |
39
|
0
|
|
|
|
|
|
$c =~ s/\:\:/\//g; |
40
|
0
|
|
|
|
|
|
require $c; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$self->{'_ep_session_code'} = $attr->{'hex'} ? 'h' : 's'; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $session; |
45
|
0
|
|
|
|
|
|
my $id = $attr->{'id'}; |
46
|
0
|
0
|
|
|
|
|
if (!$id) { |
47
|
|
|
|
|
|
|
# Create a new session |
48
|
0
|
|
|
|
|
|
require MD5; |
49
|
0
|
|
0
|
|
|
|
my $secret = ($attr->{'secret'} || 'this is secret?'); |
50
|
0
|
|
0
|
|
|
|
my $max_retries = $attr->{'max_retries'} || 5; |
51
|
0
|
|
0
|
|
|
|
for (my $i = 0; !$session && $i < $max_retries; $i++) { |
52
|
0
|
|
|
|
|
|
$id = MD5->hexhash(time() . {} . rand() . $$ . $secret); |
53
|
0
|
|
|
|
|
|
$session = eval { $class->new($self, $id, $attr) }; |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
0
|
0
|
|
|
|
|
if (!$session) { die $@ } |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} else { |
57
|
0
|
|
|
|
|
|
$session = $class->Open($self, $id, $attr); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->{'_ep_session_id'} = $id; |
61
|
0
|
|
0
|
|
|
|
my $var = $attr->{'var'} || 'session'; |
62
|
0
|
|
|
|
|
|
$self->{'_ep_session_var'} = $var; |
63
|
0
|
|
|
|
|
|
$self->{$var} = $session; |
64
|
0
|
0
|
|
|
|
|
$self->print("Created session:\n", $self->Dump($session)) |
65
|
|
|
|
|
|
|
if $self->{'debug'}; |
66
|
0
|
|
|
|
|
|
''; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _ep_session_store { |
70
|
0
|
|
|
0
|
|
|
my $self = shift; my $attr = shift; |
|
0
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
0
|
|
|
|
my $id = ($attr->{'id'} || $self->{'_ep_session_id'}) |
73
|
|
|
|
|
|
|
or die "No session ID given"; |
74
|
0
|
|
0
|
|
|
|
my $var = $attr->{'var'} || $self->{'_ep_session_var'}; |
75
|
0
|
0
|
|
|
|
|
my $session = $self->{$var} or die "No such session: $var"; |
76
|
0
|
0
|
|
|
|
|
$self->print("Storing session:\n", $self->Dump($session)) |
77
|
|
|
|
|
|
|
if $self->{'debug'}; |
78
|
0
|
|
|
|
|
|
$session->Store($self, $id, $attr->{'locked'}); |
79
|
0
|
|
|
|
|
|
''; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _ep_session_item { |
83
|
0
|
|
|
0
|
|
|
my $self = shift; my $attr = shift; |
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
0
|
|
|
|
my $id = ($attr->{'id'} || $self->{'_ep_session_id'}) |
86
|
|
|
|
|
|
|
or die "No session ID given"; |
87
|
0
|
|
0
|
|
|
|
my $var = $attr->{'var'} || $self->{'_ep_session_var'}; |
88
|
0
|
0
|
|
|
|
|
my $session = $self->{$var} or die "No such session: $var"; |
89
|
0
|
|
|
|
|
|
my $items = $session->{'items'}; |
90
|
0
|
0
|
|
|
|
|
if (!$items) { |
91
|
0
|
|
|
|
|
|
$items = $session->{'items'} = {}; |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
my $item = $attr->{'item'}; |
94
|
0
|
|
|
|
|
|
my $num; |
95
|
0
|
0
|
|
|
|
|
if ($num = $attr->{'add'}) { |
96
|
0
|
|
0
|
|
|
|
$num = ($items->{$item} || 0) + $attr->{'add'}; |
97
|
|
|
|
|
|
|
} else { |
98
|
0
|
|
0
|
|
|
|
$num = $attr->{'num'} || 0; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
$items->{$item} = $num; |
101
|
0
|
|
|
|
|
|
''; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _ep_session_delete { |
105
|
0
|
|
|
0
|
|
|
my $self = shift; my $attr = shift; |
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
0
|
|
|
|
my $id = ($attr->{'id'} || $self->{'_ep_session_id'}) |
108
|
|
|
|
|
|
|
or die "No session ID given"; |
109
|
0
|
|
0
|
|
|
|
my $var = $attr->{'var'} || $self->{'_ep_session_var'}; |
110
|
0
|
0
|
|
|
|
|
my $session = $self->{$var} or die "No such session: $var"; |
111
|
0
|
|
|
|
|
|
$session->Delete($self, $id); |
112
|
0
|
0
|
|
|
|
|
undef $self->{'_ep_session_id'} unless $attr->{'id'}; |
113
|
0
|
|
|
|
|
|
''; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |