Add dashboard box for system information
authorMarcel Werk <burntime@woltlab.com>
Sun, 1 Oct 2023 14:21:18 +0000 (16:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 24 Dec 2023 16:05:10 +0000 (17:05 +0100)
wcfsetup/install/files/acp/templates/index.tpl
wcfsetup/install/files/acp/templates/systemInfoAcpDashboardBox.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/page/IndexPage.class.php
wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
wcfsetup/install/files/lib/system/acp/dashboard/box/SystemInfoAcpDashboardBox.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index cafafd1ad6307a80664d68f35a0007eebf5d1394..a8477dda74b7f3bc777ac05ad191a173300a1edd 100644 (file)
        {/foreach}
 </div>
 
-<div class="section tabMenuContainer" data-active="system" data-store="activeTabMenuItem">
+<div class="section tabMenuContainer" data-active="credits" data-store="activeTabMenuItem">
        <nav class="tabMenu">
                <ul>
-                       <li><a href="#system">{lang}wcf.acp.index.system{/lang}</a></li>
                        <li><a href="#credits">{lang}wcf.acp.index.credits{/lang}</a></li>
                        
                        {event name='tabMenuTabs'}
                </ul>
        </nav>
        
-       <div id="system" class="hidden tabMenuContent">
-               <section class="section">
-                       <h2 class="sectionTitle">{lang}wcf.acp.index.system.software{/lang}</h2>
-                       
-                       <dl>
-                               <dt>{lang}wcf.acp.index.system.software.version{/lang}</dt>
-                               <dd>{WCF_VERSION}</dd>
-                       </dl>
-                       
-                       {event name='softwareFields'}
-                       
-                       <dl>
-                               <dt>{lang}wcf.acp.index.system.software.databaseName{/lang}</dt>
-                               <dd>{$databaseName}</dd>
-                       </dl>
-
-                       {if WCF_N != 1}
-                               <dl>
-                                       <dt>{lang}wcf.acp.index.system.software.databaseNumber{/lang}</dt>
-                                       <dd>{WCF_N}</dd>
-                               </dl>
-                       {/if}
-               </section>
-               
-               {if !ENABLE_ENTERPRISE_MODE || $__wcf->getUser()->hasOwnerAccess()}
-                       <section class="section">
-                               <h2 class="sectionTitle">{lang}wcf.acp.index.system.server{/lang}</h2>
-                               
-                               <dl>
-                                       <dt>{lang}wcf.acp.index.system.os{/lang}</dt>
-                                       <dd>{$server[os]}</dd>
-                               </dl>
-                               
-                               <dl>
-                                       <dt>{lang}wcf.acp.index.system.webserver{/lang}</dt>
-                                       <dd>{$server[webserver]}</dd>
-                               </dl>
-                               
-                               <dl>
-                                       <dt>{lang}wcf.acp.index.system.mySQLVersion{/lang}</dt>
-                                       <dd>{$server[mySQLVersion]}</dd>
-                               </dl>
-                               
-                               {if $server[load]}
-                                       <dl>
-                                               <dt>{lang}wcf.acp.index.system.load{/lang}</dt>
-                                               <dd>{$server[load]}</dd>
-                                       </dl>
-                               {/if}
-                               
-                               {if $server[innodbFlushLogAtTrxCommit] !== false}
-                                       <dl>
-                                               <dt>innodb_flush_log_at_trx_commit</dt>
-                                               <dd>{$server[innodbFlushLogAtTrxCommit]}</dd>
-                                       </dl>
-                               {/if}
-                               
-                               {event name='serverFields'}
-                       </section>
-               
-                       <section class="section">
-                               <h2 class="sectionTitle">{lang}wcf.acp.index.system.php{/lang}</h2>
-                               
-                               <dl>
-                                       <dt>{lang}wcf.acp.index.system.php.version{/lang}</dt>
-                                       <dd>
-                                               {if $__wcf->session->getPermission('admin.configuration.package.canInstallPackage') && $__wcf->session->getPermission('admin.configuration.package.canUpdatePackage')}
-                                                       <a href="{link controller='PHPInfo'}{/link}">{PHP_VERSION}</a>
-                                               {else}
-                                                       {PHP_VERSION}
-                                               {/if}
-                                       </dd>
-                               </dl>
-                               
-                               <dl>
-                                       <dt>memory_limit</dt>
-                                       <dd>
-                                               {$server[memoryLimit]}
-                                       </dd>
-                               </dl>
-                               
-                               <dl>
-                                       <dt>post_max_size</dt>
-                                       <dd>
-                                               {$server[postMaxSize]}
-                                       </dd>
-                               </dl>
-                               
-                               <dl>
-                                       <dt>upload_max_filesize</dt>
-                                       <dd>
-                                               {$server[upload_max_filesize]}
-                                       </dd>
-                               </dl>
-                               
-                               {event name='phpFields'}
-                       </section>
-               {/if}
-               
-               {event name='systemFieldsets'}
-       </div>
-       
        <div id="credits" class="hidden tabMenuContent">
                <section class="section">
                        <dl>
diff --git a/wcfsetup/install/files/acp/templates/systemInfoAcpDashboardBox.tpl b/wcfsetup/install/files/acp/templates/systemInfoAcpDashboardBox.tpl
new file mode 100644 (file)
index 0000000..2cdd817
--- /dev/null
@@ -0,0 +1,99 @@
+<section class="section">
+       <h2 class="sectionTitle">{lang}wcf.acp.dashboard.box.systemInfo.software{/lang}</h2>
+       
+       <dl>
+               <dt>{lang}wcf.acp.dashboard.box.systemInfo.software.version{/lang}</dt>
+               <dd>{WCF_VERSION}</dd>
+       </dl>
+       
+       {event name='softwareFields'}
+       
+       <dl>
+               <dt>{lang}wcf.acp.dashboard.box.systemInfo.software.databaseName{/lang}</dt>
+               <dd>{$databaseName}</dd>
+       </dl>
+
+       {if WCF_N != 1}
+               <dl>
+                       <dt>{lang}wcf.acp.dashboard.box.systemInfo.software.databaseNumber{/lang}</dt>
+                       <dd>{WCF_N}</dd>
+               </dl>
+       {/if}
+</section>
+
+{if !ENABLE_ENTERPRISE_MODE || $__wcf->getUser()->hasOwnerAccess()}
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.acp.dashboard.box.systemInfo.server{/lang}</h2>
+               
+               <dl>
+                       <dt>{lang}wcf.acp.dashboard.box.systemInfo.os{/lang}</dt>
+                       <dd>{$server[os]}</dd>
+               </dl>
+               
+               <dl>
+                       <dt>{lang}wcf.acp.dashboard.box.systemInfo.webserver{/lang}</dt>
+                       <dd>{$server[webserver]}</dd>
+               </dl>
+               
+               <dl>
+                       <dt>{lang}wcf.acp.dashboard.box.systemInfo.mySQLVersion{/lang}</dt>
+                       <dd>{$server[mySQLVersion]}</dd>
+               </dl>
+               
+               {if $server[load]}
+                       <dl>
+                               <dt>{lang}wcf.acp.dashboard.box.systemInfo.load{/lang}</dt>
+                               <dd>{$server[load]}</dd>
+                       </dl>
+               {/if}
+               
+               {if $server[innodbFlushLogAtTrxCommit] !== false}
+                       <dl>
+                               <dt>innodb_flush_log_at_trx_commit</dt>
+                               <dd>{$server[innodbFlushLogAtTrxCommit]}</dd>
+                       </dl>
+               {/if}
+               
+               {event name='serverFields'}
+       </section>
+
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.acp.dashboard.box.systemInfo.php{/lang}</h2>
+               
+               <dl>
+                       <dt>{lang}wcf.acp.dashboard.box.systemInfo.php.version{/lang}</dt>
+                       <dd>
+                               {if $__wcf->session->getPermission('admin.configuration.package.canInstallPackage') && $__wcf->session->getPermission('admin.configuration.package.canUpdatePackage')}
+                                       <a href="{link controller='PHPInfo'}{/link}">{PHP_VERSION}</a>
+                               {else}
+                                       {PHP_VERSION}
+                               {/if}
+                       </dd>
+               </dl>
+               
+               <dl>
+                       <dt>memory_limit</dt>
+                       <dd>
+                               {$server[memoryLimit]}
+                       </dd>
+               </dl>
+               
+               <dl>
+                       <dt>post_max_size</dt>
+                       <dd>
+                               {$server[postMaxSize]}
+                       </dd>
+               </dl>
+               
+               <dl>
+                       <dt>upload_max_filesize</dt>
+                       <dd>
+                               {$server[upload_max_filesize]}
+                       </dd>
+               </dl>
+               
+               {event name='phpFields'}
+       </section>
+{/if}
+
+{event name='systemFieldsets'}
index b94c7980fcde7b07ca346ac854000cbb24f74619..e3f9dc6ccb4415ab30d5c1352e83f3dc9f00ff61 100755 (executable)
@@ -43,35 +43,6 @@ class IndexPage extends AbstractPage
     public function readData()
     {
         parent::readData();
-
-        $sql = "SELECT @@innodb_flush_log_at_trx_commit";
-        $statement = WCF::getDB()->prepareStatement($sql);
-        $statement->execute();
-        $innodbFlushLogAtTrxCommit = $statement->fetchSingleColumn();
-
-        $this->server = [
-            'os' => \PHP_OS,
-            'webserver' => $_SERVER['SERVER_SOFTWARE'] ?? '',
-            'mySQLVersion' => WCF::getDB()->getVersion(),
-            'load' => '',
-            'memoryLimit' => \ini_get('memory_limit'),
-            'upload_max_filesize' => \ini_get('upload_max_filesize'),
-            'postMaxSize' => \ini_get('post_max_size'),
-            'innodbFlushLogAtTrxCommit' => $innodbFlushLogAtTrxCommit,
-        ];
-
-        // get load
-        if (\function_exists('sys_getloadavg')) {
-            $load = \sys_getloadavg();
-            if (\is_array($load) && \count($load) == 3) {
-                $this->server['load'] = \implode(
-                    ', ',
-                    \array_map(static function (float $value) {
-                        return \sprintf('%.2F', $value);
-                    }, $load)
-                );
-            }
-        }
     }
 
     /**
@@ -182,16 +153,10 @@ class IndexPage extends AbstractPage
             }
         }
 
-        $sql = "SELECT DATABASE()";
-        $statement = WCF::getDB()->prepare($sql);
-        $statement->execute();
-        $databaseName = $statement->fetchSingleColumn();
-
         WCF::getTPL()->assign([
             'recaptchaWithoutKey' => $recaptchaWithoutKey,
             'recaptchaKeyLink' => $recaptchaKeyLink,
             'server' => $this->server,
-            'databaseName' => $databaseName,
             'usersAwaitingApproval' => $usersAwaitingApproval,
             'evaluationExpired' => $evaluationExpired,
             'evaluationPending' => $evaluationPending,
index ae0f1d781f6192f0bb5c423c39d7447590b53a99..7fbf589183edb38badf94c7b86bc715b86140597 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use wcf\system\acp\dashboard\box\NewsAcpDashboardBox;
+use wcf\system\acp\dashboard\box\SystemInfoAcpDashboardBox;
 use wcf\system\acp\dashboard\event\AcpDashboardCollecting;
 use wcf\system\cronjob\CronjobScheduler;
 use wcf\system\event\EventHandler;
@@ -77,6 +78,7 @@ return static function (): void {
 
     $eventHandler->register(AcpDashboardCollecting::class, static function (AcpDashboardCollecting $event) {
         $event->register('com.woltlab.wcf.news', new NewsAcpDashboardBox());
+        $event->register('com.woltlab.wcf.systemInfo', new SystemInfoAcpDashboardBox());
     });
 
     try {
diff --git a/wcfsetup/install/files/lib/system/acp/dashboard/box/SystemInfoAcpDashboardBox.class.php b/wcfsetup/install/files/lib/system/acp/dashboard/box/SystemInfoAcpDashboardBox.class.php
new file mode 100644 (file)
index 0000000..0bda07e
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+namespace wcf\system\acp\dashboard\box;
+
+use wcf\system\WCF;
+
+/**
+ * ACP dashboard box that shows system information.
+ *
+ * @author      Marcel Werk
+ * @copyright   2001-2023 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+final class SystemInfoAcpDashboardBox extends AbstractAcpDashboardBox
+{
+    public function getTitle(): string
+    {
+        return WCF::getLanguage()->get('wcf.acp.dashboard.box.systemInfo');
+    }
+
+    public function getContent(): string
+    {
+        return WCF::getTPL()->fetch('systemInfoAcpDashboardBox', 'wcf', $this->getVariables());
+    }
+
+    private function getVariables(): array
+    {
+        return [
+            'databaseName' => $this->getDatabaseName(),
+            'server' => $this->getServerInfo(),
+        ];
+    }
+
+    private function getDatabaseName(): string
+    {
+        $sql = "SELECT DATABASE()";
+        $statement = WCF::getDB()->prepare($sql);
+        $statement->execute();
+        return $statement->fetchSingleColumn();
+    }
+
+    private function getServerInfo(): array
+    {
+        return [
+            'os' => \PHP_OS,
+            'webserver' => $_SERVER['SERVER_SOFTWARE'] ?? '',
+            'mySQLVersion' => WCF::getDB()->getVersion(),
+            'load' => $this->getLoad(),
+            'memoryLimit' => \ini_get('memory_limit'),
+            'upload_max_filesize' => \ini_get('upload_max_filesize'),
+            'postMaxSize' => \ini_get('post_max_size'),
+            'innodbFlushLogAtTrxCommit' => $this->getInnodbFlushLogAtTrxCommit(),
+        ];
+    }
+
+    private function getInnodbFlushLogAtTrxCommit(): int
+    {
+        $sql = "SELECT @@innodb_flush_log_at_trx_commit";
+        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement->execute();
+        return $statement->fetchSingleColumn();
+    }
+
+    private function getLoad(): string
+    {
+        if (\function_exists('sys_getloadavg')) {
+            $load = \sys_getloadavg();
+            if (\is_array($load) && \count($load) == 3) {
+                return \implode(
+                    ', ',
+                    \array_map(static function (float $value) {
+                        return \sprintf('%.2F', $value);
+                    }, $load)
+                );
+            }
+        }
+
+        return '';
+    }
+}
index 9bd11e21fff31025e30867fd0601c741765f7cd9..b68846096de8d359540bfb541d95178a7ca39b69 100644 (file)
@@ -940,6 +940,18 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE
        </category>
        <category name="wcf.acp.dashboard">
                <item name="wcf.acp.dashboard.box.news"><![CDATA[Nachrichten]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo"><![CDATA[System]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software"><![CDATA[Software]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.version"><![CDATA[WoltLab Suite&trade; Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.databaseNumber"><![CDATA[Datenbank-Installationsnummer]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.databaseName"><![CDATA[Datenbankname]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.server"><![CDATA[Server]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.os"><![CDATA[Betriebssystem]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.webserver"><![CDATA[Webserver]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.php"><![CDATA[PHP]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.php.version"><![CDATA[PHP-Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.mySQLVersion"><![CDATA[MySQL-Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.load"><![CDATA[Aktueller UNIX Load]]></item>
        </category>
        <category name="wcf.acp.index">
                <item name="wcf.acp.index.credits"><![CDATA[Über WoltLab Suite&trade;]]></item>
@@ -953,18 +965,6 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE
                <item name="wcf.acp.index.inRescueMode"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du rufst{else}Sie rufen{/if} diese Installation über eine abweichende Domain auf, etwa aufgrund eines Umzuges. Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}korrigiere{else}korrigieren Sie{/if} die Einstellungen unter <a href="{link controller='ApplicationManagement'}{/link}">Apps verwalten</a>.]]></item>
                <item name="wcf.acp.index.setup.notice"><![CDATA[Die Installation wird in wenigen Augenblicken automatisch gestartet, bitte {if LANGUAGE_USE_INFORMAL_VARIANT}lade{else}laden Sie{/if} diese Seite nicht neu.]]></item>
                <item name="wcf.acp.index.setup.title"><![CDATA[Bitte warten]]></item>
-               <item name="wcf.acp.index.system"><![CDATA[System]]></item>
-               <item name="wcf.acp.index.system.software"><![CDATA[Software]]></item>
-               <item name="wcf.acp.index.system.software.version"><![CDATA[WoltLab Suite&trade; Version]]></item>
-               <item name="wcf.acp.index.system.software.databaseNumber"><![CDATA[Datenbank-Installationsnummer]]></item>
-               <item name="wcf.acp.index.system.software.databaseName"><![CDATA[Datenbankname]]></item>
-               <item name="wcf.acp.index.system.server"><![CDATA[Server]]></item>
-               <item name="wcf.acp.index.system.os"><![CDATA[Betriebssystem]]></item>
-               <item name="wcf.acp.index.system.webserver"><![CDATA[Webserver]]></item>
-               <item name="wcf.acp.index.system.php"><![CDATA[PHP]]></item>
-               <item name="wcf.acp.index.system.php.version"><![CDATA[PHP-Version]]></item>
-               <item name="wcf.acp.index.system.mySQLVersion"><![CDATA[MySQL-Version]]></item>
-               <item name="wcf.acp.index.system.load"><![CDATA[Aktueller UNIX Load]]></item>
                <item name="wcf.acp.index.woltlab.website"><![CDATA[Website]]></item>
                <item name="wcf.acp.index.woltlab.manual"><![CDATA[Handbuch]]></item>
                <item name="wcf.acp.index.woltlab.forums"><![CDATA[Supportforum]]></item>
index 7ef8caa450bd3d92e712d28f71976cf902994581..4d788ba89d26abd91b3a2cdfbb8c5a6467dceb41 100644 (file)
@@ -918,6 +918,18 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru
        </category>
        <category name="wcf.acp.dashboard">
                <item name="wcf.acp.dashboard.box.news"><![CDATA[News]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo"><![CDATA[System]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software"><![CDATA[Software]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.version"><![CDATA[WoltLab Suite&trade; Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.databaseNumber"><![CDATA[Database Installation Number]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.software.databaseName"><![CDATA[Database Name]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.server"><![CDATA[Server]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.os"><![CDATA[Operating System]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.webserver"><![CDATA[Web Server]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.php"><![CDATA[PHP]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.php.version"><![CDATA[PHP Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.mySQLVersion"><![CDATA[MySQL Version]]></item>
+               <item name="wcf.acp.dashboard.box.systemInfo.load"><![CDATA[Current UNIX Load]]></item>
        </category>
        <category name="wcf.acp.index">
                <item name="wcf.acp.index.credits"><![CDATA[About WoltLab Suite&trade;]]></item>
@@ -931,18 +943,6 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru
                <item name="wcf.acp.index.inRescueMode"><![CDATA[You are accessing this installation from an unknown domain, possibly caused by moving to a new host. Please update the settings on <a href="{link controller='ApplicationManagement'}{/link}">Manage Apps</a>.]]></item>
                <item name="wcf.acp.index.setup.notice"><![CDATA[The installation will be continued within a few moments, please do not reload this page.]]></item>
                <item name="wcf.acp.index.setup.title"><![CDATA[Please Wait]]></item>
-               <item name="wcf.acp.index.system"><![CDATA[System]]></item>
-               <item name="wcf.acp.index.system.software"><![CDATA[Software]]></item>
-               <item name="wcf.acp.index.system.software.version"><![CDATA[WoltLab Suite&trade; Version]]></item>
-               <item name="wcf.acp.index.system.software.databaseNumber"><![CDATA[Database Installation Number]]></item>
-               <item name="wcf.acp.index.system.software.databaseName"><![CDATA[Database Name]]></item>
-               <item name="wcf.acp.index.system.server"><![CDATA[Server]]></item>
-               <item name="wcf.acp.index.system.os"><![CDATA[Operating System]]></item>
-               <item name="wcf.acp.index.system.webserver"><![CDATA[Web Server]]></item>
-               <item name="wcf.acp.index.system.php"><![CDATA[PHP]]></item>
-               <item name="wcf.acp.index.system.php.version"><![CDATA[PHP Version]]></item>
-               <item name="wcf.acp.index.system.mySQLVersion"><![CDATA[MySQL Version]]></item>
-               <item name="wcf.acp.index.system.load"><![CDATA[Current UNIX Load]]></item>
                <item name="wcf.acp.index.woltlab.website"><![CDATA[Website]]></item>
                <item name="wcf.acp.index.woltlab.manual"><![CDATA[Manual]]></item>
                <item name="wcf.acp.index.woltlab.forums"><![CDATA[Support Forums]]></item>