prepare('SELECT * FROM threads WHERE id = ?'); $st->execute([$id]); $thread = $st->fetch(); if (!$thread) { http_response_code(404); fb_layout_head('问题不存在'); echo '

该问题不存在或已被删除。

返回问题列表

'; fb_layout_foot(); exit; } // 审核(先审后显):未通过审核的问题对访客不可见 if (!fb_thread_public($thread)) { $justSubmitted = (isset($_GET['submitted']) && (string)$_GET['submitted'] === '1'); if ($justSubmitted) { fb_layout_head('提交成功', ['robots' => 'noindex,nofollow']); echo '
' . '

提交成功,等待审核

' . '

你的反馈已收到(编号 #' . (int)$thread['id'] . '),我们会先确认它是否为应用问题:

' . '

· 确认为问题 —— 审核通过后会公开显示,其他人也能查看与回复;
' . '· 确认不是问题 —— 我们会关闭它,并把结论与说明发送到你留下的邮箱。

' . '

审核通常在 1~2 个工作日内完成,请留意邮箱。

' . '

返回问题列表

' . '
'; fb_layout_foot(); exit; } http_response_code(404); fb_layout_head('问题不存在'); echo '

该问题不存在或已被删除。

返回问题列表

'; fb_layout_foot(); exit; } $statuses = fb_statuses(); $err = ''; $atts = []; $form = ['name' => '', 'email' => '', 'body' => '', 'captcha' => '']; /* ---------------- 处理回复提交 ---------------- */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // 审核中(未公开)的问题不允许回复 if (!fb_thread_public($thread)) { http_response_code(403); fb_layout_head('暂不可回复'); echo '

该问题还在审核中,暂时不能回复。

返回问题列表

'; fb_layout_foot(); exit; } $form['name'] = trim(isset($_POST['name']) ? (string)$_POST['name'] : ''); $form['email'] = trim(isset($_POST['email']) ? (string)$_POST['email'] : ''); $form['body'] = trim(isset($_POST['body']) ? (string)$_POST['body'] : ''); $capInput = isset($_POST['captcha']) ? (string)$_POST['captcha'] : ''; $adminPw = isset($_POST['admin_password']) ? (string)$_POST['admin_password'] : ''; $hp = trim(isset($_POST['website']) ? (string)$_POST['website'] : ''); $t0 = isset($_POST['t0']) ? (int)$_POST['t0'] : 0; list($attOk, $attList, $attErr) = fb_attach_parse(isset($_POST['attachments']) ? $_POST['attachments'] : ''); $isAdmin = ($adminPw !== '' && fb_admin_verify_password($adminPw)); if (!fb_csrf_ok(isset($_POST['csrf']) ? $_POST['csrf'] : '')) { $err = '会话已过期,请重新提交。'; } elseif ($hp !== '') { $err = '提交未通过校验,请重试。'; } elseif ($t0 > 0 && (time() - $t0) < max(0, (int)fb_cfg('post_min_seconds', 3))) { $err = '提交过于频繁,请稍候再试。'; } elseif (!fb_valid_name($form['name']) && !$isAdmin) { $err = '请填写昵称(1~24 个字符)。'; } elseif (!$isAdmin && !filter_var($form['email'], FILTER_VALIDATE_EMAIL)) { $err = '请填写有效的邮箱地址(用于接收回复通知)。'; } elseif (!fb_valid_body($form['body'])) { $err = '回复内容请填写 2~5000 个字符。'; } elseif (!$attOk) { $err = $attErr; } elseif (!fb_rate_check('reply', (int)fb_cfg('rate_limit.reply_per_hour', 20))) { $err = '回复过于频繁,请稍后再试。'; } else { list($vOk, $vList, $vErr) = fb_attach_verify($attList); if (!$vOk) { $err = $vErr; $atts = $attList; } elseif (!fb_attach_cap_ok($pdo, $vList)) { $err = '附件存储空间已满,请减少附件后重试。'; $atts = $vList; } elseif (!fb_captcha_check($capInput)) { $err = '人机验证未通过,请重新作答。'; $atts = $vList; } else { $now = time(); $replyName = $isAdmin ? '官方' : $form['name']; $replyMail = $isAdmin ? null : $form['email']; $ins = $pdo->prepare('INSERT INTO replies(thread_id, body, author_name, author_email, is_admin, created_at, ip_hash) VALUES(?,?,?,?,?,?,?)'); $ins->execute([$id, $form['body'], $replyName, $replyMail, $isAdmin ? 1 : 0, $now, fb_ip_hash()]); $replyId = (int)$pdo->lastInsertId(); fb_attach_save($pdo, $id, $replyId, $vList); // 更新主题:回复数 +1、活跃时间;管理员可同时调整状态 $newStatus = null; if ($isAdmin && isset($_POST['status']) && isset($statuses[(string)$_POST['status']])) { $newStatus = (string)$_POST['status']; } if ($newStatus !== null) { $upd = $pdo->prepare('UPDATE threads SET reply_count = reply_count + 1, updated_at = ?, status = ? WHERE id = ?'); $upd->execute([$now, $newStatus, $id]); } else { $upd = $pdo->prepare('UPDATE threads SET reply_count = reply_count + 1, updated_at = ? WHERE id = ?'); $upd->execute([$now, $id]); } fb_rate_hit('reply'); // 发送通知邮件给发帖人 $replyRow = [ 'id' => $replyId, 'body' => $form['body'], 'author_name' => $replyName, 'author_email' => $replyMail, 'is_admin' => $isAdmin ? 1 : 0, ]; fb_notify_reply($pdo, $thread, $replyRow, $isAdmin); fb_redirect('thread.php?id=' . $id . '#r' . $replyId); } } } /* ---------------- 读取数据 ---------------- */ $st = $pdo->prepare('SELECT id, body, author_name, is_admin, created_at FROM replies WHERE thread_id = ? ORDER BY created_at ASC, id ASC'); $st->execute([$id]); $replies = $st->fetchAll(); // 重新读取主题(可能在 POST 中更新过状态) $st = $pdo->prepare('SELECT * FROM threads WHERE id = ?'); $st->execute([$id]); $thread = $st->fetch(); // 附件(主题级 + 各回复) $attMap = fb_attach_for_thread($pdo, $id); fb_layout_head(fb_excerpt($thread['title'], 50)); ?>
← 返回问题列表

#
· · 条回复

全部回复()

还没有回复,欢迎在下方参与讨论。

官方答复 ·
true]); } ?>

我要回复