option('lang'); if (is_string($lang) && in_array($lang, ['en', 'nl'])) { App::setLocale($lang); } $this->platform = $this->detectPlatform(); $this->detectWebUserContext(); $this->info('╔════════════════════════════════════════════════════════════╗'); $this->info('║ ATOM CMS MASTER REPAIR COMMAND ║'); $this->info('╚════════════════════════════════════════════════════════════╝'); $this->info(' Platform: ' . strtoupper($this->platform)); $this->info(' User : ' . $this->webUser . ' / ' . $this->webGroup); $this->info(' PHP : ' . PHP_VERSION); $this->newLine(); $runner = new DiagnosticRunner; $results = $runner->runAll(); foreach ($results as $result) { $icon = match ($result->status) { 'ok' => '✓', 'warning' => '⚠', 'error' => '✗', default => '?', }; $this->line(" {$icon} {$result->name}: {$result->message}"); if ($result->fix) { $this->line(" → {$result->fix}"); } } $this->newLine(); $this->info('Summary: ' . count($runner->getOk()) . ' OK, ' . count($runner->getWarnings()) . ' warnings, ' . count($runner->getErrors()) . ' errors'); if ($this->option('fix') || $this->option('interactive')) { return $this->runFixWizard(); } return $runner->hasErrors() ? 1 : 0; } private function runFixWizard(): int { $this->warn('Interactive fix wizard - use --auto for non-interactive mode'); if ($this->confirm('Run all automatic fixes?', false)) { $this->call('optimize:clear'); $this->call('config:cache'); $this->call('view:cache'); $this->info('Fixes completed'); return 0; } return 1; } private function detectPlatform(): string { if (PHP_OS_FAMILY === 'Windows') { return 'windows'; } if (file_exists('/etc/nginx')) { return 'linux-nginx'; } if (file_exists('/etc/apache2') || file_exists('/etc/httpd')) { return 'linux-apache'; } return 'linux'; } private function detectWebUserContext(): void { if (function_exists('posix_getpwuid')) { $user = posix_getpwuid(posix_geteuid()); $this->webUser = $user['name'] ?? 'unknown'; } if (file_exists('/etc/group')) { $group = exec('id -gn 2>/dev/null'); if ($group) { $this->webGroup = trim($group); } } } }