0; $postData = null; if ($isEdit) { $db = Database::getInstance(); $post = $db->fetchOne("SELECT * FROM posts WHERE id = ? AND user_id = ?", [$postId, $_SESSION['user_id']]); if (!$post) { http_response_code(404); die('帖子不存在或无权编辑'); } $postData = $post; } $db = Database::getInstance(); $categories = $db->fetchAll("SELECT * FROM categories ORDER BY sort_order ASC"); $allTags = $db->fetchAll("SELECT * FROM tags ORDER BY name ASC"); $postTags = []; if ($postData) { $postTags = $db->fetchAll("SELECT t.* FROM tags t JOIN post_tags pt ON t.id = pt.tag_id WHERE pt.post_id = ?", [$postId]); } ?> <?php echo $isEdit ? '编辑帖子' : '发布新帖'; ?> - OSS Community
Markdown 编辑器