line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
XAO::DO::CGI - CGI interface for XAO::Web |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This is an extension of the standard CGI package that overrides its param() |
8
|
|
|
|
|
|
|
method. If the current site has a 'charset' parameter in siteconfig then |
9
|
|
|
|
|
|
|
parameters received from CGI are decoded from that charset into Perl |
10
|
|
|
|
|
|
|
native unicode strings. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=over |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
############################################################################### |
17
|
|
|
|
|
|
|
package XAO::DO::CGI; |
18
|
20
|
|
|
20
|
|
14082
|
use strict; |
|
20
|
|
|
|
|
35
|
|
|
20
|
|
|
|
|
629
|
|
19
|
20
|
|
|
20
|
|
93
|
use Encode; |
|
20
|
|
|
|
|
34
|
|
|
20
|
|
|
|
|
2341
|
|
20
|
20
|
|
|
20
|
|
110
|
use XAO::Utils; |
|
20
|
|
|
|
|
42
|
|
|
20
|
|
|
|
|
954
|
|
21
|
20
|
|
|
20
|
|
99
|
use XAO::Objects; |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
16113
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
############################################################################### |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new ($%) { |
26
|
133
|
|
|
133
|
0
|
13496
|
my $proto=shift; |
27
|
133
|
|
|
|
|
289
|
my $args=get_args(\@_); |
28
|
|
|
|
|
|
|
|
29
|
133
|
|
|
|
|
961
|
my $cgi; |
30
|
133
|
100
|
|
|
|
435
|
if($args->{'cgi'}) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
31
|
2
|
|
|
|
|
4
|
$cgi=$args->{'cgi'}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif($args->{'query'}) { |
34
|
51
|
|
|
|
|
14552
|
require CGI; |
35
|
51
|
|
|
|
|
434812
|
$cgi=CGI->new($args->{'query'}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif($args->{'no_cgi'}) { |
38
|
0
|
|
|
|
|
0
|
require CGI; |
39
|
0
|
|
|
|
|
0
|
$cgi=CGI->new('foo=bar'); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
80
|
|
|
|
|
386
|
require CGI; |
43
|
80
|
|
|
|
|
231
|
$cgi=CGI->new(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
133
|
50
|
|
|
|
46767
|
$cgi || die "Cannot create proxied CGI instance"; |
47
|
|
|
|
|
|
|
|
48
|
133
|
|
|
|
|
307
|
my $self={ |
49
|
|
|
|
|
|
|
cgi => $cgi, |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
133
|
|
33
|
|
|
733
|
bless $self,ref($proto) || $proto; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
############################################################################### |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
our $AUTOLOAD; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub AUTOLOAD { |
60
|
457
|
|
|
457
|
|
2766
|
my $self=shift; |
61
|
457
|
50
|
|
|
|
809
|
return undef if !$self->{'cgi'}; |
62
|
457
|
|
|
|
|
1126
|
my @mpath=split('::',$AUTOLOAD); |
63
|
457
|
|
|
|
|
699
|
my $method=$mpath[$#mpath]; |
64
|
457
|
|
|
|
|
1263
|
my $code=$self->{'cgi'}->can($method); |
65
|
457
|
100
|
|
|
|
749
|
if(!$code) { |
66
|
100
|
50
|
|
|
|
1971
|
return if $method eq 'DESTROY'; |
67
|
0
|
|
|
|
|
0
|
die "No method $method on $self->{'cgi'}"; |
68
|
|
|
|
|
|
|
} |
69
|
357
|
|
|
|
|
744
|
return $code->($self->{'cgi'},@_); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
############################################################################### |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub can { |
75
|
124
|
|
|
124
|
0
|
331
|
my ($self,$method)=@_; |
76
|
124
|
|
100
|
|
|
684
|
return $self->SUPER::can($method) || $self->{'cgi'}->can($method); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
############################################################################### |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub cookie ($@) { |
82
|
58
|
|
|
58
|
0
|
10602
|
my $self=shift; |
83
|
58
|
100
|
|
|
|
108
|
if(@_) { |
84
|
50
|
|
|
|
|
306
|
my @c1=caller(1); |
85
|
50
|
50
|
33
|
|
|
302
|
if(!@c1 || $c1[3]!~/get_cookie/) { |
86
|
0
|
|
|
|
|
0
|
my @c0=caller(0); |
87
|
0
|
0
|
|
|
|
0
|
eprint "Using CGI::cookie() method is deprecated, consider switching to \$config->get_cookie() in ".join(':',map { $_ || '' } ($c0[1],$c0[2])); |
|
0
|
|
|
|
|
0
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
58
|
|
|
|
|
178
|
return $self->{'cgi'}->cookie(@_); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
############################################################################### |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub set_param_charset($$) { |
96
|
124
|
|
|
124
|
0
|
193
|
my ($self,$charset)=@_; |
97
|
|
|
|
|
|
|
|
98
|
124
|
|
|
|
|
199
|
my $old=$self->{'xao_param_charset'}; |
99
|
124
|
|
|
|
|
248
|
$self->{'xao_param_charset'}=$charset; |
100
|
|
|
|
|
|
|
|
101
|
124
|
|
|
|
|
216
|
return $old; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
############################################################################### |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub get_param_charset($$) { |
107
|
2
|
|
|
2
|
0
|
39
|
my $self=shift; |
108
|
2
|
|
|
|
|
10
|
return $self->{'xao_param_charset'}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
############################################################################### |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub param ($;$) { |
114
|
76
|
|
|
76
|
0
|
1197
|
my $self=shift; |
115
|
|
|
|
|
|
|
|
116
|
76
|
|
|
|
|
95
|
my $charset=$self->{'xao_param_charset'}; |
117
|
|
|
|
|
|
|
|
118
|
76
|
100
|
|
|
|
118
|
if(!$charset) { |
119
|
41
|
100
|
|
|
|
65
|
if(wantarray) { |
120
|
24
|
|
|
|
|
50
|
return $self->{'cgi'}->multi_param(@_); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
17
|
|
|
|
|
39
|
return $self->{'cgi'}->param(@_); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else { |
127
|
35
|
50
|
|
|
|
58
|
if(wantarray) { |
128
|
|
|
|
|
|
|
return map { |
129
|
0
|
0
|
|
|
|
0
|
ref($_) ? $_ : Encode::decode($charset,$_) |
130
|
0
|
|
|
|
|
0
|
} $self->{'cgi'}->multi_param(@_); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
else { |
133
|
35
|
|
|
|
|
86
|
my $value=$self->{'cgi'}->param(@_); |
134
|
35
|
50
|
|
|
|
1705
|
return ref($value) ? $value : Encode::decode($charset,$value); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
############################################################################### |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub Vars ($) { |
142
|
3
|
|
|
3
|
0
|
383
|
my $self=shift; |
143
|
|
|
|
|
|
|
|
144
|
3
|
|
|
|
|
10
|
my $charset=$self->{'xao_param_charset'}; |
145
|
|
|
|
|
|
|
|
146
|
3
|
100
|
|
|
|
10
|
if(!$charset) { |
147
|
1
|
|
|
|
|
11
|
return $self->{'cgi'}->Vars(); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# There is a known incompatibility in this implementation -- our |
151
|
|
|
|
|
|
|
# hash is never tied and cannot be used to modify the CGI object |
152
|
|
|
|
|
|
|
# values. |
153
|
|
|
|
|
|
|
# |
154
|
2
|
|
|
|
|
14
|
my %vb=$self->{'cgi'}->Vars(); |
155
|
2
|
|
|
|
|
394
|
my %vu; |
156
|
2
|
|
|
|
|
10
|
foreach my $param (keys %vb) { |
157
|
8
|
|
|
|
|
351
|
$vu{Encode::decode($charset,$param)}=Encode::decode($charset,$vb{$param}); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
2
|
100
|
|
|
|
104
|
return wantarray ? %vu : \%vu; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
############################################################################### |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub multi_param ($;$) { |
166
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
167
|
0
|
|
|
|
|
|
return $self->param(@_); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
############################################################################### |
171
|
|
|
|
|
|
|
1; |
172
|
|
|
|
|
|
|
__END__ |