From: Mischa POSLAWSKY Date: Tue, 2 Oct 2007 10:23:56 +0000 (+0200) Subject: eg/plpinfo.plp demo/status page X-Git-Tag: 3.20~25 X-Git-Url: http://git.shiar.nl/perl/plp/.git/commitdiff_plain/9b76d38ad3dc8f7135e5c2b1594e6815790808bc?hp=0dbf6bc1fe5cd28c532994d13836e9509fcbe194 eg/plpinfo.plp demo/status page Demo page reporting about the current status of Perl and PLP. Useful as test page (see if correct versions are loaded as they should, and what variables are set), or at least as a somewhat larger example of a plp page. Modelled closely after PHP's phpinfo() output (even color scheme is the same, albeit html is much cleaner) to keep it as familiar as possible to php switcheroos. --- diff --git a/eg/plpinfo.plp b/eg/plpinfo.plp new file mode 100644 index 0000000..9578327 --- /dev/null +++ b/eg/plpinfo.plp @@ -0,0 +1,76 @@ + + + +plpinfo() + + + + +

PLP Version <:= $PLP::VERSION :>

+ + +<: +use Config; +printf "\n", @$_ for ( + ["System" => qx(uname -snrvm)], + ["Server API" => "CGI/FastCGI - ".$PLP::interface], #TODO + ["Perl" => join ".", map ord, split //, $^V], + ["Build Date" => $Config{cf_time}], + ["Debug Build" => $^P ? "yes" : "no"], + ["Thread Safety" => $Config{usethreads} ? "enabled" : "disabled"], + ["Include Path" => join "; ", @INC], +); +:>
%s%s
+ +

PLP Core

+ + +<: +my %modules; +s!/!::!g, s/\.pm$// and $modules{$_} = $_->VERSION || "" for keys %INC; +printf "\n", @$_ for ( + ["Modules" => join "
\n", + map "$_ $modules{$_}", sort grep /^PLP/, keys %modules + ], + ["Debug Output" => join "; ", + $PLP::DEBUG & 1 ? "run-time errors" : (), + $PLP::DEBUG & 2 ? "headers" : (), + ], + ["Caching" => $PLP::use_cache ? "on" : "off"], #TODO +); +:>
%s%s
+ +

Environment

+ + +<: +s/(?<=,)//g for values %ENV; # allow breaks at commas (HTTP_ACCEPT*) +printf("\n", + $_, defined $ENV{$_} ? $ENV{$_} : "no value" +) for sort keys %ENV; +:>
%s%s
+ +

PLP Variables

+ + +<: +for my $var qw(get post cookies header) { + printf("\n", + $var, $_, defined $$var{$_} ? $$var{$_} : "no value" + ) for sort keys %$var; +} +:>
%s{'%s'}%s
+ + +