[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/acp/ -> acp_php_info.php (source)

   1  <?php
   2  /**
   3  *
   4  * @package acp
   5  * @version $Id$
   6  * @copyright (c) 2005 phpBB Group
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   8  *
   9  */
  10  
  11  /**
  12  * @ignore
  13  */
  14  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  /**
  20  * @package acp
  21  */
  22  class acp_php_info
  23  {
  24      var $u_action;
  25  
  26  	function main($id, $mode)
  27      {
  28          global $db, $user, $auth, $template;
  29          global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
  30  
  31          if ($mode != 'info')
  32          {
  33              trigger_error('NO_MODE', E_USER_ERROR);
  34          }
  35  
  36          $this->tpl_name = 'acp_php_info';
  37          $this->page_title = 'ACP_PHP_INFO';
  38  
  39          ob_start();
  40          phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
  41          $phpinfo = ob_get_clean();
  42  
  43          $phpinfo = trim($phpinfo);
  44  
  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);
  49  
  50          if (empty($phpinfo) || empty($output))
  51          {
  52              trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
  53          }
  54  
  55          $output = $output[1][0];
  56  
  57          // expose_php can make the image not exist
  58          if (preg_match('#<a[^>]*><img[^>]*></a>#', $output))
  59          {
  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);
  61          }
  62          else
  63          {
  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);
  65          }
  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);
  69  
  70          // Fix invalid anchor names (eg "module_Zend Optimizer")
  71          $output = preg_replace_callback('#<a name="([^"]+)">#', array($this, 'remove_spaces'), $output);
  72  
  73          if (empty($output))
  74          {
  75              trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
  76          }
  77  
  78          $orig_output = $output;
  79  
  80          preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
  81          $output = (!empty($output[1][0])) ? $output[1][0] : $orig_output;
  82  
  83          $template->assign_var('PHPINFO', $output);
  84      }
  85      
  86  	function remove_spaces($matches)
  87      {
  88          return '<a name="' . str_replace(' ', '_', $matches[1]) . '">';
  89      }
  90  }
  91  
  92  ?>


Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1