line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenPlugin::Upload::CGI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: CGI.pm,v 1.11 2003/04/03 01:51:26 andreychek Exp $ |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2342
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
6
|
2
|
|
|
2
|
|
1021
|
use OpenPlugin::Upload(); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
7
|
2
|
|
|
2
|
|
10
|
use base qw( OpenPlugin::Upload ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
363
|
|
8
|
2
|
|
|
2
|
|
21
|
use CGI qw( -no_debug ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$OpenPlugin::Upload::CGI::VERSION = sprintf("%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
2
|
|
|
2
|
0
|
6
|
my ( $self, $args ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
50
|
|
|
|
8
|
return $self unless $self->OP->request->object; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
8
|
foreach my $field ( $self->OP->request->object->param() ) { |
18
|
0
|
|
|
|
|
0
|
my $fh = $self->OP->request->object->upload( $field ); |
19
|
0
|
0
|
|
|
|
0
|
next unless ( $fh ); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my $cgi_filename = $self->OP->request->object->param( $field ); |
22
|
0
|
|
|
|
|
0
|
my $upload_info = $self->OP->request->object->uploadInfo( $cgi_filename ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# TODO: Ensure this works |
25
|
0
|
|
|
|
|
0
|
my ( $filename ) = $upload_info->{'Content-Disposition'} =~ /filename="(.*?)"/; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
$self->set_incoming({ |
28
|
|
|
|
|
|
|
name => $field, |
29
|
|
|
|
|
|
|
content_type => $upload_info->{'Content-Type'}, |
30
|
|
|
|
|
|
|
size => (stat $fh)[7], |
31
|
|
|
|
|
|
|
filehandle => $fh, |
32
|
|
|
|
|
|
|
filename => $filename, |
33
|
|
|
|
|
|
|
}); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
53
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#sub new {} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#sub name {} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#sub filename {} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#sub fh { my $u = shift; return $u->filehandle( @_ ) } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#sub filehandle {} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#sub type { my $u = shift; return $u->content_type( @_ ) } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#sub content_type {} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#sub size {} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
OpenPlugin::Upload::CGI - CGI driver for the OpenPlugin::Upload plugin |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 PARAMETERS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
You may optionally pass in an existing CGI object. For example: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $q = CGI->new(); |
70
|
|
|
|
|
|
|
my $OP = OpenPlugin->new( request => { cgi => $q } ); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is typically unnecessary. If you do not pass in a CGI object, one will be |
73
|
|
|
|
|
|
|
created for you. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
After the plugin is initialized, the CGI object is accessible |
76
|
|
|
|
|
|
|
to you using: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$q = $OP->state->{ request }{ cgi }; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 CONFIG OPTIONS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item 4 driver |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
CGI |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 BUGS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
None known. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 TO DO |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Nothing known. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Eric Andreychek. All rights reserved. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
107
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHORS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Eric Andreychek |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |