includes/acp/acp_php_info.php
changeset 0 ceef6d64c21d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/includes/acp/acp_php_info.php	Wed Mar 07 16:41:10 2012 +0400
     1.3 @@ -0,0 +1,92 @@
     1.4 +<?php
     1.5 +/**
     1.6 +*
     1.7 +* @package acp
     1.8 +* @version $Id$
     1.9 +* @copyright (c) 2005 phpBB Group
    1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
    1.11 +*
    1.12 +*/
    1.13 +
    1.14 +/**
    1.15 +* @ignore
    1.16 +*/
    1.17 +if (!defined('IN_PHPBB'))
    1.18 +{
    1.19 +	exit;
    1.20 +}
    1.21 +
    1.22 +/**
    1.23 +* @package acp
    1.24 +*/
    1.25 +class acp_php_info
    1.26 +{
    1.27 +	var $u_action;
    1.28 +
    1.29 +	function main($id, $mode)
    1.30 +	{
    1.31 +		global $db, $user, $auth, $template;
    1.32 +		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
    1.33 +
    1.34 +		if ($mode != 'info')
    1.35 +		{
    1.36 +			trigger_error('NO_MODE', E_USER_ERROR);
    1.37 +		}
    1.38 +
    1.39 +		$this->tpl_name = 'acp_php_info';
    1.40 +		$this->page_title = 'ACP_PHP_INFO';
    1.41 +
    1.42 +		ob_start();
    1.43 +		phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
    1.44 +		$phpinfo = ob_get_clean();
    1.45 +
    1.46 +		$phpinfo = trim($phpinfo);
    1.47 +
    1.48 +		// Here we play around a little with the PHP Info HTML to try and stylise
    1.49 +		// it along phpBB's lines ... hopefully without breaking anything. The idea
    1.50 +		// for this was nabbed from the PHP annotated manual
    1.51 +		preg_match_all('#<body[^>]*>(.*)</body>#si', $phpinfo, $output);
    1.52 +
    1.53 +		if (empty($phpinfo) || empty($output))
    1.54 +		{
    1.55 +			trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
    1.56 +		}
    1.57 +
    1.58 +		$output = $output[1][0];
    1.59 +
    1.60 +		// expose_php can make the image not exist
    1.61 +		if (preg_match('#<a[^>]*><img[^>]*></a>#', $output))
    1.62 +		{
    1.63 +			$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);
    1.64 +		}
    1.65 +		else
    1.66 +		{
    1.67 +			$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);
    1.68 +		}
    1.69 +		$output = preg_replace('#<table[^>]+>#i', '<table>', $output);
    1.70 +		$output = preg_replace('#<img border="0"#i', '<img', $output);
    1.71 +		$output = str_replace(array('class="e"', 'class="v"', 'class="h"', '<hr />', '<font', '</font>'), array('class="row1"', 'class="row2"', '', '', '<span', '</span>'), $output);
    1.72 +
    1.73 +		// Fix invalid anchor names (eg "module_Zend Optimizer")
    1.74 +		$output = preg_replace_callback('#<a name="([^"]+)">#', array($this, 'remove_spaces'), $output);
    1.75 +
    1.76 +		if (empty($output))
    1.77 +		{
    1.78 +			trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
    1.79 +		}
    1.80 +
    1.81 +		$orig_output = $output;
    1.82 +
    1.83 +		preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
    1.84 +		$output = (!empty($output[1][0])) ? $output[1][0] : $orig_output;
    1.85 +
    1.86 +		$template->assign_var('PHPINFO', $output);
    1.87 +	}
    1.88 +	
    1.89 +	function remove_spaces($matches)
    1.90 +	{
    1.91 +		return '<a name="' . str_replace(' ', '_', $matches[1]) . '">';
    1.92 +	}
    1.93 +}
    1.94 +
    1.95 +?>
    1.96 \ No newline at end of file