line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenPlugin::Cookie; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Cookie.pm,v 1.25 2003/04/03 01:51:23 andreychek Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw( OpenPlugin::Plugin ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
92
|
|
7
|
1
|
|
|
1
|
|
6
|
use Data::Dumper qw( Dumper ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1828
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$OpenPlugin::Cookie::VERSION = sprintf("%d.%02d", q$Revision: 1.25 $ =~ /(\d+)\.(\d+)/); |
10
|
|
|
|
|
|
|
|
11
|
8
|
|
|
8
|
0
|
42
|
sub OP { return $_[0]->{_m}{OP} } |
12
|
0
|
|
|
0
|
0
|
0
|
sub type { return 'cookie' } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Tell OpenPlugin about the cookies we've been sent |
15
|
|
|
|
|
|
|
sub set_incoming { |
16
|
1
|
|
|
1
|
0
|
3
|
my ( $self, $cookie ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
1
|
50
|
|
|
|
5
|
return undef unless ( $cookie->{name} ); |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
50
|
|
|
4
|
$cookie->{value} ||= ""; |
21
|
1
|
|
50
|
|
|
4
|
$cookie->{domain} ||= ""; |
22
|
1
|
|
50
|
|
|
3
|
$cookie->{path} ||= ""; |
23
|
1
|
|
50
|
|
|
4
|
$cookie->{expires} ||= ""; |
24
|
1
|
|
50
|
|
|
6
|
$cookie->{secure} ||= ""; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
12
|
return $self->state->{ incoming }{ $cookie->{name} } = { |
27
|
|
|
|
|
|
|
value => $cookie->{value}, |
28
|
|
|
|
|
|
|
domain => $cookie->{domain}, |
29
|
|
|
|
|
|
|
path => $cookie->{path}, |
30
|
|
|
|
|
|
|
expires => $cookie->{expires}, |
31
|
|
|
|
|
|
|
secure => $cookie->{secure}, |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
*get = \*get_incoming; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Retrieve cookies sent from the browser |
38
|
|
|
|
|
|
|
sub get_incoming { |
39
|
1
|
|
|
1
|
0
|
5
|
my ( $self, $name ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Just return a list of cookies |
42
|
1
|
50
|
|
|
|
4
|
unless ( $name ) { |
43
|
0
|
|
|
|
|
0
|
return keys %{ $self->state->{ incoming } }; |
|
0
|
|
|
|
|
0
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Return a single cookie as a hash |
47
|
1
|
|
|
|
|
4
|
return $self->state->{ incoming }{ $name }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Display cookies in the outgoing cookies queue |
51
|
|
|
|
|
|
|
sub get_outgoing { |
52
|
1
|
|
|
1
|
0
|
3
|
my ( $self, $name ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
4
|
unless ( $name ) { |
55
|
0
|
|
|
|
|
0
|
return keys %{ $self->state->{ outgoing } }; |
|
0
|
|
|
|
|
0
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
50
|
|
|
4
|
return $self->state->{ outgoing }{ $name } || undef; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
*set = \*set_outgoing; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Save a cookie to the outgoing queue |
65
|
|
|
|
|
|
|
sub set_outgoing { |
66
|
1
|
|
|
1
|
0
|
2
|
my ( $self, $args ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
50
|
|
|
|
5
|
if( ref $args eq "HASH" ) { |
|
|
0
|
|
|
|
|
|
69
|
1
|
|
|
|
|
2
|
my @keys = keys %{ $args }; |
|
1
|
|
|
|
|
5
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# The cookie(s) were sent in as a hash of hashes |
72
|
1
|
50
|
|
|
|
4
|
if ( ref $args->{ $keys[0] } eq "HASH" ) { |
73
|
0
|
|
|
|
|
0
|
foreach my $key ( @keys ) { |
74
|
0
|
|
|
|
|
0
|
my $cookie = $args->{ $key }; |
75
|
0
|
|
|
|
|
0
|
$cookie->{ name } = $key; |
76
|
0
|
|
|
|
|
0
|
$self->_set_outgoing( $cookie ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# We were sent a single cookie as a hash |
81
|
|
|
|
|
|
|
else { |
82
|
1
|
|
|
|
|
6
|
$self->_set_outgoing( $args ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# The cookies were sent in as an array of hashes |
87
|
|
|
|
|
|
|
elsif( ref $args eq "ARRAY" ) { |
88
|
0
|
|
|
|
|
0
|
foreach my $cookie ( @{ $args } ) { |
|
0
|
|
|
|
|
0
|
|
89
|
0
|
|
|
|
|
0
|
$self->_set_outgoing( $cookie ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { |
93
|
0
|
|
|
|
|
0
|
$self->OP->log->warn( "Unknown format used in attempt to create " . |
94
|
|
|
|
|
|
|
"a cookie!" ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
3
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Called by set_outgoing, tells OpenPlugin to add a cookie to the outgoing |
101
|
|
|
|
|
|
|
# queue |
102
|
|
|
|
|
|
|
sub _set_outgoing { |
103
|
1
|
|
|
1
|
|
2
|
my ( $self, $args ) = @_; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Remove a cookie from the outgoing queue |
106
|
1
|
50
|
33
|
|
|
7
|
if (( $args->{ name } ) && ( !exists $args->{ value } )) { |
107
|
0
|
|
|
|
|
0
|
delete $self->{_m}{OP}{_state}{Cookie}{outgoing}{$args->{ name }}; |
108
|
0
|
|
|
|
|
0
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
50
|
|
|
5
|
$args->{path} ||= "/"; |
112
|
1
|
|
50
|
|
|
4
|
$args->{expires} ||= ""; |
113
|
1
|
|
50
|
|
|
2
|
$args->{domain} ||= ""; |
114
|
1
|
|
50
|
|
|
6
|
$args->{secure} ||= 0; |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
7
|
return $self->state->{ outgoing }{ $args->{name} } = { |
117
|
|
|
|
|
|
|
value => $args->{value}, |
118
|
|
|
|
|
|
|
path => $args->{path}, |
119
|
|
|
|
|
|
|
expires => $args->{expires}, |
120
|
|
|
|
|
|
|
domain => $args->{domain}, |
121
|
|
|
|
|
|
|
secure => $args->{secure}, |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# These functions are defined in the individual drivers |
126
|
0
|
|
|
0
|
0
|
|
sub init { } |
127
|
0
|
|
|
0
|
0
|
|
sub bake { } |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |