X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/b5e0ee87251670be18b2f2fc128a4be0b25ebfb8..58ad0f73721365480cd2c2bc844af04146ba1941:/lib/PLP/Backend/CGI.pm diff --git a/lib/PLP/Backend/CGI.pm b/lib/PLP/Backend/CGI.pm index e4bcf1e..3acf63d 100644 --- a/lib/PLP/Backend/CGI.pm +++ b/lib/PLP/Backend/CGI.pm @@ -1,8 +1,9 @@ package PLP::Backend::CGI; use strict; +use warnings; -our $VERSION = '1.02'; +our $VERSION = '1.03'; use PLP; @@ -16,17 +17,17 @@ sub init { # Run backwards through PATH_TRANSLATED to find target filename, # then get file (relative) by stripping PATH_INFO. my ($path, $rel) = (delete $ENV{PATH_TRANSLATED}, delete $ENV{PATH_INFO}); - my $path_info; + my $path_info = ''; while (not -f $path) { if (not $path =~ s/(\/+[^\/]*)$//) { - printf STDERR "PLP: Not found: $path$path_info ($ENV{REQUEST_URI})\n"; + warn "PLP: Not found: $path$path_info ($ENV{REQUEST_URI})\n"; PLP::error(undef, 404); return; } # move last path element onto PATH_INFO $path_info = $1 . $path_info; } - if (defined $path_info) { + if ($path_info ne '') { $rel =~ s/\Q$path_info\E$//; $ENV{PATH_INFO} = $path_info; } @@ -34,7 +35,7 @@ sub init { $ENV{SCRIPT_NAME} = $rel; } elsif (not -f $ENV{SCRIPT_FILENAME}) { - print STDERR "PLP: Not found: $ENV{SCRIPT_FILENAME} ($ENV{REQUEST_URI})\n"; + warn "PLP: Not found: $ENV{SCRIPT_FILENAME} ($ENV{REQUEST_URI})\n"; PLP::error(undef, 404); return; } @@ -42,13 +43,12 @@ sub init { $ENV{"PLP_$_"} = $ENV{"SCRIPT_$_"} for qw/NAME FILENAME/; if (not -r $ENV{PLP_FILENAME}) { - print STDERR "PLP: Can't read: $ENV{PLP_FILENAME} ($ENV{REQUEST_URI})\n"; + warn "PLP: Can't read: $ENV{PLP_FILENAME} ($ENV{REQUEST_URI})\n"; PLP::error(undef, 403); return; } delete @ENV{ - qw(SCRIPT_NAME SCRIPT_FILENAME), grep /^REDIRECT_/, keys %ENV }; @@ -61,7 +61,7 @@ sub init { sub read ($) { my ($bytes) = @_; - read *STDIN, my $data, $bytes; + read *STDIN, my ($data), $bytes; return $data; } @@ -94,12 +94,12 @@ Or install the C included with PLP. =head2 Lighttpd -Usually in F: -enable I (add/outcomment in server.modules), and add: +Add this to your configuration file (usually F): - cgi.assign = ( - ".plp" => "/foo/bar/plp.cgi", - ) + server.modules += ("mod_cgi") + cgi.assign += (".plp" => "/foo/bar/plp.cgi") + server.indexfiles += ("index.plp") + static-file.exclude-extensions += (".plp") =head2 Apache