[TASK] Change visibility of suhosin specific checks in SystemEnvironment
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / ViewHelpers / PhpInfoViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Install\ViewHelpers;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Utility class for phpinfo()
19 *
20 * @author Patrick Broens <patrick@patrickbroens.nl>
21 * @internal
22 */
23 class PhpInfoViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
24
25 /**
26 * Disable the escaping interceptor because otherwise the child nodes would be escaped before this view helper
27 * can decode the text's entities.
28 *
29 * @var bool
30 */
31 protected $escapingInterceptorEnabled = FALSE;
32
33 /**
34 * Render PHP info
35 *
36 * @return string
37 */
38 public function render() {
39 return $this->removeAllHtmlOutsideBody(
40 $this->changeHtmlToHtml5(
41 $this->getPhpInfo()
42 )
43 );
44 }
45
46 /**
47 * Get information about PHP's configuration
48 *
49 * @return string HTML page with the configuration options
50 */
51 public function getPhpInfo() {
52 ob_start();
53 phpinfo();
54
55 return ob_get_clean();
56 }
57
58 /**
59 * Remove all HTML outside the body tag from HTML string
60 *
61 * @param string $html Complete HTML markup for page
62 * @return string Content of the body tag
63 */
64 protected function removeAllHtmlOutsideBody($html) {
65 // Delete anything outside of the body tag and the body tag itself
66 $html = preg_replace('/^.*?<body.*?>/is', '', $html);
67 $html = preg_replace('/<\/body>.*?$/is', '', $html);
68
69 return $html;
70 }
71
72 /**
73 * Change HTML markup to HTML5
74 *
75 * @param string $html HTML markup to be cleaned
76 * @return string
77 */
78 protected function changeHtmlToHtml5($html) {
79 // Delete obsolete attributes
80 $html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
81
82 // Replace font tag with span
83 return str_replace(array('<font', '</font>'), array('<span', '</span>'), $html);
84 }
85
86 }