line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGIS; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: CGIS.pm,v 1.6 2003/03/12 11:43:34 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5750
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
52
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
1
|
|
|
1
|
|
6
|
use base 'CGI'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2267
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
($CGIS::VERSION) = '$Revision: 1.6 $' =~ m/Revision:\s*(\S+)/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Preloaded methods go here. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub session { |
14
|
1
|
|
|
1
|
0
|
5048
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
my $session_obj = $self->{_CGI_SESSION_OBJ}; |
17
|
1
|
50
|
|
|
|
3
|
unless ( defined $session_obj ) { |
18
|
1
|
|
|
|
|
995
|
require CGI::Session; |
19
|
1
|
|
|
|
|
4817
|
my $session_dir = $self->cgi_session_dir(); |
20
|
1
|
|
|
|
|
9
|
$session_obj = new CGI::Session(undef, $self, {Directory=>$session_dir}); |
21
|
1
|
|
|
|
|
80857
|
$self->{_CGI_SESSION_OBJ} = $session_obj; |
22
|
1
|
|
|
|
|
8
|
$self->param($session_obj->name, $session_obj->id); |
23
|
|
|
|
|
|
|
} |
24
|
1
|
50
|
|
|
|
97
|
unless ( @_ ) { |
25
|
1
|
|
|
|
|
5
|
return $session_obj; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
0
|
return $session_obj->param(@_); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# returns the folder to store session files in |
32
|
|
|
|
|
|
|
sub cgi_session_dir { |
33
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
8
|
require File::Spec; |
36
|
|
|
|
|
|
|
# getting the temporary directory |
37
|
1
|
|
|
|
|
101
|
my $tmpdir = File::Spec->tmpdir(); |
38
|
|
|
|
|
|
|
# directory name to store cgisession data in: |
39
|
1
|
|
|
|
|
16
|
my $session_dir = File::Spec->catfile($tmpdir, 'cgi_session'); |
40
|
1
|
50
|
|
|
|
19
|
unless ( -d $session_dir ) { |
41
|
0
|
|
|
|
|
0
|
require File::Path; |
42
|
0
|
0
|
|
|
|
0
|
unless(File::Path::mkpath($session_dir)) { |
43
|
|
|
|
|
|
|
# if fails to create the folder, fall back to default tmpdir |
44
|
0
|
|
|
|
|
0
|
$session_dir = File::Spec->tmpdir(); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
15
|
return $session_dir; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# alias to cgi_session_dir() |
53
|
|
|
|
|
|
|
sub session_dir { |
54
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
55
|
0
|
|
|
|
|
|
return $self->cgi_session_dir(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub header { |
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $session = $self->session(); |
64
|
0
|
|
|
|
|
|
my $cookie = $self->cookie($session->name, $session->id); |
65
|
0
|
|
|
|
|
|
return $self->SUPER::header(-cookie=>$cookie, @_); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub urlf { |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $session = $self->session(); |
74
|
0
|
|
|
|
|
|
my $name = $session->name; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my %args = ( |
77
|
|
|
|
|
|
|
$name => $session->id, |
78
|
|
|
|
|
|
|
@_ |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
require URI; |
82
|
0
|
|
|
|
|
|
my $url = new URI( $self->url )->canonical(); |
83
|
0
|
|
|
|
|
|
$url->query_form( %args ); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $url->as_string(); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub session_id { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return $self->session()->id; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
__END__ |