Show CodePress version and OS in admin site info

This commit is contained in:
2026-07-28 14:47:49 +02:00
parent 3bb16ff116
commit c8343a096e
2 changed files with 12 additions and 1 deletions
+3
View File
@@ -56,7 +56,9 @@
<tr><td class="text-muted">Site titel</td><td><?= htmlspecialchars($siteConfig['site_title'] ?? 'CodePress') ?></td></tr> <tr><td class="text-muted">Site titel</td><td><?= htmlspecialchars($siteConfig['site_title'] ?? 'CodePress') ?></td></tr>
<tr><td class="text-muted">Standaard taal</td><td><?= htmlspecialchars($siteConfig['language']['default'] ?? 'nl') ?></td></tr> <tr><td class="text-muted">Standaard taal</td><td><?= htmlspecialchars($siteConfig['language']['default'] ?? 'nl') ?></td></tr>
<tr><td class="text-muted">Auteur</td><td><?= htmlspecialchars($siteConfig['author']['name'] ?? '-') ?></td></tr> <tr><td class="text-muted">Auteur</td><td><?= htmlspecialchars($siteConfig['author']['name'] ?? '-') ?></td></tr>
<tr><td class="text-muted">CodePress versie</td><td>v<?= htmlspecialchars($stats['cms_version']) ?></td></tr>
<tr><td class="text-muted">PHP versie</td><td><?= $stats['php_version'] ?></td></tr> <tr><td class="text-muted">PHP versie</td><td><?= $stats['php_version'] ?></td></tr>
<tr><td class="text-muted">Besturingssysteem</td><td><?= htmlspecialchars($stats['os']) ?></td></tr>
<tr><td class="text-muted">Config geladen</td><td><?= $stats['config_exists'] ? '<span class="badge bg-success">Ja</span>' : '<span class="badge bg-danger">Nee</span>' ?></td></tr> <tr><td class="text-muted">Config geladen</td><td><?= $stats['config_exists'] ? '<span class="badge bg-success">Ja</span>' : '<span class="badge bg-danger">Nee</span>' ?></td></tr>
</table> </table>
</div> </div>
@@ -74,6 +76,7 @@
<li class="mb-2 pb-2 border-bottom small"> <li class="mb-2 pb-2 border-bottom small">
<span class="text-muted"><?= htmlspecialchars($log['time']) ?></span> <span class="text-muted"><?= htmlspecialchars($log['time']) ?></span>
<span class="badge bg-<?= $log['level'] === 'warning' ? 'warning text-dark' : ($log['level'] === 'error' ? 'danger' : 'info') ?> me-1"><?= htmlspecialchars($log['level']) ?></span> <span class="badge bg-<?= $log['level'] === 'warning' ? 'warning text-dark' : ($log['level'] === 'error' ? 'danger' : 'info') ?> me-1"><?= htmlspecialchars($log['level']) ?></span>
<code class="text-muted"><?= htmlspecialchars($log['ip']) ?></code>
<?= htmlspecialchars($log['message']) ?> <?= htmlspecialchars($log['message']) ?>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
+9 -1
View File
@@ -178,6 +178,9 @@ function handleDashboard(AdminAuth $auth, array $config): void
$pluginsDir = $config['plugins_dir']; $pluginsDir = $config['plugins_dir'];
$configJson = $config['config_json']; $configJson = $config['config_json'];
$versionFile = __DIR__ . '/../version.php';
$versionInfo = file_exists($versionFile) ? include $versionFile : [];
$stats = [ $stats = [
'pages' => countFiles($contentDir, ['md', 'php', 'html']), 'pages' => countFiles($contentDir, ['md', 'php', 'html']),
'directories' => countDirs($contentDir), 'directories' => countDirs($contentDir),
@@ -185,6 +188,8 @@ function handleDashboard(AdminAuth $auth, array $config): void
'config_exists' => file_exists($configJson), 'config_exists' => file_exists($configJson),
'content_size' => formatSize(dirSize($contentDir)), 'content_size' => formatSize(dirSize($contentDir)),
'php_version' => PHP_VERSION, 'php_version' => PHP_VERSION,
'cms_version' => $versionInfo['version'] ?? '-',
'os' => PHP_OS_FAMILY . ' (' . php_uname('r') . ')',
]; ];
// Load site config // Load site config
@@ -290,7 +295,10 @@ function adminLog(array $config, string $level, string $message): void
@mkdir($dir, 0755, true); @mkdir($dir, 0755, true);
} }
$timestamp = date('Y-m-d H:i:s'); $timestamp = date('Y-m-d H:i:s');
$ip = $_SERVER['REMOTE_ADDR'] ?? 'cli'; $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? 'cli';
if (($commaPos = strpos($ip, ',')) !== false) {
$ip = trim(substr($ip, 0, $commaPos));
}
@file_put_contents($logFile, "[{$timestamp}] [{$level}] [{$ip}] {$message}\n", FILE_APPEND); @file_put_contents($logFile, "[{$timestamp}] [{$level}] [{$ip}] {$message}\n", FILE_APPEND);
} }