3 # Not to be used without the CGI script;
15 print STDOUT "Content-Type: text/plain\n\n" if $DEBUG & 2;
16 print STDOUT map("$_: $PLP::Script::header{$_}\n", keys %PLP::Script::header), "\n";
20 my ($path, $level, $linespec) = @_;
21 $level = 0 if not defined $level;
22 $linespec = '1' if not defined $linespec;
24 (my $file = $path) =~ s[.*/][];
26 ? qq/\cQ;\n#line 1 "$file"\nprint q\cQ/
27 : qq/\n#line 1 "$file"\nprint q\cQ/;
30 open SOURCE, $path or return $level
31 ? qq{\cQ; die qq[Can't open "\Q$path\E" (\Q$!\E)]; print q\cQ}
32 : qq{\n#line $linespec\ndie qq[Can't open "\Q$path\E" (\Q$!\E)];};
33 LINE: while (defined (my $line = <SOURCE>)) {
37 \G # Begin where left off
39 | <:=? | :> # PLP tags <:=? ... :>
40 | <\(.*?\)> # Include tags <(...)>
41 | <[^:(][^<:]* # Normal text
42 | :[^>][^<:]* # Normal text
43 | [^<:]* # Normal text
46 next LINE unless length $1;
48 if ($part eq '<:=' and not $inA || $inB) {
51 } elsif ($part eq '<:' and not $inA || $inB) {
54 } elsif ($part eq ':>' and $inA) {
57 } elsif ($part eq ':>' and $inB) {
59 $source .= "; print q\cQ";
60 } elsif ($part =~ /^<\((.*?)\)>\z/ and not $inA || $inB) {
61 $source .= source($1, $level + 1) .
62 qq/\cQ, \n#line $linenr "$file"\nq\cQ/;
64 $part =~ s/\\/\\\\/ if not $inA || $inB;
69 $source .= "\cQ" unless $level;
74 my ($error, $type) = @_;
75 if (not defined $type or $type < 100) {
76 PLP::sendheaders unless $PLP::sentheaders;
77 $error =~ s/([<&>])/'&#' . ord($1) . ';'/ge;
78 print qq{<table border=1 class="PLPerror"><tr><td>},
79 qq{<span><b>Debug information:</b><BR>$error</td></tr></table>};
82 my ($short, $long) = @{ +{
83 404 => [ 'Not Found', "The requested URL $ENV{REQUEST_URI} was not found on this server." ],
84 403 => [ 'Forbidden', "You don't have permission to access $ENV{REQUEST_URI} on this server." ],
86 print "Status: $type\nContent-Type: text/html\n\n",
87 qq{<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n},
88 "<html><head>\n<title>--$type $short</title>\n</head></body>\n",
89 "<h1>$short</h1>\n$long<p>\n<hr>\n$ENV{SERVER_SIGNATURE}</body></html>";