Backup #634
| ID | 634 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Controller/BackupRestoreController.php |
| Version | 7 |
| Typ |
modified |
| Größe | 3.3 KB |
| Hash | d1cd517af8e44fc37f49c27be8de490194a371d343e9837d321521b1085becbc |
| Datum | 2025-12-23 04:45:11 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
declare(strict_types=1);
namespace Controller;
use Framework\Controller;
use Infrastructure\Persistence\FileBackupRepository;
/**
* Controller for File Backup management.
*/
class BackupRestoreController extends Controller
{
private FileBackupRepository $repository;
public function __construct(FileBackupRepository $repository)
{
$this->repository = $repository;
}
/**
* GET /backup-restore
* List all backups.
*/
public function index(): void
{
$filters = [];
$search = $this->getString('search');
if ($search !== '') {
$filters['search'] = $search;
}
$changeType = $this->getString('change_type');
if ($changeType !== '') {
$filters['change_type'] = $changeType;
}
$limit = 50;
$offset = $this->getInt('offset');
$backups = $this->repository->findAll($filters, $limit, $offset);
$total = $this->repository->count($filters);
$stats = $this->repository->getStatistics();
$this->view('backup-restore.index', [
'title' => 'File Backup',
'backups' => $backups,
'stats' => $stats,
'total' => $total,
'filters' => $filters,
]);
}
/**
* GET /backup-restore/{id}
* Show backup details.
*/
public function show(string $id): void
{
$backup = $this->repository->findById((int) $id);
if ($backup === null) {
$this->notFound('Backup nicht gefunden');
}
// Get content preview (max 500 lines)
$contentPreview = $this->repository->getContentPreview((int) $id, 500);
// Get other versions of this file
$versions = $this->repository->findByFilePath($backup['file_path']);
// Check if file currently exists
$fileExists = file_exists($backup['file_path']);
$this->view('backup-restore.show', [
'title' => 'Backup #' . $id,
'backup' => $backup,
'contentPreview' => $contentPreview,
'versions' => $versions,
'fileExists' => $fileExists,
]);
}
/**
* POST /backup-restore/{id}/restore
* Restore file from backup.
*/
public function restore(string $id): void
{
$this->requireCsrf();
try {
$this->repository->restore((int) $id);
// Redirect with success message
header('Location: /backup-restore/' . $id . '?restored=1');
} catch (\RuntimeException $e) {
// Redirect with error message
header('Location: /backup-restore/' . $id . '?error=' . urlencode($e->getMessage()));
}
}
/**
* GET /backup-restore/{id}/download
* Download full backup content as file.
*/
public function download(string $id): void
{
$backup = $this->repository->findById((int) $id);
if ($backup === null) {
$this->notFound('Backup nicht gefunden');
}
$filename = basename($backup['file_path']) . '.backup-v' . $backup['version'];
header('Content-Type: text/plain; charset=utf-8');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Length: ' . strlen($backup['file_content']));
echo $backup['file_content'];
}
}
Vollständig herunterladen
Aktionen
Andere Versionen dieser Datei
| ID |
Version |
Typ |
Größe |
Datum |
| 1766 |
11 |
modified |
3.2 KB |
2025-12-27 12:54 |
| 1267 |
10 |
modified |
3.2 KB |
2025-12-25 12:51 |
| 696 |
9 |
modified |
3.2 KB |
2025-12-23 07:53 |
| 657 |
8 |
modified |
3.2 KB |
2025-12-23 04:50 |
| 634 |
7 |
modified |
3.3 KB |
2025-12-23 04:45 |
| 606 |
6 |
modified |
3.4 KB |
2025-12-23 04:39 |
| 588 |
5 |
modified |
3.3 KB |
2025-12-23 04:24 |
| 308 |
4 |
modified |
3.3 KB |
2025-12-22 08:05 |
| 245 |
3 |
modified |
3.4 KB |
2025-12-22 01:46 |
| 244 |
2 |
modified |
3.4 KB |
2025-12-22 01:46 |
| 103 |
1 |
modified |
3.4 KB |
2025-12-20 19:19 |
← Zurück zur Übersicht