6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
26 function main($id, $mode)
28 global $db, $user, $auth, $template;
29 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
33 trigger_error('NO_MODE', E_USER_ERROR);
36 $this->tpl_name = 'acp_php_info';
37 $this->page_title = 'ACP_PHP_INFO';
40 phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
41 $phpinfo = ob_get_clean();
43 $phpinfo = trim($phpinfo);
45 // Here we play around a little with the PHP Info HTML to try and stylise
46 // it along phpBB's lines ... hopefully without breaking anything. The idea
47 // for this was nabbed from the PHP annotated manual
48 preg_match_all('#<body[^>]*>(.*)</body>#si', $phpinfo, $output);
50 if (empty($phpinfo) || empty($output))
52 trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
55 $output = $output[1][0];
57 // expose_php can make the image not exist
58 if (preg_match('#<a[^>]*><img[^>]*></a>#', $output))
60 $output = preg_replace('#<tr class="v"><td>(.*?<a[^>]*><img[^>]*></a>)(.*?)</td></tr>#s', '<tr class="row1"><td><table class="type2"><tr><td>\2</td><td>\1</td></tr></table></td></tr>', $output);
64 $output = preg_replace('#<tr class="v"><td>(.*?)</td></tr>#s', '<tr class="row1"><td><table class="type2"><tr><td>\1</td></tr></table></td></tr>', $output);
66 $output = preg_replace('#<table[^>]+>#i', '<table>', $output);
67 $output = preg_replace('#<img border="0"#i', '<img', $output);
68 $output = str_replace(array('class="e"', 'class="v"', 'class="h"', '<hr />', '<font', '</font>'), array('class="row1"', 'class="row2"', '', '', '<span', '</span>'), $output);
70 // Fix invalid anchor names (eg "module_Zend Optimizer")
71 $output = preg_replace_callback('#<a name="([^"]+)">#', array($this, 'remove_spaces'), $output);
75 trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
78 $orig_output = $output;
80 preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
81 $output = (!empty($output[1][0])) ? $output[1][0] : $orig_output;
83 $template->assign_var('PHPINFO', $output);
86 function remove_spaces($matches)
88 return '<a name="' . str_replace(' ', '_', $matches[1]) . '">';