mirror of
https://github.com/error311/FileRise.git
synced 2026-05-12 06:50:54 -05:00
ab2f519cbe
- sources(core): add SourcesConfig + core WebDAV adapter (Local + WebDAV without Pro)
- sources(api/ui): migrate /api/pro/sources/* to SourcesConfig and expose capability metadata (allowedTypes/proExtended)
- admin: add per-source delete-permanently toggle + trash-off badges/hints
- pro: add Gateway Shares admin section + /api/pro/gateways/{list,save,test,delete}
- ui: fix pagination getting stuck on page 2 in table/gallery (pane state sync)
- frontend/security: move pretheme to external js/pretheme.js and remove inline CSP hash requirement
- licensing: attempt yearly-plan instance auto-bind on license save with clearer autoBind responses
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
// public/api/pro/sources/delete.php
|
|
declare(strict_types=1);
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
require_once __DIR__ . '/../../../../config/config.php';
|
|
require_once PROJECT_ROOT . '/src/lib/SourcesConfig.php';
|
|
|
|
try {
|
|
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') !== 'POST') {
|
|
http_response_code(405);
|
|
echo json_encode(['ok' => false, 'error' => 'Method not allowed']);
|
|
exit;
|
|
}
|
|
|
|
if (session_status() !== PHP_SESSION_ACTIVE) {
|
|
session_start();
|
|
}
|
|
|
|
\FileRise\Http\Controllers\AdminController::requireAuth();
|
|
\FileRise\Http\Controllers\AdminController::requireAdmin();
|
|
\FileRise\Http\Controllers\AdminController::requireCsrf();
|
|
|
|
$raw = file_get_contents('php://input');
|
|
$body = json_decode($raw, true);
|
|
if (!is_array($body)) {
|
|
http_response_code(400);
|
|
echo json_encode(['ok' => false, 'error' => 'Invalid JSON body']);
|
|
exit;
|
|
}
|
|
|
|
$id = trim((string)($body['id'] ?? ''));
|
|
if ($id === '') {
|
|
http_response_code(400);
|
|
echo json_encode(['ok' => false, 'error' => 'Missing source id']);
|
|
exit;
|
|
}
|
|
|
|
$res = SourcesConfig::deleteSource($id);
|
|
if (empty($res['ok'])) {
|
|
http_response_code(400);
|
|
echo json_encode(['ok' => false, 'error' => $res['error'] ?? 'Failed to delete source']);
|
|
exit;
|
|
}
|
|
|
|
$cfg = \FileRise\Domain\AdminModel::getConfig();
|
|
if (!isset($cfg['error'])) {
|
|
$public = \FileRise\Domain\AdminModel::buildPublicSubset($cfg);
|
|
\FileRise\Domain\AdminModel::writeSiteConfig($public);
|
|
}
|
|
|
|
echo json_encode(['ok' => true], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
} catch (Throwable $e) {
|
|
http_response_code(500);
|
|
echo json_encode(['ok' => false, 'error' => 'Error deleting source'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
}
|