X-Git-Url: http://git.shiar.nl/perl/plp/.git/blobdiff_plain/a3a4d694959ff6549ab0a37632440f529229c576..b5e0ee87251670be18b2f2fc128a4be0b25ebfb8:/PLP/Backend/CGI.pm diff --git a/PLP/Backend/CGI.pm b/PLP/Backend/CGI.pm deleted file mode 100644 index 1a4f49c..0000000 --- a/PLP/Backend/CGI.pm +++ /dev/null @@ -1,126 +0,0 @@ -package PLP::Backend::CGI; - -use strict; - -our $VERSION = '1.02'; - -use PLP; - -# CGI initializer: opens SCRIPT_FILENAME -sub init { - $PLP::print = 'print'; - $PLP::read = \&read; - - if (defined $ENV{PATH_TRANSLATED}) { - # SCRIPT_* points to handler script (Apache CGI) - # 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; - while (not -f $path) { - if (not $path =~ s/(\/+[^\/]*)$//) { - printf STDERR "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) { - $rel =~ s/\Q$path_info\E$//; - $ENV{PATH_INFO} = $path_info; - } - $ENV{SCRIPT_FILENAME} = $path; - $ENV{SCRIPT_NAME} = $rel; - } - elsif (not -f $ENV{SCRIPT_FILENAME}) { - print STDERR "PLP: Not found: $ENV{SCRIPT_FILENAME} ($ENV{REQUEST_URI})\n"; - PLP::error(undef, 404); - return; - } - - $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"; - PLP::error(undef, 403); - return; - } - - delete @ENV{ - qw(SCRIPT_NAME SCRIPT_FILENAME), - grep /^REDIRECT_/, keys %ENV - }; - - my ($file, $dir) = File::Basename::fileparse($ENV{PLP_FILENAME}); - chdir $dir; - - $PLP::code = PLP::source($file, 0, undef, $ENV{PLP_FILENAME}); - return 1; -} - -sub read ($) { - my ($bytes) = @_; - read *STDIN, my $data, $bytes; - return $data; -} - -sub everything { - PLP::clean(); - $_[0]->init() and PLP::start(); -} - -# This is run by the CGI script. (#!perl \n use PLP::Backend::CGI;) -sub import { - $_[0]->everything(); -} - -1; - -=head1 NAME - -PLP::Backend::CGI - CGI interface for PLP - -=head1 SYNOPSIS - -For most servers you'll need a script executable. -Example F: - - #!/usr/bin/perl - use PLP::Backend::CGI; - -Or install the C included with PLP. - -=head2 Lighttpd - -Usually in F: -enable I (add/outcomment in server.modules), and add: - - cgi.assign = ( - ".plp" => "/foo/bar/plp.cgi", - ) - -=head2 Apache - -Enable I and -setup F (in new installs just create F) with: - - - ScriptAlias /PLP_COMMON/ /foo/bar/ - - Options +ExecCGI - Order allow,deny - Allow from all - - AddHandler plp-document plp - Action plp-document /PLP_COMMON/plp.cgi - - -=head1 AUTHOR - -Mischa POSLAWSKY - -=head1 SEE ALSO - -L, L -