line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Anansi::Script::CGI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Anansi::Script::CGI - Defines the mechanisms specific to handling web browser execution. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $OBJECT = Anansi::Script::CGI->new(); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This module is designed to be an optional component module for use by the |
15
|
|
|
|
|
|
|
L component management module. It defines the processes |
16
|
|
|
|
|
|
|
specific to handling both input and output from Perl scripts that are executed |
17
|
|
|
|
|
|
|
by a web server using the Common Gateway Interface. See L |
18
|
|
|
|
|
|
|
for inherited methods. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
24605
|
use base qw(Anansi::Component); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8006
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
44385
|
use CGI; |
|
1
|
|
|
|
|
20223
|
|
|
1
|
|
|
|
|
11
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 content |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $contents = $OBJECT->content(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# OR |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $contents = $OBJECT->channel('CONTENT'); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# OR |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if(1 == $OBJECT->content(undef, undef)); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# OR |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
if(1 == $OBJECT->channel('CONTENT', undef)); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# OR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if(1 == $OBJECT->content(undef, 'some content')); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# OR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if(1 == $OBJECT->channel('CONTENT', 'some content')); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Either returns the existing content or redefines the content. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub content { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
66
|
0
|
|
|
|
|
|
my $channel; |
67
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 != scalar(@_)); |
68
|
0
|
0
|
|
|
|
|
$self->{CONTENTS} = '' if(!defined($self->{CONTENTS})); |
69
|
0
|
0
|
|
|
|
|
return $self->{CONTENTS} if(0 == scalar(@_)); |
70
|
0
|
|
|
|
|
|
my $content = shift(@_); |
71
|
0
|
0
|
|
|
|
|
return 0 if(0 < scalar(@_)); |
72
|
0
|
0
|
|
|
|
|
$content = '' if(!defined($content)); |
73
|
0
|
0
|
|
|
|
|
return 0 if(ref($content) !~ /^$/); |
74
|
0
|
|
|
|
|
|
$self->{CONTENTS} = $content; |
75
|
0
|
|
|
|
|
|
return 1; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::CGI', 'CONTENT' => 'content'); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 finalise |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$OBJECT::SUPER->finalise(@_); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
An overridden virtual method called during object destruction. Not intended to |
86
|
|
|
|
|
|
|
be directly called unless overridden by a descendant. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub finalise { |
92
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
93
|
0
|
|
|
|
|
|
$self->saveHeaders(%parameters); |
94
|
0
|
|
|
|
|
|
print $self->content(); |
95
|
0
|
|
|
|
|
|
$self->used('CGI'); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 header |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $headers = $OBJECT->header(); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# OR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $headers = $OBJECT->channel('HEADER'); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# OR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $headerValue = $OBJECT->header(undef, 'header_name'); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# OR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $headerValue = $OBJECT->channel('HEADER', 'header_name'); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# OR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
if($OBJECT->header(undef, 'header_name' => 'header value', 'another_header' => undef, 'yet_another_header' => [1, 2, 3], 'one_more' => {'hash key' => 'some value', 'another key' => undef})); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# OR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
if($OBJECT->channel('HEADER', 'header_name' => 'header value', 'another_header' => undef, 'yet_another_header' => [1, 2, 3], 'one_more' => {'hash key' => 'some value', 'another key' => undef})); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Either returns an ARRAY of all the existing header names or returns the value of |
124
|
|
|
|
|
|
|
a specific header or sets the value of one or more headers. Assigning an |
125
|
|
|
|
|
|
|
"undef" value to a header has the effect of deleting the header. Assigning an |
126
|
|
|
|
|
|
|
"undef" HASH key value to a header's HASH value has the effect of deleting the |
127
|
|
|
|
|
|
|
HASH key value. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub header { |
133
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
134
|
0
|
|
|
|
|
|
my $channel; |
135
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
136
|
0
|
0
|
|
|
|
|
if(0 == scalar(@_)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
return [] if(!defined($self->{HEADERS})); |
138
|
0
|
|
|
|
|
|
return [( keys(%{$self->{HEADERS}}) )]; |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} elsif(1 == scalar(@_)) { |
140
|
0
|
|
|
|
|
|
my $name = shift(@_); |
141
|
0
|
0
|
|
|
|
|
return if(!defined($self->{HEADERS})); |
142
|
0
|
0
|
|
|
|
|
return if(!defined(${$self->{HEADERS}}{$name})); |
|
0
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return ${$self->{HEADERS}}{$name}; |
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} elsif(1 == scalar(@_) % 2) { |
145
|
0
|
|
|
|
|
|
return 0; |
146
|
|
|
|
|
|
|
} |
147
|
0
|
|
|
|
|
|
my ($name, %parameters) = @_; |
148
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
149
|
0
|
0
|
|
|
|
|
if(!defined(${$self->{HEADERS}}{$name})) { |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^$/) { |
151
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^ARRAY$/i) { |
152
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$name}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
return 0 if(ref($value) !~ /^$/); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^HASH$/i) { |
156
|
0
|
|
|
|
|
|
foreach my $value (keys(%{$parameters{$name}})) { |
|
0
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
|
if(defined(${$parameters{$name}}{$value})) { |
|
0
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
return 0 if(ref(${$parameters{$name}}{$value}) !~ /^$/); |
|
0
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} else { |
162
|
0
|
|
|
|
|
|
return 0; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
166
|
0
|
0
|
|
|
|
|
if(!defined(${$self->{HEADERS}}{$name})) { |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
delete(${$self->{HEADERS}}{$name}); |
|
0
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^$/) { |
169
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = $parameters{$name}; |
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^ARRAY$/i) { |
171
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = []; |
|
0
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$name}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
push(@{${$self->{HEADERS}}{$name}}, $value); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^HASH$/i) { |
176
|
0
|
0
|
|
|
|
|
${$self->{HEADERS}}{$name} = {} if(ref(${$self->{HEADERS}}{$name}) !~ /^HASH$/i); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
foreach my $value (keys(%{$parameters{$name}})) { |
|
0
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
if(!defined(${$parameters{$name}}{$value})) { |
|
0
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
delete(${${$self->{HEADERS}}{$name}}{$value}) if(defined(${${$self->{HEADERS}}{$name}}{$value})); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} else { |
181
|
0
|
|
|
|
|
|
${${$self->{HEADERS}}{$name}}{$value} = ${$parameters{$name}}{$value}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
0
|
|
|
|
|
|
return 1; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::CGI', 'HEADER' => 'header'); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 initialise |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$OBJECT::SUPER->initialise(@_); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
An overridden virtual method called during object creation. Not intended to be |
197
|
|
|
|
|
|
|
directly called unless overridden by a descendant. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub initialise { |
203
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
204
|
0
|
|
|
|
|
|
my $CGI = CGI->new(); |
205
|
0
|
|
|
|
|
|
$self->uses( |
206
|
|
|
|
|
|
|
CGI => $CGI, |
207
|
|
|
|
|
|
|
); |
208
|
0
|
|
|
|
|
|
$self->loadHeaders(%parameters); |
209
|
0
|
|
|
|
|
|
$self->loadParameters(%parameters); |
210
|
0
|
|
|
|
|
|
$self->header('content-type' => 'text/html'); |
211
|
0
|
|
|
|
|
|
$self->content(); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 loadHeaders |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$OBJECT->loadHeaders(); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Loads all of the CGI headers supplied upon page REQUEST. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub loadHeaders { |
225
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
226
|
0
|
0
|
|
|
|
|
$self->{HEADERS} = {} if(!defined($self->{HEADERS})); |
227
|
0
|
|
|
|
|
|
foreach my $name ($self->{CGI}->param()) { |
228
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = $self->{CGI}->param($name); |
|
0
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 loadParameters |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
$OBJECT->loadParameters(); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Loads all of the CGI parameters supplied upon page REQUEST. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub loadParameters { |
243
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
244
|
0
|
0
|
|
|
|
|
$self->{PARAMETERS} = {} if(!defined($self->{PARAMETERS})); |
245
|
0
|
|
|
|
|
|
foreach my $name ($self->{CGI}->param()) { |
246
|
0
|
|
|
|
|
|
${$self->{PARAMETERS}}{$name} = $self->{CGI}->param($name); |
|
0
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 medium |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
my $medium = Anansi::Script::CGI->medium(); |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# OR |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
my $medium = $OBJECT->medium(); |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# OR |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
my $medium = $OBJECT->channel('MEDIUM'); |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Returns the STRING description of the medium this module is designed to handle. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub medium { |
269
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
270
|
0
|
|
|
|
|
|
my $channel; |
271
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
272
|
0
|
|
|
|
|
|
return 'CGI'; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::CGI', 'MEDIUM' => 'medium'); |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head2 parameter |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
my $parameters = $OBJECT->parameter(); |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# OR |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
my $parameters = $OBJECT->channel('PARAMETER'); |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
# OR |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
my $parameterValue = $OBJECT->parameter(undef, 'parameter name'); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
# OR |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
my $parameterValue = $OBJECT->channel('PARAMETER', 'parameter name'); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# OR |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
if($OBJECT->parameter(undef, 'parameter name' => 'parameter value', 'another parameter' => undef)); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
# OR |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
if($OBJECT->channel('PARAMETER', 'parameter name' => 'parameter value', 'another parameter' => undef)); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Either returns an ARRAY of all the existing parameter names or returns the value |
303
|
|
|
|
|
|
|
of a specific parameter or sets the value of one or more parameters. Assigning |
304
|
|
|
|
|
|
|
an "undef" value has the effect of deleting the parameter. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=cut |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub parameter { |
310
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
311
|
0
|
|
|
|
|
|
my $channel; |
312
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
313
|
0
|
0
|
|
|
|
|
if(0 == scalar(@_)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
314
|
0
|
0
|
|
|
|
|
return [] if(!defined($self->{PARAMETERS})); |
315
|
0
|
|
|
|
|
|
return [( keys(%{$self->{PARAMETERS}}) )]; |
|
0
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
} elsif(1 == scalar(@_)) { |
317
|
0
|
|
|
|
|
|
my $name = shift(@_); |
318
|
0
|
0
|
|
|
|
|
return if(!defined($self->{PARAMETERS})); |
319
|
0
|
0
|
|
|
|
|
return if(!defined(${$self->{PARAMETERS}}{$name})); |
|
0
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
return ${$self->{PARAMETERS}}{$name}; |
|
0
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
} elsif(1 == scalar(@_) % 2) { |
322
|
0
|
|
|
|
|
|
return 0; |
323
|
|
|
|
|
|
|
} |
324
|
0
|
|
|
|
|
|
my ($name, %parameters) = @_; |
325
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
326
|
0
|
0
|
|
|
|
|
if(defined(${$self->{PARAMETERS}}{$name})) { |
|
0
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
${$self->{PARAMETERS}}{$name} = $parameters{$name}; |
|
0
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
} else { |
329
|
0
|
|
|
|
|
|
delete(${$self->{PARAMETERS}}{$name}); |
|
0
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
} |
332
|
0
|
|
|
|
|
|
return 1; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::CGI', 'PARAMETER' => 'parameter'); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head2 saveHeaders |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
$OBJECT->saveHeaders(); |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
Prints the CGI headers. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=cut |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
sub saveHeaders { |
348
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
349
|
0
|
0
|
|
|
|
|
return if(0 == scalar(keys(%{$self->{HEADERS}}))); |
|
0
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
foreach my $header (keys(%{$self->{HEADERS}})) { |
|
0
|
|
|
|
|
|
|
351
|
0
|
0
|
|
|
|
|
if(ref(${$self->{HEADERS}}{$header}) =~ /^$/) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
352
|
0
|
|
|
|
|
|
print $header.': '.${$self->{HEADERS}}{$header}."\n"; |
|
0
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
} elsif(ref(${$self->{HEADERS}}{$header}) =~ /^ARRAY$/i) { |
354
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$header}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
355
|
0
|
|
|
|
|
|
print $header.': '.$value."\n"; |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
} elsif(ref(${$self->{HEADERS}}{$header}) =~ /^HASH$/i) { |
358
|
0
|
|
|
|
|
|
foreach my $name (keys(%{${$self->{HEADERS}}{$header}})) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
359
|
0
|
|
|
|
|
|
print $header.': '.${${$self->{HEADERS}}{$header}}{$name}."\n"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
} |
363
|
0
|
|
|
|
|
|
print "\n"; |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=head2 validate |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
my $valid = $OBJECT->validate(); |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
# OR |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
my $valid = $OBJECT->channel('VALIDATE_AS_APPROPRIATE'); |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
Determines whether this module is the correct one to use for handling Perl |
376
|
|
|
|
|
|
|
script execution. |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=cut |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub validate { |
382
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
383
|
0
|
|
|
|
|
|
my $channel; |
384
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
385
|
0
|
0
|
|
|
|
|
return 0 if(!defined($ENV{'HTTP_HOST'})); |
386
|
0
|
|
|
|
|
|
my $CGI = CGI->new(); |
387
|
|
|
|
|
|
|
# Check the HTTP_SOAPACTION environment variable. |
388
|
0
|
0
|
|
|
|
|
return 0 if(defined($CGI->http('SOAPAction'))); |
389
|
0
|
|
|
|
|
|
return 1; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
Anansi::Component::addChannel('Anansi::Script::CGI', 'VALIDATE_AS_APPROPRIATE' => 'validate'); |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=head1 AUTHOR |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Kevin Treleaven |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=cut |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
1; |