eg/plpinfo.plp demo/status page
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 2 Oct 2007 10:23:56 +0000 (12:23 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 17 Mar 2008 19:52:26 +0000 (20:52 +0100)
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.

eg/plpinfo.plp [new file with mode: 0644]

diff --git a/eg/plpinfo.plp b/eg/plpinfo.plp
new file mode 100644 (file)
index 0000000..9578327
--- /dev/null
@@ -0,0 +1,76 @@
+<html>
+
+<head>
+<title>plpinfo()</title>
+<style>
+       body {background:#FFF; color:#000; font-family:sans-serif}
+       table, h1 {width:45em; margin:1ex auto}
+       table, h1 {border:1px solid #000; border-collapse:collapse}
+       tr {background:#CCC; color:#000}
+       th, td {text-align:left; vertical-align:baseline}
+       th, td, h1 {padding:0.1ex 0.2em}
+       th {background:#CCF; width:33%}
+       h1 {font-size:150%; width:30em; background:#99C; color:#000}
+       h2 {font-size:125%; text-align:center}
+       i {color:#666}
+</style>
+</head>
+
+<body>
+<h1>PLP Version <:= $PLP::VERSION :></h1>
+
+<table border="1">
+<:
+use Config;
+printf "<tr><th>%s</th><td>%s</td></tr>\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],
+);
+:></table>
+
+<h2>PLP Core</h2>
+
+<table border="1">
+<:
+my %modules;
+s!/!::!g, s/\.pm$// and $modules{$_} = $_->VERSION || "" for keys %INC;
+printf "<tr><th>%s</th><td>%s</td></tr>\n", @$_ for (
+       ["Modules" => join "<br>\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
+);
+:></table>
+
+<h2>Environment</h2>
+
+<table border="1">
+<:
+s/(?<=,)/<wbr>/g for values %ENV; # allow breaks at commas (HTTP_ACCEPT*)
+printf("<tr><th>%s</th><td>%s</td></tr>\n",
+       $_, defined $ENV{$_} ? $ENV{$_} : "<i>no value</i>"
+) for sort keys %ENV;
+:></table>
+
+<h2>PLP Variables</h2>
+
+<table border="1">
+<:
+for my $var qw(get post cookies header) {
+       printf("<tr><th>%s{'%s'}</th><td>%s</td></tr>\n",
+               $var, $_, defined $$var{$_} ? $$var{$_} : "<i>no value</i>"
+       ) for sort keys %$var;
+}
+:></table>
+
+</body>
+</html>