[BUGFIX] Inconsistent visual appearance Install Tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Utility / PhpInfo.php
1 <?php
2 namespace TYPO3\CMS\Install\Utility;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Patrick Broens <patrick@patrickbroens.nl>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Utility class for phpinfo()
29 *
30 * @author Patrick Broens <patrick@patrickbroens.nl>
31 */
32 class PhpInfo {
33
34 /**
35 * Get the content of the body tag of phpinfo()
36 *
37 * @return string
38 */
39 public function getBodyContent() {
40 return $this->removeAllHtmlOutsideBody(
41 $this->changeHtmlToHtml5(
42 $this->getPhpInfo()
43 )
44 );
45 }
46
47 /**
48 * Get information about PHP's configuration
49 *
50 * @return string HTML page with the configuration options
51 */
52 public function getPhpInfo() {
53 ob_start();
54 phpinfo();
55
56 return ob_get_clean();
57 }
58
59 /**
60 * Remove all HTML outside the body tag from HTML string
61 *
62 * @param string $html Complete HTML markup for page
63 * @return string Content of the body tag
64 */
65 protected function removeAllHtmlOutsideBody($html) {
66 // Delete anything outside of the body tag and the body tag itself
67 $html = preg_replace('/^.*?<body.*?>/is', '', $html);
68 $html = preg_replace('/<\/body>.*?$/is', '', $html);
69
70 return $html;
71 }
72
73 /**
74 * Change HTML markup to HTML5
75 *
76 * @param string $html HTML markup to be cleaned
77 * @return string
78 */
79 protected function changeHtmlToHtml5($html) {
80 // Delete obsolete attributes
81 $html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
82
83 // Replace font tag with span
84 $html = str_replace(array('<font', '</font>'), array('<span', '</span>'), $html);
85
86 return $html;
87 }
88 }