initial upload

This commit is contained in:
root
2026-03-24 10:22:01 +00:00
commit e805f225bc
19 changed files with 2160 additions and 0 deletions

27
db_download.php Normal file
View File

@ -0,0 +1,27 @@
<?php
// /var/www/html/db_download.php
require_once __DIR__ . '/common.php';
// Token prüfen
$auth = $_SERVER['HTTP_AUTHORIZATION'] ?? ($_SERVER['Authorization'] ?? '');
if (stripos($auth, 'Bearer ') !== 0) { http_response_code(401); echo "Fehlender Bearer-Token"; exit; }
$token = substr($auth, 7);
if (!token_is_valid($token)) { http_response_code(403); echo "Ungültiger oder abgelaufener Token"; exit; }
// DB entschlüsseln
$path = __DIR__ . '/uploads/questionnaire_database';
if (!file_exists($path)) { http_response_code(404); echo "Datenbank nicht gefunden"; exit; }
$enc = file_get_contents($path);
if ($enc === false) { http_response_code(500); echo "Lesefehler"; exit; }
try {
$plain = aes256_cbc_decrypt_bytes($enc, get_master_key_bytes());
} catch (Throwable $e) {
http_response_code(500); echo "Entschlüsselung fehlgeschlagen"; exit;
}
// Ausliefern
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="questionnaire.sqlite"');
header('Content-Length: ' . strlen($plain));
echo $plain;