backup_database.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. session_start();
  3. // Config lade
  4. $config = include(__DIR__ . '/../config.php');
  5. // WebsiteID us der URL hole
  6. $websiteId = isset($_GET['websiteId']) ? (int)$_GET['websiteId'] : 1;
  7. // Website config ider config finde
  8. $websiteConfig = array_filter($config, function($site) use ($websiteId) {
  9. return isset($site['id']) && $site['id'] === $websiteId;
  10. });
  11. $websiteConfig = reset($websiteConfig);
  12. // omg en request mache zum backup erstelle und so wie bin ich so tüüf gfalle 😭
  13. $source = $websiteConfig['database'];
  14. $backupDir = __DIR__ . '/../' . $websiteConfig['backup_folder'];
  15. $timestamp = date('Y-m-d-H-i-s');
  16. $destination = $backupDir . '/' . $timestamp . '.db';
  17. // stell der vor es git kei backup folder 😱 denn meun mer de mache
  18. if (!is_dir($backupDir)) {
  19. mkdir($backupDir, 0755, true);
  20. }
  21. // und jetzt stell der vor mer kopieret die datei deht ineh 😱
  22. if (copy($source, $destination)) {
  23. $backupMessage = "Database backup created successfully: " . htmlspecialchars($destination);
  24. } else {
  25. $backupMessage = "Failed to create database backup.";
  26. }
  27. // zrug zum sexxi admin panel mit de message mir sind so guet und sexi , ich wird niemals eh frau ha im lebe ich bin single af
  28. header("Location: index.php?backupMessage=" . urlencode($backupMessage));
  29. exit();
  30. ?>