}
}
+our $r;
+
# mod_perl initializer: returns 0 on success, Apache error code on failure
sub init {
- our $r = shift;
+ $r = shift;
$PLP::print = 'PLP::Apache::print';
+ $PLP::read = \&read;
$ENV{PLP_FILENAME} = my $filename = $r->filename;
unless (-f $filename) {
- return MP2 ? Apache2::Const::NOT_FOUND() : Apache::Constants::NOT_FOUND();
+ return MP2 ? Apache2::Const::HTTP_NOT_FOUND() : Apache::Constants::NOT_FOUND();
}
unless (-r _) {
- return MP2 ? Apache2::Const::FORBIDDEN() : Apache::Constants::FORBIDDEN();
+ return MP2 ? Apache2::Const::HTTP_FORBIDDEN() : Apache::Constants::FORBIDDEN();
}
$ENV{PLP_NAME} = $r->uri;
- our $use_cache = $r->dir_config('PLPcache') !~ /^off$/i;
-#S our $use_safe = $r->dir_config('PLPsafe') =~ /^on$/i;
+ $PLP::use_cache = $r->dir_config('PLPcache') !~ /^off$/i;
+#S $PLP::use_safe = $r->dir_config('PLPsafe') =~ /^on$/i;
my $path = $r->filename();
my ($file, $dir) = File::Basename::fileparse($path);
chdir $dir;
return 0; # OK
}
+sub read ($) {
+ my ($bytes) = @_;
+ $r->read(my $data, $bytes);
+ return $data;
+}
+
# FAST printing under mod_perl
sub print {
return unless grep length, @_;
PLP::sendheaders() unless $PLP::sentheaders;
- $PLP::Apache::r->print(@_);
+ $r->print(@_);
}
# This is the mod_perl handler.
1;
+=head1 NAME
+
+PLP::Apache - Apache mod_perl interface for PLP
+
+=head1 SYNOPSIS
+
+Naturally, you'll need to enable I<mod_perl>:
+
+ apache-modconf apache enable mod_perl
+
+Setup F<httpd.conf> (often just create a F</etc/apache2/conf.d/plp>) with:
+
+ <IfModule mod_perl.c>
+ <Files *.plp>
+ SetHandler perl-script
+ PerlHandler PLP::Apache
+ PerlSendHeader On
+ PerlSetVar PLPcache On
+ </Files>
+ </IfModule>
+
+=head1 DESCRIPTION
+
+=head2 PerlSetVar configuration directives
+
+=over 16
+
+=item PLPcache
+
+Sets caching B<On>/B<Off>. When caching, PLP saves your script in memory and
+doesn't re-read and re-parse it if it hasn't changed. PLP will use more memory,
+but will also run 50% faster.
+
+B<On> is default, anything that isn't =~ /^off$/i is considered On.
+
+=back
+
+=head1 AUTHOR
+
+Mischa POSLAWSKY <perl@shiar.org>
+
+=head1 SEE ALSO
+
+L<PLP|PLP>, L<PLP::FastCGI|PLP::FastCGI>, L<mod_perl|Apache>
+