diff --git a/saas-app/public/install-support.php b/saas-app/public/install-support.php index 8ea913c..ae137f9 100644 --- a/saas-app/public/install-support.php +++ b/saas-app/public/install-support.php @@ -36,6 +36,11 @@ function scripts_installer_lock_path(): string return scripts_saas_app_path() . DIRECTORY_SEPARATOR . '.installer.lock'; } +function scripts_parent_directory(string $path): string +{ + return dirname($path); +} + function scripts_string_contains(string $haystack, string $needle): bool { if (function_exists('str_contains')) { @@ -157,6 +162,46 @@ function scripts_write_env_file(array $values, ?string $targetPath = null): stri return $targetPath; } +function scripts_path_writable_state(string $path): array +{ + $exists = file_exists($path); + $parent = scripts_parent_directory($path); + $targetWritable = $exists ? is_writable($path) : false; + $parentWritable = is_dir($parent) ? is_writable($parent) : false; + + return [ + 'path' => $path, + 'exists' => $exists, + 'readable' => $exists ? is_readable($path) : false, + 'writable' => $exists ? $targetWritable : $parentWritable, + 'target_writable' => $targetWritable, + 'parent' => $parent, + 'parent_exists' => is_dir($parent), + 'parent_writable' => $parentWritable, + ]; +} + +function scripts_path_state_label(array $state): string +{ + if (!$state['parent_exists']) { + return 'Elternordner fehlt'; + } + + if ($state['exists'] && $state['target_writable']) { + return 'beschreibbar'; + } + + if (!$state['exists'] && $state['parent_writable']) { + return 'anlegbar'; + } + + if ($state['exists']) { + return 'nicht beschreibbar'; + } + + return 'nicht anlegbar'; +} + function scripts_format_env_value(string $value): string { if ($value === '') { diff --git a/saas-app/public/install.php b/saas-app/public/install.php index e316a4d..d4cb456 100644 --- a/saas-app/public/install.php +++ b/saas-app/public/install.php @@ -56,6 +56,9 @@ $errors = []; $executedMigrations = []; $bundlePath = is_file(scripts_bundle_output_path()) ? scripts_bundle_output_path() : null; $locked = scripts_installer_is_locked(); +$envPathState = scripts_path_writable_state(scripts_env_path()); +$lockPathState = scripts_path_writable_state(scripts_installer_lock_path()); +$bundlePathState = scripts_path_writable_state(scripts_bundle_output_path()); if ($requestMethod === 'POST' && !$locked) { $csrf = (string) ($_POST['csrf'] ?? ''); @@ -118,7 +121,8 @@ if ($requestMethod === 'POST' && !$locked) { if (scripts_string_contains($message, 'pdo_sqlsrv')) { $errors[] = 'Migrationen konnten nicht direkt ueber PHP ausgefuehrt werden. Bitte `pdo_sqlsrv` pruefen oder das SQL-Bundle manuell importieren.'; } elseif (scripts_string_contains($message, '.env')) { - $errors[] = 'Die Konfiguration konnte nicht gespeichert werden. Bitte Schreibrechte pruefen.'; + $errors[] = 'Die Konfiguration konnte nicht gespeichert werden. Zielpfad: ' . scripts_env_path(); + $errors[] = 'Status fuer .env: ' . scripts_path_state_label($envPathState) . '. Elternordner: ' . $envPathState['parent']; } else { $errors[] = 'Die Installation konnte nicht abgeschlossen werden. Bitte Eingaben, DB-Zugang und Dateirechte pruefen.'; } @@ -439,9 +443,15 @@ function h(string $value): string
  • PHP Version:
  • .env.example:
  • .env:
  • +
  • .env Status:
  • +
  • .env Zielpfad:
  • +
  • .env Elternordner:
  • +
  • .env Elternordner beschreibbar:
  • pdo_sqlsrv:
  • Installer-Lock:
  • +
  • Lock-Datei Status:
  • Bundle-Pfad:
  • +
  • Bundle-Ziel Status: