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. Uses |
18
|
|
|
|
|
|
|
L I<(indirectly)>, L and |
19
|
|
|
|
|
|
|
L. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
69862
|
use base qw(Anansi::ScriptComponent); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
511
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
27493
|
use CGI; |
|
1
|
|
|
|
|
31843
|
|
|
1
|
|
|
|
|
7
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 INHERITED METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 addChannel |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Declared in L. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 channel |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Declared in L. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 componentManagers |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Declared in L. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 finalise |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$OBJECT->SUPER::finalise(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Declared in L. Overridden by this module. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub finalise { |
67
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
68
|
0
|
|
|
|
|
|
$self->saveHeaders(%parameters); |
69
|
0
|
|
|
|
|
|
print $self->content(); |
70
|
0
|
|
|
|
|
|
$self->used('CGI'); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 implicate |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Declared in L. Intended to be overridden by an extending module. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 import |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Declared in L. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 initialise |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$OBJECT->SUPER::initialise(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Declared in L. Overridden by this module. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub initialise { |
98
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
99
|
0
|
|
|
|
|
|
my $CGI = CGI->new(); |
100
|
0
|
|
|
|
|
|
$self->uses( |
101
|
|
|
|
|
|
|
CGI => $CGI, |
102
|
|
|
|
|
|
|
); |
103
|
0
|
|
|
|
|
|
$self->loadHeaders(%parameters); |
104
|
0
|
|
|
|
|
|
$self->loadParameters(%parameters); |
105
|
0
|
|
|
|
|
|
$self->header('content-type' => 'text/html'); |
106
|
0
|
|
|
|
|
|
$self->content(); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 old |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Declared in L. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 removeChannel |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Declared in L. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 used |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Declared in L. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 uses |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Declared in L. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 METHODS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 content |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $contents = $OBJECT->content(); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $contents = $OBJECT->channel('CONTENT'); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
if(1 == $OBJECT->content(undef, undef)); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
if(1 == $OBJECT->channel('CONTENT', undef)); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
if(1 == $OBJECT->content(undef, 'some content')); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
if(1 == $OBJECT->channel('CONTENT', 'some content')); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Either returns the existing content or redefines the content. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub content { |
163
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
164
|
0
|
|
|
|
|
|
my $channel; |
165
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 != scalar(@_)); |
166
|
0
|
0
|
|
|
|
|
$self->{CONTENTS} = '' if(!defined($self->{CONTENTS})); |
167
|
0
|
0
|
|
|
|
|
return $self->{CONTENTS} if(0 == scalar(@_)); |
168
|
0
|
|
|
|
|
|
my $content = shift(@_); |
169
|
0
|
0
|
|
|
|
|
return 0 if(0 < scalar(@_)); |
170
|
0
|
0
|
|
|
|
|
$content = '' if(!defined($content)); |
171
|
0
|
0
|
|
|
|
|
return 0 if(ref($content) !~ /^$/); |
172
|
0
|
|
|
|
|
|
$self->{CONTENTS} = $content; |
173
|
0
|
|
|
|
|
|
return 1; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'CONTENT' => 'content'); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 header |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $headers = $OBJECT->header(); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $headers = $OBJECT->channel('HEADER'); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $headerValue = $OBJECT->header(undef, 'header_name'); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my $headerValue = $OBJECT->channel('HEADER', 'header_name'); |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
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})); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
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})); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Either returns an ARRAY of all the existing header names or returns the value of |
194
|
|
|
|
|
|
|
a specific header or sets the value of one or more headers. Assigning an |
195
|
|
|
|
|
|
|
"undef" value to a header has the effect of deleting the header. Assigning an |
196
|
|
|
|
|
|
|
"undef" HASH key value to a header's HASH value has the effect of deleting the |
197
|
|
|
|
|
|
|
HASH key value. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub header { |
203
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
204
|
0
|
|
|
|
|
|
my $channel; |
205
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
206
|
0
|
0
|
|
|
|
|
if(0 == scalar(@_)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
return [] if(!defined($self->{HEADERS})); |
208
|
0
|
|
|
|
|
|
return [( keys(%{$self->{HEADERS}}) )]; |
|
0
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
} elsif(1 == scalar(@_)) { |
210
|
0
|
|
|
|
|
|
my $name = shift(@_); |
211
|
0
|
0
|
|
|
|
|
return if(!defined($self->{HEADERS})); |
212
|
0
|
0
|
|
|
|
|
return if(!defined(${$self->{HEADERS}}{$name})); |
|
0
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
return ${$self->{HEADERS}}{$name}; |
|
0
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
} elsif(1 == scalar(@_) % 2) { |
215
|
0
|
|
|
|
|
|
return 0; |
216
|
|
|
|
|
|
|
} |
217
|
0
|
|
|
|
|
|
my ($name, %parameters) = @_; |
218
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
219
|
0
|
0
|
|
|
|
|
if(!defined(${$self->{HEADERS}}{$name})) { |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
220
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^$/) { |
221
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^ARRAY$/i) { |
222
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$name}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
223
|
0
|
0
|
|
|
|
|
return 0 if(ref($value) !~ /^$/); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^HASH$/i) { |
226
|
0
|
|
|
|
|
|
foreach my $value (keys(%{$parameters{$name}})) { |
|
0
|
|
|
|
|
|
|
227
|
0
|
0
|
|
|
|
|
if(defined(${$parameters{$name}}{$value})) { |
|
0
|
|
|
|
|
|
|
228
|
0
|
0
|
|
|
|
|
return 0 if(ref(${$parameters{$name}}{$value}) !~ /^$/); |
|
0
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
} else { |
232
|
0
|
|
|
|
|
|
return 0; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
236
|
0
|
0
|
|
|
|
|
if(!defined(${$self->{HEADERS}}{$name})) { |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
delete(${$self->{HEADERS}}{$name}); |
|
0
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^$/) { |
239
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = $parameters{$name}; |
|
0
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^ARRAY$/i) { |
241
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = []; |
|
0
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$name}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
push(@{${$self->{HEADERS}}{$name}}, $value); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} elsif(ref($parameters{$name}) =~ /^HASH$/i) { |
246
|
0
|
0
|
|
|
|
|
${$self->{HEADERS}}{$name} = {} if(ref(${$self->{HEADERS}}{$name}) !~ /^HASH$/i); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
foreach my $value (keys(%{$parameters{$name}})) { |
|
0
|
|
|
|
|
|
|
248
|
0
|
0
|
|
|
|
|
if(!defined(${$parameters{$name}}{$value})) { |
|
0
|
|
|
|
|
|
|
249
|
0
|
0
|
|
|
|
|
delete(${${$self->{HEADERS}}{$name}}{$value}) if(defined(${${$self->{HEADERS}}{$name}}{$value})); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
} else { |
251
|
0
|
|
|
|
|
|
${${$self->{HEADERS}}{$name}}{$value} = ${$parameters{$name}}{$value}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
} |
256
|
0
|
|
|
|
|
|
return 1; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'HEADER' => 'header'); |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 loadHeaders |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
$OBJECT->loadHeaders(); |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Loads all of the CGI headers supplied upon page REQUEST. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub loadHeaders { |
272
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
273
|
0
|
0
|
|
|
|
|
$self->{HEADERS} = {} if(!defined($self->{HEADERS})); |
274
|
0
|
|
|
|
|
|
foreach my $name ($self->{CGI}->param()) { |
275
|
0
|
|
|
|
|
|
${$self->{HEADERS}}{$name} = $self->{CGI}->param($name); |
|
0
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 loadParameters |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
$OBJECT->loadParameters(); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Loads all of the CGI parameters supplied upon page REQUEST. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=cut |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub loadParameters { |
290
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
291
|
0
|
0
|
|
|
|
|
$self->{PARAMETERS} = {} if(!defined($self->{PARAMETERS})); |
292
|
0
|
|
|
|
|
|
foreach my $name ($self->{CGI}->param()) { |
293
|
0
|
|
|
|
|
|
${$self->{PARAMETERS}}{$name} = $self->{CGI}->param($name); |
|
0
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 medium |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
my $medium = Anansi::Script::CGI->medium(); |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
my $medium = $OBJECT->medium(); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
my $medium = $OBJECT->channel('MEDIUM'); |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Returns the STRING description of the medium this module is designed to handle. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=cut |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub medium { |
312
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
313
|
0
|
|
|
|
|
|
my $channel; |
314
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
315
|
0
|
|
|
|
|
|
return 'CGI'; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'MEDIUM' => 'medium'); |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=head2 parameter |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
my $parameters = $OBJECT->parameter(); |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
my $parameters = $OBJECT->channel('PARAMETER'); |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
my $parameterValue = $OBJECT->parameter(undef, 'parameter name'); |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
my $parameterValue = $OBJECT->channel('PARAMETER', 'parameter name'); |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
if($OBJECT->parameter(undef, 'parameter name' => 'parameter value', 'another parameter' => undef)); |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
if($OBJECT->channel('PARAMETER', 'parameter name' => 'parameter value', 'another parameter' => undef)); |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Either returns an ARRAY of all the existing parameter names or returns the value |
336
|
|
|
|
|
|
|
of a specific parameter or sets the value of one or more parameters. Assigning |
337
|
|
|
|
|
|
|
an "undef" value has the effect of deleting the parameter. |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
sub parameter { |
343
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
344
|
0
|
|
|
|
|
|
my $channel; |
345
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
346
|
0
|
0
|
|
|
|
|
if(0 == scalar(@_)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
347
|
0
|
0
|
|
|
|
|
return [] if(!defined($self->{PARAMETERS})); |
348
|
0
|
|
|
|
|
|
return [( keys(%{$self->{PARAMETERS}}) )]; |
|
0
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
} elsif(1 == scalar(@_)) { |
350
|
0
|
|
|
|
|
|
my $name = shift(@_); |
351
|
0
|
0
|
|
|
|
|
return if(!defined($self->{PARAMETERS})); |
352
|
0
|
0
|
|
|
|
|
return if(!defined(${$self->{PARAMETERS}}{$name})); |
|
0
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
return ${$self->{PARAMETERS}}{$name}; |
|
0
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
} elsif(1 == scalar(@_) % 2) { |
355
|
0
|
|
|
|
|
|
return 0; |
356
|
|
|
|
|
|
|
} |
357
|
0
|
|
|
|
|
|
my ($name, %parameters) = @_; |
358
|
0
|
|
|
|
|
|
foreach my $name (keys(%parameters)) { |
359
|
0
|
0
|
|
|
|
|
if(defined(${$self->{PARAMETERS}}{$name})) { |
|
0
|
|
|
|
|
|
|
360
|
0
|
|
|
|
|
|
${$self->{PARAMETERS}}{$name} = $parameters{$name}; |
|
0
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
} else { |
362
|
0
|
|
|
|
|
|
delete(${$self->{PARAMETERS}}{$name}); |
|
0
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
} |
365
|
0
|
|
|
|
|
|
return 1; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'PARAMETER' => 'parameter'); |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head2 priority |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
my $priority = Anansi::Script::CGI->priority(); |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
my $priority = $OBJECT->priority(); |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
my $priority = $OBJECT->channel('PRIORITY_OF_VALIDATE'); |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
Returns a hash of the priorities of this script component in relation to other |
380
|
|
|
|
|
|
|
script components. Each priority is represented by a component namespace in the |
381
|
|
|
|
|
|
|
form of a key and a value of B, B<-1> I<(minus one)> or any negative |
382
|
|
|
|
|
|
|
value implying this component is of higher priority, B, B<1> I<(one)> or |
383
|
|
|
|
|
|
|
any positive value implying this component is of lower priority or B or |
384
|
|
|
|
|
|
|
B<0> I<(zero)> implying this component is of the same priority. |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=cut |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
sub priority { |
390
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
391
|
0
|
|
|
|
|
|
my $channel; |
392
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
393
|
0
|
|
|
|
|
|
my $priorities = { |
394
|
|
|
|
|
|
|
'Anansi::Script::Shell' => 'lower', |
395
|
|
|
|
|
|
|
}; |
396
|
0
|
|
|
|
|
|
return $priorities; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'PRIORITY_OF_VALIDATE' => 'priority'); |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=head2 saveHeaders |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
$OBJECT->saveHeaders(); |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
Prints the CGI headers. |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=cut |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
sub saveHeaders { |
412
|
0
|
|
|
0
|
1
|
|
my ($self, %parameters) = @_; |
413
|
0
|
0
|
|
|
|
|
return if(0 == scalar(keys(%{$self->{HEADERS}}))); |
|
0
|
|
|
|
|
|
|
414
|
0
|
|
|
|
|
|
foreach my $header (keys(%{$self->{HEADERS}})) { |
|
0
|
|
|
|
|
|
|
415
|
0
|
0
|
|
|
|
|
if(ref(${$self->{HEADERS}}{$header}) =~ /^$/) { |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
416
|
0
|
|
|
|
|
|
print $header.': '.${$self->{HEADERS}}{$header}."\n"; |
|
0
|
|
|
|
|
|
|
417
|
0
|
|
|
|
|
|
} elsif(ref(${$self->{HEADERS}}{$header}) =~ /^ARRAY$/i) { |
418
|
0
|
|
|
|
|
|
foreach my $value (@{${$self->{HEADERS}}{$header}}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
419
|
0
|
|
|
|
|
|
print $header.': '.$value."\n"; |
420
|
|
|
|
|
|
|
} |
421
|
0
|
|
|
|
|
|
} elsif(ref(${$self->{HEADERS}}{$header}) =~ /^HASH$/i) { |
422
|
0
|
|
|
|
|
|
foreach my $name (keys(%{${$self->{HEADERS}}{$header}})) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
423
|
0
|
|
|
|
|
|
print $header.': '.${${$self->{HEADERS}}{$header}}{$name}."\n"; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
} |
427
|
0
|
|
|
|
|
|
print "\n"; |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=head2 validate |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
my $valid = $OBJECT->validate(); |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
my $valid = $OBJECT->channel('VALIDATE_AS_APPROPRIATE'); |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
Determines whether this module is the correct one to use for handling Perl |
438
|
|
|
|
|
|
|
script execution. |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=cut |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub validate { |
444
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
445
|
0
|
|
|
|
|
|
my $channel; |
446
|
0
|
0
|
|
|
|
|
$channel = shift(@_) if(0 < scalar(@_)); |
447
|
0
|
0
|
|
|
|
|
return 1 if(exists($ENV{'MOD_PERL'})); |
448
|
0
|
0
|
|
|
|
|
return 1 if(exists($ENV{'GATEWAY_INTERFACE'})); |
449
|
0
|
|
|
|
|
|
return 0; |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
Anansi::ScriptComponent::addChannel('Anansi::Script::CGI', 'VALIDATE_AS_APPROPRIATE' => 'validate'); |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head1 NOTES |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
This module is designed to make it simple, easy and quite fast to code your |
458
|
|
|
|
|
|
|
design in perl. If for any reason you feel that it doesn't achieve these goals |
459
|
|
|
|
|
|
|
then please let me know. I am here to help. All constructive criticisms are |
460
|
|
|
|
|
|
|
also welcomed. |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=cut |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=head1 AUTHOR |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
Kevin Treleaven treleaven I net> |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=cut |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
1; |
473
|
|
|
|
|
|
|
|