Refactor AdminPanel: extract module, add collapsible sections & shared-links management, enforce PascalCase controllers

This commit is contained in:
Ryan
2025-05-03 23:41:02 -04:00
committed by GitHub
parent 274bedd186
commit f3977153fb
68 changed files with 5678 additions and 590 deletions

View File

@@ -0,0 +1,44 @@
<?php
// public/api/admin/readMetadata.php
require_once __DIR__ . '/../../../config/config.php';
// Simple authcheck: only admins may read these
if (empty($_SESSION['isAdmin']) || $_SESSION['isAdmin'] !== true) {
http_response_code(403);
echo json_encode(['error'=>'Forbidden']);
exit;
}
// Expect a ?file=share_links.json or share_folder_links.json
if (empty($_GET['file'])) {
http_response_code(400);
echo json_encode(['error'=>'Missing `file` parameter']);
exit;
}
$file = basename($_GET['file']);
$allowed = ['share_links.json','share_folder_links.json'];
if (!in_array($file, $allowed, true)) {
http_response_code(403);
echo json_encode(['error'=>'Invalid file requested']);
exit;
}
$path = META_DIR . $file;
if (!file_exists($path)) {
http_response_code(404);
echo json_encode((object)[]); // return empty object
exit;
}
$data = file_get_contents($path);
$json = json_decode($data, true);
if (json_last_error() !== JSON_ERROR_NONE) {
http_response_code(500);
echo json_encode(['error'=>'Corrupted JSON']);
exit;
}
header('Content-Type: application/json');
echo json_encode($json);