--- /dev/null
+#!/usr/bin/perl
+
+$VERSION = '2.01';
+
+$INTERNAL{file} = $ENV{PATH_TRANSLATED};
+unless (-e $INTERNAL{file}){
+ $ENV{REDIRECT_STATUS} = '404';
+ print STDERR "htmpl: Not found: $INTERNAL{file}\n";
+
+ #Change this if you have an error handling script.
+ print `/vhost/COMMON/err.cgi` || "Status: 404 Not found\n\nFile not found";
+
+ exit;
+}
+
+($INTERNAL{dir} = $INTERNAL{file}) =~ s{^(.*)/.*?$}[$1];
+chdir $INTERNAL{dir};
+
+($ENV{PLP_NAME} = $ENV{REQUEST_URI}) =~ s/\?.*$//;
+
+use plp;
+
+$INTERNAL{qq} = "\10"; #^P
+$INTERNAL{q} = "\17"; #^Q
+
+$header{'content-type'} = 'text/html';
+$header{'status'} = '200 OK';
+
+$INTERNAL{code} = ReadFile($INTERNAL{file});
+
+while ($INTERNAL{code} =~ /<\((.*?)\)>/ ){
+ ($INTERNAL{file} = $1) =~ s/[<>\|]//g;
+ $INTERNAL{code} =~ s//ReadFile($INTERNAL{file})/e;
+}
+
+$INTERNAL{code} =~ s(<:)($INTERNAL{q};)g;
+$INTERNAL{code} =~ s(:>)(;\nprint q$INTERNAL{q})g;
+
+while ($INTERNAL{code} =~ /(<\[1(.*?)\]>(.*?)<\[2\]>(.*?)<\[3\]>)/s){
+ $INTERNAL{naam} = $2;
+ $BLOCK{"$INTERNAL{naam}-1"} = $3;
+ $BLOCK{"$INTERNAL{naam}-2"} = $4;
+ $INTERNAL{code} =~ s///; #Redo last match
+}
+$INTERNAL{code} =~ s(\\\\\r?\n)()g;
+$INTERNAL{code} =~ s(<\[([^>]*?):(.*?)\]>)($BLOCK{"${1}-1"}$2$BLOCK{"${1}-2"})g;
+$INTERNAL{code} =~ s(<\[(?!/)(.*?)\]>)($BLOCK{"${1}-1"})g;
+$INTERNAL{code} =~ s(<\[/(.*?)\]>)($BLOCK{"${1}-2"})g;
+$INTERNAL{code} =~ s(<{[ \08\09]*)($INTERNAL{q};print qq$INTERNAL{qq})g;
+$INTERNAL{code} =~ s([ \08\09]*}>)($INTERNAL{qq};print q$INTERNAL{q})g;
+$INTERNAL{code} = "print q$INTERNAL{q}$INTERNAL{code}$INTERNAL{q};";
+
+$INTERNAL{code} =~ s{print qq$INTERNAL{qq}$INTERNAL{qq};}[]g;
+$INTERNAL{code} =~ s{print q$INTERNAL{q}$INTERNAL{q};}[]g;
+
+
+while ($INTERNAL{code} =~ s/<_(.*?)_>//s){
+ $INTERNAL{pre} = $1;
+ eval $INTERNAL{pre};
+}
+
+for (keys %header){
+ print "$_: $header{$_}\n";
+}
+print "\n";
+
+eval $INTERNAL{code};
+if ($@){
+ print "<hr><b>Debug</b><br>", Entity($@);
+}
+
+if ($Debug){
+ print "<hr>Debug:<pre>$INTERNAL{code}<hr>$output";
+}
--- /dev/null
+if ($ENV{QUERY_STRING} ne ''){
+ for (split /&/, $ENV{QUERY_STRING}) {
+ split /=/;
+ for (@_) {
+ $_ = DecodeURI($_);
+ }
+ $get{$_[0]} = $_[1];
+ }
+}
+
+
+$INTERNAL{post} = <STDIN>;
+if ($INTERNAL{post} ne ''){
+ for (split /&/, $INTERNAL{post}) {
+ split /=/;
+ for (@_) {
+ $_ = DecodeURI($_);
+ }
+ $post{$_[0]} = $_[1];
+ }
+}
+%fields=(%get, %post);
+
+$INTERNAL{koek} = $ENV{HTTP_COOKIE};
+if ($INTERNAL{koek} ne ''){
+ for (split /; ?/, $INTERNAL{koek}) {
+ split /=/;
+ #for (@_) {
+ # $_ = DecodeURI($_);
+ #}
+ $cookie{$_[0]} ||= $_[1];
+ }
+}
+
+1;
--- /dev/null
+sub HiddenFields($@){
+ $INTERNAL{hash} = shift;
+ $INTERNAL{saves} = $INTERNAL{q} . (join $INTERNAL{q}, @_) . $INTERNAL{q};
+# $INTERNAL{human} = join ',', @_;
+# print "<!-- $INTERNAL{hash}: $INTERNAL{human} -->";
+ for (keys %{$INTERNAL{hash}}){
+ print qq{<input type=hidden name="$_" value="${$INTERNAL{hash}}{$_}">}
+ unless $INTERNAL{saves} =~ /$INTERNAL{q}$_$INTERNAL{q}/;
+ }
+}
+
+sub NoHeaders($){
+ $_[0] =~ s/^.*?\n\n//;
+ return $_[0]
+}
+
+sub Entity($;$$$$){
+ $_[4] ||= 4;
+ $_[0] =~ s/&/&/g;
+ $_[0] =~ s/\"/"/g;
+ $_[0] =~ s/</</g;
+ $_[0] =~ s/>/>/g;
+ if ($_[1]){
+ $_[0] =~ s/\n/<br>\n/g;
+ }
+ if ($_[2]){
+ $_[0] =~ s/\t/' ' x $_[4]/eg;
+ }
+ if ($_[3]){
+ $_[0] =~ s/ / /g;
+ }
+ return $_[0]
+}
+
+sub DecodeURI($;$){
+ my $t = $_[0];
+ $t =~ tr{+} { } unless ($_[1] == 1);
+ $t =~ s{%([0-9A-Fa-f]{2})}
+ {pack('c',hex($1))}ge;
+ return $t;
+}
+
+sub EncodeURI($;$){
+ my $t = $_[0];
+ $t =~ s{([^a-zA-Z0-9_\-.])}
+ {uc sprintf("%%%02x",ord($1))}ge;
+ $t =~ s{%20}{+}g if ($_[1] == 1);
+ return $t;
+}
+
+sub AddCookie($){
+ if ($header{'set-cookie'}){
+ $header{'set-cookie'} .= "\nset-cookie: $_[0]";
+ }else{
+ $header{'set-cookie'} = $_[0];
+ }
+}
+
+sub ReadFile($){
+ my $o = $/; undef $/;
+ open (READFILE, $_[0]);
+ my $r = <READFILE>;
+ close READFILE;
+ $/ = $o;
+ return $r;
+}
+
+sub WriteFile($$){
+ open (WRITEFILE, ">$_[0]");
+ flock WRITEFILE, 2;
+ print WRITEFILE $_[1];
+ close WRITEFILE;
+}
+1;
\ No newline at end of file