Add Env/Request superglobals output to PrettyPage handler

This commit is contained in:
filp
2013-03-13 11:20:51 +00:00
parent bb18819ae1
commit dab2dbbd9e
2 changed files with 30 additions and 5 deletions
+22 -5
View File
@@ -39,15 +39,32 @@ class PrettyPage extends Handler
$frames = $inspector->getFrames();
$v = (object) array(
'name' => explode('\\', $inspector->getExceptionName()),
'message' => $inspector->getException()->getMessage(),
'frames' => $frames,
'hasFrames' => !!count($frames)
'name' => explode('\\', $inspector->getExceptionName()),
'message' => $inspector->getException()->getMessage(),
'frames' => $frames,
'hasFrames' => !!count($frames),
'super' => array(
'Server/Request Data' => $_SERVER,
'Files' => $_FILES,
'GET Data' => $_GET,
'POST Data' => $_POST,
'Cookies' => $_COOKIE,
'Session' => isset($_SESSION) ? $_SESSION: array(),
'Environment Variables' => $_ENV
)
);
call_user_func(function() use($templateFile, $v) {
// $e -> cleanup output
$e = function($_) { return htmlspecialchars($_, ENT_QUOTES, 'UTF-8'); };
$e = function($_) { return htmlspecialchars($_, ENT_QUOTES, 'UTF-8'); };
// $slug -> sluggify string (i.e: Hello world! -> hello-world)
$slug = function($_) {
$_ = str_replace(" ", "-", $_);
$_ = preg_replace('/[^\w\d\-\_]/i', '', $_);
return strtolower($_);
};
require $templateFile;
});
+8
View File
@@ -182,6 +182,14 @@
</div>
<?php endforeach ?>
</div>
<div class="superglobals-container">
<?php foreach($v->super as $label => $data): ?>
<div class="superglobal" id="sg-<?php echo $e($slug($label)) ?>">
<label><?php echo $e($label) ?></label>
<pre class="prettyprint"><?php echo $e(print_r($data, true)); ?></pre>
</div>
<?php endforeach ?>
</div>
</div>
</div>