3 use vars qw(%INTERNAL %get %post %fields %header %cookie %BLOCK $DEBUG $output);
7 $INTERNAL{sentheaders} = 1;
8 print STDOUT "Content-Type: text/plain\n\n" if $DEBUG & 2;
9 print STDOUT map("$_: $header{$_}\n", keys %header), "\n";
17 $ENV{PLP_VERSION} = '2.40';
20 # We put most everything in %INTERNAL, just so the user won't screw it.
21 # We could also have used packages, but let's keep it simple.
23 $INTERNAL{file} = $ENV{PATH_TRANSLATED};
24 unless (-e $INTERNAL{file}){
25 $ENV{REDIRECT_STATUS} = '404';
26 print STDERR "PLP: Not found: $INTERNAL{file}\n";
28 #Change this if you have an error handling script.
29 print `/vhost/COMMON/err.cgi` || "Status: 404 Not found\n\nFile not found";
36 ($INTERNAL{dir} = $INTERNAL{file}) =~ s{^(.*)/(.*?)$}[$1];
40 ($ENV{PLP_NAME} = $ENV{REQUEST_URI}) =~ s/\?.*$//;
43 $INTERNAL{qq} = "
\10"; #^P
44 $INTERNAL{q} = "
\17"; #^Q
46 $INTERNAL{code} = ReadFile($INTERNAL{file});
48 while ($INTERNAL{code} =~ /<\((.*?)\)>/ ){
49 (my $file = $1) =~ tr/[<>|//d;
50 $INTERNAL{code} =~ s//ReadFile($file)/e;
53 $INTERNAL{code} =~ s(<:)($INTERNAL{q};)g;
54 $INTERNAL{code} =~ s(:>)(;\nprint q$INTERNAL{q})g;
56 while ($INTERNAL{code} =~ /(<\[1(.*?)\]>(.*?)<\[2\]>(.*?)<\[3\]>)/s){
59 $INTERNAL{code} =~ s///; #Redo last match
61 $INTERNAL{code} =~ s(\\\\\r?\n)()g;
63 # This is bad and subject to removal.
64 $INTERNAL{code} =~ s(<\[([^>]*?):(.*?)\]>)($BLOCK{"${1}-1"}$2$BLOCK{"${1}-2"})g;
65 $INTERNAL{code} =~ s(<\[(?!/)(.*?)\]>)($BLOCK{"${1}-1"})g;
66 $INTERNAL{code} =~ s(<\[/(.*?)\]>)($BLOCK{"${1}-2"})g;
68 # This too is bad and subject to removal.
69 $INTERNAL{code} =~ s(<{[ \08\09]*)($INTERNAL{q};print qq$INTERNAL{qq})g;
70 $INTERNAL{code} =~ s([ \08\09]*}>)($INTERNAL{qq};print q$INTERNAL{q})g;
71 $INTERNAL{code} = "print q$INTERNAL{q}$INTERNAL{code}$INTERNAL{q};";
73 $INTERNAL{code} =~ s{print qq$INTERNAL{qq}$INTERNAL{qq};}[]g;
74 $INTERNAL{code} =~ s{print q$INTERNAL{q}$INTERNAL{q};}[]g;
76 tie %header, 'PLP::Headers';
77 tie *PLPOUT, 'PLP::Print';
79 # This is VERY bad, and will probably be removed. Use <: BEGIN { ... }
81 while ($INTERNAL{code} =~ s/<_(.*?)_>//s){
86 if ($@ && $DEBUG & 1){
87 print "\nDebug:\n $@";
92 #$INTERNAL{headers}->();
97 SendHeaders() unless $INTERNAL{sentheaders};
98 if ($@ && $DEBUG & 1){
99 print "<hr><b>Debug</b><br>", Entity($@);