integration-snippet.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // Die Zeilen, die ein bestehendes Projekt braucht.
  3. // Zum Kopieren gedacht, nicht zum direkten Ausführen.
  4. // ---------------------------------------------------------------------------
  5. // 1. Adminseite für Update und Backup: <projekt>/admin/manage.php
  6. // ---------------------------------------------------------------------------
  7. require_once __DIR__ . "/../config.php";
  8. require_once __DIR__ . "/../includes/functions.php";
  9. // Anmeldung des Projekts zuerst prüfen – das Panel ist die mächtigste Seite
  10. // der Anwendung.
  11. if (empty($_SESSION["admin_logged_in"])) {
  12. header("Location: login.php");
  13. exit;
  14. }
  15. require __DIR__ . "/../manage-client/ui/panel.php";
  16. // ---------------------------------------------------------------------------
  17. // 2. Statusblock auf einer bestehenden Einstellungsseite
  18. // ---------------------------------------------------------------------------
  19. $manageStatusPanelUrl = "manage.php";
  20. include __DIR__ . "/../manage-client/ui/status-partial.php";
  21. // ---------------------------------------------------------------------------
  22. // 3. Automatisches Backup ohne Cron, z. B. auf dem Admin-Dashboard
  23. // ---------------------------------------------------------------------------
  24. require_once __DIR__ . "/../manage-client/lib/client.php";
  25. try {
  26. // Legt nur an, wenn MANAGE_BACKUP_AUTO_INTERVAL_SECONDS abgelaufen ist.
  27. manageBackupCreateAutomaticIfDue();
  28. } catch (Throwable $exception) {
  29. // Ein fehlgeschlagenes Backup darf das Dashboard nicht blockieren.
  30. error_log("Automatisches Backup fehlgeschlagen: " . $exception->getMessage());
  31. }
  32. // ---------------------------------------------------------------------------
  33. // 4. Update-Hinweis in der eigenen Navigation
  34. // ---------------------------------------------------------------------------
  35. require_once __DIR__ . "/../manage-client/lib/client.php";
  36. $manageStatus = manageClientStatus(); // wirft nie
  37. if ($manageStatus["update"] !== null && $manageStatus["update"]["available"]) {
  38. echo '<a href="manage.php">Update ' .
  39. htmlspecialchars($manageStatus["update"]["latest"], ENT_QUOTES, "UTF-8") .
  40. " verfügbar</a>";
  41. }