settings.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. declare(strict_types=1);
  3. require_once __DIR__ . "/../includes/auth.php";
  4. require_once __DIR__ . "/../includes/layout.php";
  5. require_once __DIR__ . "/../includes/backups.php";
  6. manageRequireLogin();
  7. $messages = [];
  8. $errors = [];
  9. if (($_SERVER["REQUEST_METHOD"] ?? "") === "POST") {
  10. try {
  11. manageRequireCsrf();
  12. $action = (string) ($_POST["action"] ?? "");
  13. if ($action === "save_retention") {
  14. manageBackupWriteSettings([
  15. "retention" => (int) ($_POST["retention"] ?? 0),
  16. "s3_retention" => (int) ($_POST["s3_retention"] ?? 0),
  17. ]);
  18. // Retention changes take effect immediately, not only on next upload.
  19. manageBackupApplyRetentionAll();
  20. $messages[] = "Aufbewahrung gespeichert und angewendet.";
  21. }
  22. } catch (Throwable $exception) {
  23. $errors[] = $exception->getMessage();
  24. }
  25. }
  26. $settings = manageBackupSettings();
  27. $s3Log = manageLogS3Tail(30);
  28. // Everything an operator needs to sanity-check a deployment at a glance.
  29. $diagnostics = [
  30. "Produkt" => manageProductName(),
  31. "Paket-Präfix" => (string) MANAGE_PACKAGE_PREFIX,
  32. "Öffentliche URL" => trim((string) MANAGE_PUBLIC_URL) !== "" ? (string) MANAGE_PUBLIC_URL : "NICHT GESETZT",
  33. "Storage-Verzeichnis" => manageStorageDir(),
  34. "Storage beschreibbar" => is_writable(manageStorageDir()) ? "ja" : "NEIN",
  35. "Admin-Passwort" => managePasswordConfigured() ? "konfiguriert" : "NICHT KONFIGURIERT",
  36. "S3-Archiv" => manageS3Enabled() ? "aktiv" : "aus",
  37. "PHP-Version" => PHP_VERSION,
  38. "upload_max_filesize" => (string) ini_get("upload_max_filesize"),
  39. "post_max_size" => (string) ini_get("post_max_size"),
  40. ];
  41. manageRenderHeader("Einstellungen", $messages, $errors);
  42. ?>
  43. <h2>Aufbewahrung</h2>
  44. <form method="POST" class="panel">
  45. <?php echo manageCsrfField(); ?>
  46. <input type="hidden" name="action" value="save_retention">
  47. <div class="form-row">
  48. <div class="form-group">
  49. <label for="retention">Lokale Backups pro Instanz</label>
  50. <input type="number" id="retention" name="retention" min="1" required
  51. value="<?php echo (int) $settings["retention"]; ?>">
  52. <p class="hint">Mindestens 1. Bei aktivem S3 gilt dieser Wert nur für die lokale Kopie.</p>
  53. </div>
  54. <div class="form-group">
  55. <label for="s3_retention">S3-Backups pro Instanz</label>
  56. <input type="number" id="s3_retention" name="s3_retention" min="1" required
  57. value="<?php echo (int) $settings["s3_retention"]; ?>">
  58. <p class="hint">Nur wirksam, wenn das S3-Archiv aktiviert ist.</p>
  59. </div>
  60. </div>
  61. <button type="submit" class="btn">Speichern und anwenden</button>
  62. </form>
  63. <h2>Diagnose</h2>
  64. <div class="table-scroll">
  65. <table class="data-table">
  66. <tbody>
  67. <?php foreach ($diagnostics as $label => $value): ?>
  68. <tr>
  69. <th scope="row"><?php echo manageEscape($label); ?></th>
  70. <td><code><?php echo manageEscape($value); ?></code></td>
  71. </tr>
  72. <?php endforeach; ?>
  73. </tbody>
  74. </table>
  75. </div>
  76. <h2>Zugangsdaten</h2>
  77. <p>
  78. Passwort und S3-Zugangsdaten stehen ausschließlich in <code>config.php</code> und werden hier bewusst nicht
  79. bearbeitbar gemacht. Neuen Passwort-Hash erzeugen:
  80. </p>
  81. <pre class="code-block">php -r 'echo password_hash("neues-passwort", PASSWORD_DEFAULT), PHP_EOL;'</pre>
  82. <?php if (manageS3Enabled()): ?>
  83. <h2>S3-Protokoll</h2>
  84. <?php if ($s3Log === []): ?>
  85. <p class="empty">Keine S3-Meldungen protokolliert.</p>
  86. <?php else: ?>
  87. <pre class="code-block log-tail"><?php echo manageEscape(implode(PHP_EOL, $s3Log)); ?></pre>
  88. <?php endif; ?>
  89. <?php endif; ?>
  90. <?php manageRenderFooter(); ?>