v3.01 release
[perl/plp/.git] / plp.cgi
diff --git a/plp.cgi b/plp.cgi
index 6dbcee9f01abdd30336a0738f27d2e86b5d91c6b..85d82100b55441ddd7ff00fd5437413f1fc79172 100755 (executable)
--- a/plp.cgi
+++ b/plp.cgi
@@ -2,7 +2,7 @@
 use v5.6.0;
 use PLP;
 
-die 'Wrong module version' if $PLP::VERSION ne '3.00';
+die 'Wrong module version' if $PLP::VERSION ne '3.01';
 
 use vars qw($DEBUG);
 
@@ -23,15 +23,14 @@ our $mod_perl = exists $ENV{MOD_PERL};
     my $path_info;
     while (not -f $file) {
         if (not $file =~ s/(\/+[^\/]*)$//) {
-           $ENV{REDIRECT_STATUS} = '404';
-           print STDERR "PLP: Not found: $file\n";
+           print STDERR "PLP: Not found: $ENV{PATH_TRANSLATED} ($ENV{REQUEST_URI})\n";
 
            if ($mod_perl) {
                Apache->request->uri($ENV{REQUEST_URI});
                print STDOUT "Status: 404 Not Found";
                Apache::exit();
            } else {
-               print STDOUT "Status: 404 Not Found\n\nNot found: $ENV{REQUEST_URI}";
+               PLP::error(undef, 404);
                exit;
            }
        }
@@ -45,11 +44,12 @@ our $mod_perl = exists $ENV{MOD_PERL};
     }
 
     if (not -r $file) {
+       print STDERR "PLP: Can't read: $ENV{PATH_TRANSLATED} ($ENV{REQUEST_URI})\n";
        if (exists $ENV{MOD_PERL}) {
            print STDOUT "Status: 403 Forbidden";
            Apache::exit();
        } else {
-           print STDOUT "Status: 403 Forbidden\n\nForbidden: $ENV{REQUEST_URI}";
+           PLP::error(undef, 403);
            exit;
        }
     }
@@ -79,13 +79,9 @@ our $mod_perl = exists $ENV{MOD_PERL};
        PLP::Functions->import();
        eval qq{package PLP::Script; $PLP::code};
     }
+    PLP::error($@, 1) if $@;
     select STDOUT;
     undef *{"PLP::Script::$_"} for keys %PLP::Script::;
     PLP::SendHeaders() unless $PLP::sentheaders;
-    if ($@ && $DEBUG & 1){
-       print $header{'Content-Type'} =~ m!^text/html!i
-             ? ("<hr><b>Debug</b><br>", Entity($@))
-             : ("[Debug]\n", $@);
-    }
 }