includes/acp/acp_php_info.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Wed, 07 Mar 2012 17:33:40 +0400
changeset 1 a633f7a37958
parent 0 ceef6d64c21d
permissions -rw-r--r--
Language RU
indvdum@0
     1
<?php
indvdum@0
     2
/**
indvdum@0
     3
*
indvdum@0
     4
* @package acp
indvdum@0
     5
* @version $Id$
indvdum@0
     6
* @copyright (c) 2005 phpBB Group
indvdum@0
     7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
indvdum@0
     8
*
indvdum@0
     9
*/
indvdum@0
    10
indvdum@0
    11
/**
indvdum@0
    12
* @ignore
indvdum@0
    13
*/
indvdum@0
    14
if (!defined('IN_PHPBB'))
indvdum@0
    15
{
indvdum@0
    16
	exit;
indvdum@0
    17
}
indvdum@0
    18
indvdum@0
    19
/**
indvdum@0
    20
* @package acp
indvdum@0
    21
*/
indvdum@0
    22
class acp_php_info
indvdum@0
    23
{
indvdum@0
    24
	var $u_action;
indvdum@0
    25
indvdum@0
    26
	function main($id, $mode)
indvdum@0
    27
	{
indvdum@0
    28
		global $db, $user, $auth, $template;
indvdum@0
    29
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
indvdum@0
    30
indvdum@0
    31
		if ($mode != 'info')
indvdum@0
    32
		{
indvdum@0
    33
			trigger_error('NO_MODE', E_USER_ERROR);
indvdum@0
    34
		}
indvdum@0
    35
indvdum@0
    36
		$this->tpl_name = 'acp_php_info';
indvdum@0
    37
		$this->page_title = 'ACP_PHP_INFO';
indvdum@0
    38
indvdum@0
    39
		ob_start();
indvdum@0
    40
		phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
indvdum@0
    41
		$phpinfo = ob_get_clean();
indvdum@0
    42
indvdum@0
    43
		$phpinfo = trim($phpinfo);
indvdum@0
    44
indvdum@0
    45
		// Here we play around a little with the PHP Info HTML to try and stylise
indvdum@0
    46
		// it along phpBB's lines ... hopefully without breaking anything. The idea
indvdum@0
    47
		// for this was nabbed from the PHP annotated manual
indvdum@0
    48
		preg_match_all('#<body[^>]*>(.*)</body>#si', $phpinfo, $output);
indvdum@0
    49
indvdum@0
    50
		if (empty($phpinfo) || empty($output))
indvdum@0
    51
		{
indvdum@0
    52
			trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
indvdum@0
    53
		}
indvdum@0
    54
indvdum@0
    55
		$output = $output[1][0];
indvdum@0
    56
indvdum@0
    57
		// expose_php can make the image not exist
indvdum@0
    58
		if (preg_match('#<a[^>]*><img[^>]*></a>#', $output))
indvdum@0
    59
		{
indvdum@0
    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);
indvdum@0
    61
		}
indvdum@0
    62
		else
indvdum@0
    63
		{
indvdum@0
    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);
indvdum@0
    65
		}
indvdum@0
    66
		$output = preg_replace('#<table[^>]+>#i', '<table>', $output);
indvdum@0
    67
		$output = preg_replace('#<img border="0"#i', '<img', $output);
indvdum@0
    68
		$output = str_replace(array('class="e"', 'class="v"', 'class="h"', '<hr />', '<font', '</font>'), array('class="row1"', 'class="row2"', '', '', '<span', '</span>'), $output);
indvdum@0
    69
indvdum@0
    70
		// Fix invalid anchor names (eg "module_Zend Optimizer")
indvdum@0
    71
		$output = preg_replace_callback('#<a name="([^"]+)">#', array($this, 'remove_spaces'), $output);
indvdum@0
    72
indvdum@0
    73
		if (empty($output))
indvdum@0
    74
		{
indvdum@0
    75
			trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
indvdum@0
    76
		}
indvdum@0
    77
indvdum@0
    78
		$orig_output = $output;
indvdum@0
    79
indvdum@0
    80
		preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
indvdum@0
    81
		$output = (!empty($output[1][0])) ? $output[1][0] : $orig_output;
indvdum@0
    82
indvdum@0
    83
		$template->assign_var('PHPINFO', $output);
indvdum@0
    84
	}
indvdum@0
    85
	
indvdum@0
    86
	function remove_spaces($matches)
indvdum@0
    87
	{
indvdum@0
    88
		return '<a name="' . str_replace(' ', '_', $matches[1]) . '">';
indvdum@0
    89
	}
indvdum@0
    90
}
indvdum@0
    91
indvdum@0
    92
?>