= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB'; if ($bytes >= 1048576) return number_format($bytes / 1048576, 1) . ' MB'; if ($bytes >= 1024) return number_format($bytes / 1024, 1) . ' KB'; return $bytes . ' B'; } // --- PHP --------------------------------------------------------------- $phpChecks = array( array('PHP version', PHP_VERSION_ID >= 80100, PHP_VERSION), ); foreach (array('mysqli' => true, 'curl' => false, 'openssl' => false, 'gd' => false, 'zip' => false, 'mbstring' => false) as $ext => $required) { $phpChecks[] = array( 'Extension: ' . $ext, extension_loaded($ext), extension_loaded($ext) ? 'Loaded' : ($required ? 'Missing (required)' : 'Missing (optional)'), ); } // --- Database ------------------------------------------------------------ $dbSize = db()->fetchOne(" SELECT ROUND(SUM(data_length + index_length)) AS `bytes`, COUNT(*) AS `tables` FROM `information_schema`.`tables` WHERE `table_schema` = DATABASE(); "); $dbBytes = (int)($dbSize['bytes'] ?? 0); $dbTables = (int)($dbSize['tables'] ?? 0); // --- Cache ----------------------------------------------------------- $cacheStats = function_exists('znote_cache_stats') ? znote_cache_stats() : array('files' => 0, 'bytes' => 0, 'apcu_available' => false); // --- Migrations -------------------------------------------------------- $migrationStatus = function_exists('znote_migrations_status') ? znote_migrations_status() : array(); $pendingMigrations = 0; foreach ($migrationStatus as $m) { if (($m['state'] ?? '') === 'pending') $pendingMigrations++; } // --- Disk -------------------------------------------------------------- $diskFree = @disk_free_space(dirname(__DIR__, 2)); $diskTotal = @disk_total_space(dirname(__DIR__, 2)); // --- Error log ----------------------------------------------------------- $errorLogPath = trim((string)(setting('error_log:path', '') ?: (string)@ini_get('error_log'))); $errorLogSize = ($errorLogPath !== '' && is_file($errorLogPath)) ? (int)filesize($errorLogPath) : null; $errorLogModified = ($errorLogPath !== '' && is_file($errorLogPath)) ? (int)filemtime($errorLogPath) : null; // --- Backups ------------------------------------------------------------- $backups = function_exists('znote_backups_list') ? znote_backups_list() : array(); $lastBackup = $backups[0] ?? null; ?>
| = h($check[0]) ?> | = h($check[2]) ?> |
| = t_default('acp.health.db_tables', 'Database tables') ?> | = number_format($dbTables) ?> |
| = t_default('acp.health.cache_size', 'Cache on disk') ?> | = h(acp_health_bytes((int)($cacheStats['bytes'] ?? 0))) ?> |
| = t_default('acp.health.apcu', 'APCu memory cache') ?> | = !empty($cacheStats['apcu_available']) ? t_default('acp.health.available', 'Available') : t_default('acp.health.unavailable', 'Unavailable') ?> |
| = t_default('acp.health.disk_free', 'Disk free') ?> | = h(acp_health_bytes((int)$diskFree)) ?> / = h(acp_health_bytes((int)$diskTotal)) ?> |
= t_default('acp.health.errorlog_summary', '{path} - {size}, last written {when}.', [
'path' => '' . h($errorLogPath) . '',
'size' => h(acp_health_bytes($errorLogSize)),
'when' => h(getClock((int)$errorLogModified, true)),
]) ?>
= t_default('acp.health.errorlog_none', 'No log file found at the configured or auto-detected path.') ?>