diff --git a/src/Extension/MokoWaaS.php b/src/Extension/MokoWaaS.php index 40207542..a746d163 100644 --- a/src/Extension/MokoWaaS.php +++ b/src/Extension/MokoWaaS.php @@ -1286,12 +1286,55 @@ class MokoWaaS extends CMSPlugin $status = 'degraded'; } + // Total disk and site size + $totalBytes = @disk_total_space(JPATH_ROOT); + $totalMb = $totalBytes !== false + ? round($totalBytes / 1048576) + : null; + + // Site directory size (quick estimate via common dirs) + $siteMb = null; + + try + { + $siteSize = 0; + + foreach (['images', 'media', 'tmp', 'cache', + 'administrator/logs', 'administrator/cache'] as $dir) + { + $path = JPATH_ROOT . '/' . $dir; + + if (is_dir($path)) + { + $iter = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator( + $path, + \FilesystemIterator::SKIP_DOTS + ) + ); + + foreach ($iter as $file) + { + $siteSize += $file->getSize(); + } + } + } + + $siteMb = round($siteSize / 1048576); + } + catch (\Exception $e) + { + // Ignore — siteMb stays null + } + return [ 'status' => $status, 'tmp_writable' => $tmpWritable, 'log_writable' => $logWritable, 'cache_writable' => $cacheWritable, 'free_disk_mb' => $freeMb, + 'total_disk_mb' => $totalMb, + 'site_size_mb' => $siteMb, ]; }