X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/0f5e78a789961923b45cae1a881c655fff9e7283..6fb22c399428a8e7cac088cab5603e75a87016fa:/PLP.pm diff --git a/PLP.pm b/PLP.pm index 7d3bf99..704870c 100644 --- a/PLP.pm +++ b/PLP.pm @@ -2,7 +2,7 @@ package PLP; # Not to be used without the CGI script; -our $VERSION = '3.00'; +our $VERSION = '3.01'; use PLP::Functions (); use PLP::Fields; @@ -17,7 +17,9 @@ sub SendHeaders () { }; sub source { - my ($path, $level) = @_; + my ($path, $level, $linespec) = @_; + $level = 0 if not defined $level; + $linespec = '1' if not defined $linespec; our ($inA, $inB); (my $file = $path) =~ s[.*/][]; my $source = $level @@ -27,7 +29,7 @@ sub source { local *SOURCE; open SOURCE, $path or return $level ? qq{\cQ; die qq[Can't open "\Q$path\E" (\Q$!\E)]; print q\cQ} - : qq{\ndie qq[Can't open "\Q$path\e" (\Q$!\E)];}; + : qq{\n#line $linespec\ndie qq[Can't open "\Q$path\E" (\Q$!\E)];}; LINE: while (defined (my $line = )) { $linenr++; for (;;) { @@ -68,5 +70,25 @@ sub source { return $source; } +sub error { + my ($error, $type) = @_; + if (not defined $type or $type < 100) { + PLP::sendheaders unless $PLP::sentheaders; + $error =~ s/([<&>])/'&#' . ord($1) . ';'/ge; + print qq{
}, + qq{Debug information:
$error
}; + } else { + select STDOUT; + my ($short, $long) = @{ +{ + 404 => [ 'Not Found', "The requested URL $ENV{REQUEST_URI} was not found on this server." ], + 403 => [ 'Forbidden', "You don't have permission to access $ENV{REQUEST_URI} on this server." ], + }->{$type} }; + print "Status: $type\nContent-Type: text/html\n\n", + qq{\n}, + "\n--$type $short\n\n", + "

$short

\n$long

\n


\n$ENV{SERVER_SIGNATURE}"; + } +} + 1;