line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PLP::Backend::CGI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3146
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
879
|
use PLP; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
677
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# CGI initializer: opens SCRIPT_FILENAME |
11
|
|
|
|
|
|
|
sub init { |
12
|
19
|
|
|
19
|
0
|
28
|
$PLP::print = 'print'; |
13
|
19
|
|
|
|
|
37
|
$PLP::read = \&read; |
14
|
|
|
|
|
|
|
|
15
|
19
|
100
|
|
|
|
359
|
if (defined $ENV{PATH_TRANSLATED}) { |
|
|
50
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# SCRIPT_* points to handler script (Apache CGI) |
17
|
|
|
|
|
|
|
# Run backwards through PATH_TRANSLATED to find target filename, |
18
|
|
|
|
|
|
|
# then get file (relative) by stripping PATH_INFO. |
19
|
2
|
|
|
|
|
12
|
my ($path, $rel) = (delete $ENV{PATH_TRANSLATED}, delete $ENV{PATH_INFO}); |
20
|
2
|
|
|
|
|
5
|
my $path_info = ''; |
21
|
2
|
|
|
|
|
35
|
while (not -f $path) { |
22
|
7
|
100
|
|
|
|
50
|
if (not $path =~ s/(\/+[^\/]*)$//) { |
23
|
1
|
|
|
|
|
11
|
warn "PLP: Not found: $path$path_info ($ENV{REQUEST_URI})\n"; |
24
|
1
|
|
|
|
|
8
|
PLP::error(undef, 404); |
25
|
1
|
|
|
|
|
6
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
# move last path element onto PATH_INFO |
28
|
6
|
|
|
|
|
80
|
$path_info = $1 . $path_info; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
50
|
|
|
|
8
|
if ($path_info ne '') { |
31
|
1
|
|
|
|
|
22
|
$rel =~ s/\Q$path_info\E$//; |
32
|
1
|
|
|
|
|
6
|
$ENV{PATH_INFO} = $path_info; |
33
|
|
|
|
|
|
|
} |
34
|
1
|
|
|
|
|
5
|
$ENV{SCRIPT_FILENAME} = $path; |
35
|
1
|
|
|
|
|
4
|
$ENV{SCRIPT_NAME} = $rel; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif (not -f $ENV{SCRIPT_FILENAME}) { |
38
|
0
|
|
|
|
|
0
|
warn "PLP: Not found: $ENV{SCRIPT_FILENAME} ($ENV{REQUEST_URI})\n"; |
39
|
0
|
|
|
|
|
0
|
PLP::error(undef, 404); |
40
|
0
|
|
|
|
|
0
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
18
|
|
|
|
|
246
|
$ENV{"PLP_$_"} = $ENV{"SCRIPT_$_"} for qw/NAME FILENAME/; |
44
|
|
|
|
|
|
|
|
45
|
18
|
50
|
|
|
|
325
|
if (not -r $ENV{PLP_FILENAME}) { |
46
|
0
|
|
|
|
|
0
|
warn "PLP: Can't read: $ENV{PLP_FILENAME} ($ENV{REQUEST_URI})\n"; |
47
|
0
|
|
|
|
|
0
|
PLP::error(undef, 403); |
48
|
0
|
|
|
|
|
0
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
delete @ENV{ |
52
|
18
|
|
|
|
|
104
|
grep /^REDIRECT_/, keys %ENV |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
18
|
|
|
|
|
367
|
my ($file, $dir) = File::Basename::fileparse($ENV{PLP_FILENAME}); |
56
|
18
|
|
|
|
|
277
|
chdir $dir; |
57
|
|
|
|
|
|
|
|
58
|
18
|
|
|
|
|
67
|
$PLP::code = PLP::source($file, 0, undef, $ENV{PLP_FILENAME}); |
59
|
18
|
|
|
|
|
82
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub read ($) { |
63
|
0
|
|
|
0
|
0
|
0
|
my ($bytes) = @_; |
64
|
0
|
|
|
|
|
0
|
read *STDIN, my ($data), $bytes; |
65
|
0
|
|
|
|
|
0
|
return $data; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub everything { |
69
|
19
|
|
|
19
|
0
|
46
|
PLP::clean(); |
70
|
19
|
100
|
|
|
|
76
|
$_[0]->init() and PLP::start(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# This is run by the CGI script. (#!perl \n use PLP::Backend::CGI;) |
74
|
|
|
|
|
|
|
sub import { |
75
|
0
|
|
|
0
|
|
|
$PLP::interface = $_[0]; |
76
|
0
|
|
|
|
|
|
$_[0]->everything(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
PLP::Backend::CGI - CGI interface for PLP |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
For most servers you'll need a script executable. |
88
|
|
|
|
|
|
|
Example F: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#!/usr/bin/perl |
91
|
|
|
|
|
|
|
use PLP::Backend::CGI; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Or install the C included with PLP. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Lighttpd |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Add this to your configuration file (usually F): |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
server.modules += ("mod_cgi") |
100
|
|
|
|
|
|
|
cgi.assign += (".plp" => "/foo/bar/plp.cgi") |
101
|
|
|
|
|
|
|
server.indexfiles += ("index.plp") |
102
|
|
|
|
|
|
|
static-file.exclude-extensions += (".plp") |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 Apache |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Enable I and |
107
|
|
|
|
|
|
|
setup F (in new installs just create F) with: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
ScriptAlias /PLP_COMMON/ /foo/bar/ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Options +ExecCGI |
113
|
|
|
|
|
|
|
Order allow,deny |
114
|
|
|
|
|
|
|
Allow from all |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
AddHandler plp-document plp |
117
|
|
|
|
|
|
|
Action plp-document /PLP_COMMON/plp.cgi |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Mischa POSLAWSKY |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L, L |
127
|
|
|
|
|
|
|
|