'Forbidden'])); } $user = checkAuth($pdo); if (!$user) { http_response_code(401); exit(json_encode(['error' => 'Unauthorized'])); } $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if (!$id) { exit(json_encode(['error' => 'Invalid ID'])); } $article = getLocalKnowledgeArticle($pdo, $id); if (!$article) { exit(json_encode(['error' => 'Article not found'])); } $documents = []; if ($article['documents']) { $docs = json_decode($article['documents'], true); if (is_array($docs)) { foreach ($docs as $doc) { $documents[] = [ 'id' => $doc['id'], 'name' => $doc['name'], 'mime' => $doc['mime'], 'url' => 'get_document.php?kid=' . $id . '&doc=' . $doc['id'] ]; } } } echo json_encode([ 'id' => $article['id'], 'title' => $article['title'], 'content' => $article['content'], 'documents' => $documents, 'date' => $article['updated_at'] ?? $article['created_at'] ]); exit;