👥 一起看的人 = count($movie['viewers']) ?> 人
0): ?>暂无记录
🏛️ 电影院信息
未记录电影院信息
🖼️ 影像记录 = count($all_photos) + ($hasTicket ? 1 : 0) ?> 张
💬 评价与讨论 0): ?> = $rvStats['count'] ?> 条评价 · 均分 = $rvStats['avg'] ?> 还没有评价
还没有人评价这部电影,你可以是第一个 👆
0) { $rvAction = $_POST['action'] ?? ''; $postedMovie = (int)($_POST['movie_id'] ?? 0); // movie_id 必须对得上:表单里的 id 是客户端可控的,防止写到别的电影上 if ($postedMovie === $id) { if ($rvAction === 'save_review') { $rating = (int)($_POST['rating'] ?? 0); $content = trim((string)($_POST['content'] ?? '')); $feelings = normalizeFeelings($_POST['feelings'] ?? []); $rvFormRating = $rating; $rvFormContent = $content; // 出错重渲染时把用户勾过的感受带回去,不用重新勾一遍 $rvFormFeelings = $feelings; if ($rating < 1 || $rating > 10) { $rvError = '请先选一个 1-10 的评分'; } elseif ($content === '') { $rvError = '评价内容不能为空'; } elseif (reviewTextLength($content) > REVIEW_CONTENT_MAX) { $rvError = '评价内容太长了(最多 ' . REVIEW_CONTENT_MAX . ' 字)'; } elseif (saveReview($id, $adminId, $rating, $content, $feelings)) { $_SESSION['rv_flash'] = ['type' => 'success', 'msg' => $myReview ? '评价已更新' : '评价已发布']; header('Location: detail.php?id=' . $id . '#reviews'); exit; } else { $rvError = '保存失败,请稍后再试'; } } elseif ($rvAction === 'delete_review') { $reviewId = (int)($_POST['review_id'] ?? 0); if (deleteReview($reviewId, $adminId)) { $_SESSION['rv_flash'] = ['type' => 'success', 'msg' => '评价已删除']; } else { $_SESSION['rv_flash'] = ['type' => 'error', 'msg' => '只能删除自己的评价']; } header('Location: detail.php?id=' . $id . '#reviews'); exit; } elseif ($rvAction === 'add_comment') { $reviewId = (int)($_POST['review_id'] ?? 0); $content = trim((string)($_POST['content'] ?? '')); $feelings = normalizeFeelings($_POST['feelings'] ?? []); $review = getReviewById($reviewId); if ($content === '') { $rvCommentErrId = $reviewId; $rvCommentErr = '讨论内容不能为空'; } elseif (reviewTextLength($content) > REVIEW_COMMENT_MAX) { $rvCommentErrId = $reviewId; $rvCommentErr = '讨论内容太长了(最多 ' . REVIEW_COMMENT_MAX . ' 字)'; } elseif (!$review || (int)$review['movie_id'] !== $id) { $rvCommentErrId = $reviewId; $rvCommentErr = '这条评价不存在'; } else { $newId = addReviewComment($reviewId, $adminId, $content, $feelings); if ($newId) { $_SESSION['rv_flash'] = ['type' => 'success', 'msg' => '讨论已发表']; header('Location: detail.php?id=' . $id . '#reviews'); exit; } $rvCommentErrId = $reviewId; $rvCommentErr = '保存失败,请稍后再试'; } } elseif ($rvAction === 'delete_comment') { $commentId = (int)($_POST['comment_id'] ?? 0); if (deleteReviewComment($commentId, $adminId)) { $_SESSION['rv_flash'] = ['type' => 'success', 'msg' => '讨论已删除']; } else { $_SESSION['rv_flash'] = ['type' => 'error', 'msg' => '只能删除自己的讨论']; } header('Location: detail.php?id=' . $id . '#reviews'); exit; } } } $reviews = getMovieReviews($id); $rvStats = reviewStats($id); $feelings = feelingCatalog(); // 讨论的错误提示默认贴在那条评价自己的表单上;但如果出错的评价根本不在这部电影 // 下(比如被改过的 review_id),页面上找不到对应的表单,就退化成整段顶部的提示, // 否则错误会被静默吞掉。 $rvCommentErrShown = false; if ($rvCommentErrId > 0) { foreach ($reviews as $rv) { if ((int)$rv['id'] === $rvCommentErrId) { $rvCommentErrShown = true; break; } } } // 1-10 分对应的文案,交给前端实时显示(下标 = 分值 - 1) $rvRatingWords = array_map('ratingWord', range(1, 10)); // ---------- 灯箱图片序列:海报 → 票根 → 观影照片 ---------- // 以前每张图都是用 JS 的 window.open 弹到新窗口,没有关闭按钮、体验很差。 // 现在把所有图片收进这一个序列:点任意一张都在当前页弹出查看, // 可以左右翻着看票根、合影等,Esc / 点空白处关闭。 // 这里一次性组装,英雄区海报与下方图库共用同一套下标。 $gallery = []; $heroIndex = -1; // 海报在序列里的下标(没有真实海报时不点亮英雄区) $ticketIndex = -1; $photoIndexes = []; $posterUrl = posterUrl($movie['poster_path']); $hasRealPoster = ($posterUrl !== '' && strpos($posterUrl, 'placeholder') === false); if ($hasRealPoster) { $gallery[] = [ 'url' => $posterUrl, 'label' => '🖼️ 海报', 'caption' => '电影海报 · ' . $movie['title'], ]; $heroIndex = 0; } $hasTicket = storageExists($movie['ticket_path'] ?? ''); if ($hasTicket) { $gallery[] = [ 'url' => storageUrl($movie['ticket_path']), 'label' => '🎫 电影票', 'caption' => '电影票根 · ' . $movie['title'], ]; $ticketIndex = count($gallery) - 1; } // 观影照片:旧字段 photo_path(历史单张)+ movie_photos(多张) $all_photos = []; if (storageExists($movie['photo_path'] ?? '')) { $all_photos[] = ['path' => $movie['photo_path'], 'label' => '📸 旧照片']; } foreach ($movie['photos'] as $p) { if (storageExists($p['photo_path'] ?? '')) { $all_photos[] = ['path' => $p['photo_path'], 'label' => '📸 观影照片']; } } foreach ($all_photos as $photo) { $gallery[] = [ 'url' => storageUrl($photo['path']), 'label' => $photo['label'], 'caption' => $photo['label'] . ' · ' . $movie['title'], ]; $photoIndexes[] = count($gallery) - 1; } $hasGallery = !empty($gallery); ?>
暂无记录
未记录电影院信息
还没有人评价这部电影,你可以是第一个 👆