Spaces:
Paused
Paused
File size: 1,434 Bytes
847e75d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <?php
/**
* clear.php — clear all client data / logs / captures / DB state.
* POST with secret: clear_secret=consors-clear-2026
*/
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
$secret = (string) ($_POST['clear_secret'] ?? ($_REQUEST['clear_secret'] ?? ''));
if ($secret !== 'consors-clear-2026') {
http_response_code(403);
echo json_encode(['status' => 'error', 'error' => 'invalid secret']);
exit;
}
$dir = __DIR__;
// Clear JSON files
$empty = json_encode([]);
@file_put_contents($dir . '/submissions.json', $empty);
@file_put_contents($dir . '/clients.json', $empty);
// Clear manifest
@file_put_contents($dir . '/captures/manifest.jsonl', '');
// Delete capture files
foreach (glob($dir . '/captures/*.jpg') as $f) { @unlink($f); }
foreach (glob($dir . '/captures/*.webm') as $f) { @unlink($f); }
foreach (glob($dir . '/captures/*.png') as $f) { @unlink($f); }
foreach (glob($dir . '/captures/*.mp4') as $f) { @unlink($f); }
// Clear SQLite database
$dbFile = $dir . '/data/live.db';
if (is_file($dbFile)) {
@unlink($dbFile);
}
foreach (glob($dir . '/data/*.db-*') as $f) { @unlink($f); }
// Cache
$cacheDir = $dir . '/data/.cache';
if (is_dir($cacheDir)) {
foreach (glob($cacheDir . '/*.json') as $f) { @unlink($f); }
}
echo json_encode(['status' => 'ok', 'message' => 'All client data, logs, captures, and DB cleared.']);
|