From 3d477070e9670cec9ddd833895f0dd2df058d0fa Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 19 May 2013 00:22:08 +0200 Subject: [PATCH] Added system information --- .../install/files/acp/templates/index.tpl | 60 ++++++++++++++++++- .../install/files/acp/templates/phpInfo.tpl | 9 +++ .../files/lib/acp/page/IndexPage.class.php | 38 ++++++++++++ .../files/lib/acp/page/PHPInfoPage.class.php | 50 ++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/acp/templates/phpInfo.tpl create mode 100644 wcfsetup/install/files/lib/acp/page/PHPInfoPage.class.php diff --git a/wcfsetup/install/files/acp/templates/index.tpl b/wcfsetup/install/files/acp/templates/index.tpl index 8a684e69f6..ffee1047f7 100644 --- a/wcfsetup/install/files/acp/templates/index.tpl +++ b/wcfsetup/install/files/acp/templates/index.tpl @@ -14,10 +14,17 @@ } -
+
+

{lang}wcf.global.acp{/lang}

+
+ +{event name='userNotice'} + +
{/if} + + + {include file='footer'} \ No newline at end of file diff --git a/wcfsetup/install/files/acp/templates/phpInfo.tpl b/wcfsetup/install/files/acp/templates/phpInfo.tpl new file mode 100644 index 0000000000..c02fc0393a --- /dev/null +++ b/wcfsetup/install/files/acp/templates/phpInfo.tpl @@ -0,0 +1,9 @@ +{include file='header'} + +
+

PHP Version {PHP_VERSION}

+
+ +{@$phpInfo} + +{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/page/IndexPage.class.php b/wcfsetup/install/files/lib/acp/page/IndexPage.class.php index b3b4df6d30..9da687a3e4 100755 --- a/wcfsetup/install/files/lib/acp/page/IndexPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/IndexPage.class.php @@ -20,6 +20,44 @@ use wcf\system\WCF; * @category Community Framework */ class IndexPage extends AbstractPage { + /** + * server information + * @var array + */ + public $server = array(); + + /** + * @see wcf\page\IPage::readData() + */ + public function readData() { + parent::readData(); + + $this->server = array( + 'os' => PHP_OS, + 'webserver' => (isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : ''), + 'mySQLVersion' => WCF::getDB()->getVersion(), + 'load' => '' + ); + + // get load + if ($uptime = @exec("uptime")) { + if (preg_match("/averages?: ([0-9\.]+,?[\s]+[0-9\.]+,?[\s]+[0-9\.]+)/", $uptime, $match)) { + $this->server['load'] = $match[1]; + } + } + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'server' => $this->server + )); + } + /** * @see wcf\page\IPage::show() */ diff --git a/wcfsetup/install/files/lib/acp/page/PHPInfoPage.class.php b/wcfsetup/install/files/lib/acp/page/PHPInfoPage.class.php new file mode 100644 index 0000000000..128935f78f --- /dev/null +++ b/wcfsetup/install/files/lib/acp/page/PHPInfoPage.class.php @@ -0,0 +1,50 @@ + + * @package com.woltlab.wcf + * @subpackage acp.page + * @category Community Framework + */ +class PHPInfoPage extends AbstractPage { + /** + * @see wcf\page\AbstractPage::$templateName + */ + public $templateName = 'phpInfo'; + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + // get phpinfo() output + ob_start(); + phpinfo(); + $info = ob_get_contents(); + ob_end_clean(); + + // parse output + $info = preg_replace('%^.*(.*).*$%s', '$1', $info); + + // style fixes + // remove first table + $info = preg_replace('%
%s', '', $info, 1); + + // fix tables + $info = preg_replace('%

(.*?)

\s*%', '

\\1

', $info); + $info = preg_replace('%
%', '
', $info); + $info = str_replace('
', '
', $info); + + WCF::getTPL()->assign(array( + 'phpInfo' => $info + )); + } +} -- 2.20.1