| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Maypole::Session; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Maypole::Session - Session related functionality for maypole |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Maypole::Session; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $uid = Maypole::Session::generate_unique_id() |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class provides session related methods for Maypole such as unique id's for |
|
16
|
|
|
|
|
|
|
requests. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Currently it provides only the generate_unique_id() function, by checking the |
|
19
|
|
|
|
|
|
|
id's generated by this function and included in submitted forms, it is possible |
|
20
|
|
|
|
|
|
|
to see if a form has been submitted before.. implementing these checks is left |
|
21
|
|
|
|
|
|
|
to the developer of that application. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Further functionality is to be added here in later versions to provide easy |
|
24
|
|
|
|
|
|
|
access to sessions, either through plugins or builtin methods. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 generate_unique_id() |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $uid = Maypole::Session::generate_unique_id() |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
generates a unique id and returns it, requires no arguments but accepts size, |
|
33
|
|
|
|
|
|
|
default is 32. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
1876
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
38
|
1
|
|
|
1
|
|
5
|
use Digest::MD5; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
138
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub generate_unique_id { |
|
42
|
0
|
|
0
|
0
|
1
|
|
my $length = shift || 32; |
|
43
|
0
|
|
|
|
|
|
my $id = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, $length); |
|
44
|
0
|
|
|
|
|
|
return $id; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
################################################################################ |
|
49
|
|
|
|
|
|
|
################################################################################ |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 TODO |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Currently implementing uniqueness tests of form submissions is left to the |
|
54
|
|
|
|
|
|
|
Maypole user, we plan to provide an optional default behaviour to automate this |
|
55
|
|
|
|
|
|
|
if required. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 MAINTAINER |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Aaron Trevena, c |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Simon Cozens, C |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 LICENSE |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
You may distribute this code under the same terms as Perl itself. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |