X-Git-Url: http://git.shiar.nl/perl/plp/.git/blobdiff_plain/0dee415b1a371573e705c18f09e70c555845e428..4565100c67dd7b0344e9eb332296d5fa64e7611b:/PLP/CGI.pm diff --git a/PLP/CGI.pm b/PLP/CGI.pm index ee81b37..56ca4db 100644 --- a/PLP/CGI.pm +++ b/PLP/CGI.pm @@ -9,6 +9,7 @@ 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) @@ -32,6 +33,11 @@ sub init { $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/; @@ -52,6 +58,12 @@ sub init { $PLP::code = PLP::source($file, 0, undef, $ENV{PLP_FILENAME}); } +sub read ($) { + my ($bytes) = @_; + read *STDIN, my $data, $bytes; + return $data; +} + # This is run by the CGI script. (#!perl \n use PLP::CGI; PLP::CGI::everything;) sub everything { PLP::clean();