'not_logged_in' ]); exit; } $user = $_SESSION['user']; $lang = $_GET['lang'] ?? ''; $list = $_GET['list'] ?? ''; if ($lang === '' || $list === '') { echo json_encode([ 'error' => 'missing_params' ]); exit; } $file = listPath($user, $lang, $list); if (!file_exists($file)) { echo json_encode([ 'error' => 'file_not_found', 'file' => $file ]); exit; } $data = JsonDB::read($file); if (!is_array($data) || !isset($data['words'])) { echo json_encode([ 'error' => 'invalid_data_structure' ]); exit; } echo json_encode([ 'ok' => true, 'metadata' => $data['metadata'] ?? null, 'words' => $data['words'] ]); } catch (Throwable $e) { http_response_code(500); echo json_encode([ 'error' => 'server_exception', 'message' => $e->getMessage() ]); }