Skip to content

Commit

Permalink
BlueScreen: phpinfo() returns text in CLI [Closes #444]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 21, 2020
1 parent d85f267 commit 925c357
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/Tracy/BlueScreen/BlueScreen.php
Expand Up @@ -405,4 +405,22 @@ function ($m) {

return $msg;
}


private function renderPhpInfo(): void
{
ob_start();
@phpinfo(INFO_LICENSE); // @ phpinfo may be disabled
$license = ob_get_clean();
ob_start();
@phpinfo(INFO_CONFIGURATION | INFO_MODULES); // @ phpinfo may be disabled
$info = ob_get_clean();

if (strpos($license, '<body>') === false) {
echo '<pre>', Helpers::escapeHtml($info), '</pre>';
} else {
$info = str_replace('<table', '<table class="tracy-sortable"', $info);
echo preg_replace('#^.+<body>|</body>.+\z#s', '', $info);
}
}
}
4 changes: 1 addition & 3 deletions src/Tracy/BlueScreen/assets/content.phtml
Expand Up @@ -267,9 +267,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : '';

<h3><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Configuration options</a></h3>
<div class="outer tracy-collapsed">
<?php ob_start(); @phpinfo(INFO_CONFIGURATION | INFO_MODULES); $phpinfo = ob_get_clean(); // @ phpinfo can be disabled
$phpinfo = str_replace('<table', '<table class="tracy-sortable"', $phpinfo);
echo preg_replace('#^.+<body>|</body>.+\z#s', '', $phpinfo) ?>
<?php $this->renderPhpInfo() ?>
</div>
</div></div>
<?php endif ?>
Expand Down

0 comments on commit 925c357

Please sign in to comment.