SOURCE DOWNLOAD

木漏茶室源码下载中心

整站 PHP 源码:可浏览文件、复制路径、下载单文件或打包 ZIP。

发布版本 v6.25.230 升级后自动生成独立源码包,下载中心只发送这份冻结包 已排除 config.php / 用户数据 / 上传文件 / 升级备份
komorebi-forum 183 个节点 · PHP 8.1.12 · 完整源码 ZIP 1.31 MB
下载完整源码 ZIP 源码包大小:1.31 MB 安装教程 作者主页 免费开源 免费下载 ↓
COMMUNITY DEPLOYMENTS

已经跑起来的木漏茶室

从源码下载中心下载、完成安装并回传验证的站外站点。每个站点只计 1 次部署下载量;已记录站点会实时读取名称、版本、Logo 与在线状态,本机、内网和证书异常站点无法完成回传。

实时检测
3 个站点已部署

已展示全部 3 个站点。

admin/comments.php 6.1 KB · 发布包 v6.25.230
下载
<?php
/**
 * 后台 · 评论管理
 */
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    check_csrf();
    $act = input('act');
    $comment = DB::one('SELECT * FROM ' . DB::table('comments') . ' WHERE id = ?', [(int) input('id')]);
    if ($act === 'approve') {
        if ($comment) {
            DB::update('comments', ['status' => 1], 'id = ?', [(int) $comment['id']]);
            notification_insert((int) $comment['user_id'], 0, 'system', (int) $comment['id'], '你的评论已审核通过', page_url('post', ['id' => (int) $comment['post_id']]) . '#comment-' . (int) $comment['id']);
            audit_log('comment_approve', '评论 #' . (int) $comment['id']);
            flash('评论已审核通过');
        } else { flash('评论不存在', 'err'); }
        redirect(admin_url('comments', ['status' => 'pending']));
    }
    if ($act === 'reject') {
        if ($comment) {
            DB::update('comments', ['status' => 0], 'id = ?', [(int) $comment['id']]);
            notification_insert((int) $comment['user_id'], 0, 'system', (int) $comment['id'], '你的评论未通过审核:' . mb_substr((string) input('reason', '不符合社区规范'), 0, 80), page_url('post', ['id' => (int) $comment['post_id']]));
            audit_log('comment_reject', '评论 #' . (int) $comment['id']);
            flash('评论已驳回');
        } else { flash('评论不存在', 'err'); }
        redirect(admin_url('comments', ['status' => 'pending']));
    }
    if ($act === 'delete') {
        if ($comment && is_superadmin(user_by_id((int) $comment['user_id'])) && !is_superadmin(current_user())) {
            flash('超级管理员的评论不能由管理员删除', 'err');
        } elseif ($comment) {
            DB::delete('comments', 'id = ?', [(int) $comment['id']]);
            flash('评论已删除');
        }
    }
    redirect(admin_url('comments', ['status' => input('status') === 'pending' ? 'pending' : 'all']));
}

$q = trim((string) input('q', ''));
$statusFilter = input('status') === 'pending' ? 'pending' : 'all';
$where = ['1'];
$params = [];
if ($statusFilter === 'pending') { $where[] = 'c.status = 2'; }
if ($q !== '') {
    $where[] = 'c.content LIKE ?';
    $params[] = '%' . $q . '%';
}
$pendingTotal = (int) DB::val('SELECT COUNT(*) FROM ' . DB::table('comments') . ' WHERE status = 2', [], 0);
$whereSql = implode(' AND ', $where);
$total = (int) DB::val('SELECT COUNT(*) FROM ' . DB::table('comments') . ' c WHERE ' . $whereSql, $params, 0);
$pager = paginate($total, 25);
$rows = DB::all('SELECT c.*, u.nickname, u.username, u.avatar, u.role, p.title AS post_title FROM ' . DB::table('comments') . ' c
                 LEFT JOIN ' . DB::table('users') . ' u ON u.id = c.user_id
                 LEFT JOIN ' . DB::table('posts') . ' p ON p.id = c.post_id
                 WHERE ' . $whereSql . ' ORDER BY c.id DESC LIMIT ' . $pager['limit'] . ' OFFSET ' . $pager['offset'], $params);
?>
<div class="admin-head">
  <div><h1>评论管理</h1><p>共 <?= $total ?> 条 <?= $statusFilter === 'pending' ? '待审核评论' : '评论' ?> · <a class="link-btn" href="<?= e(admin_url('comments', ['status' => 'pending'])) ?>">待审核 <?= $pendingTotal ?></a> · <a class="link-btn" href="<?= e(admin_url('comments', ['status' => 'all'])) ?>">全部</a></p></div>
  <form method="get" class="admin-search">
    <input type="hidden" name="page" value="admin"><input type="hidden" name="s" value="comments">
    <input type="search" name="q" value="<?= e($q) ?>" placeholder="搜索评论内容">
    <button class="btn-mini" type="submit">搜索</button>
  </form>
</div>

<section class="panel">
  <div class="admin-table">
    <div class="at-head"><span>评论内容</span><span>作者</span><span>所在帖子</span><span>时间</span><span>操作</span></div>
    <?php foreach ($rows as $c): ?>
      <div class="at-row">
        <div class="at-main"><p class="at-text"><?= nl2br(e(mb_substr($c['content'], 0, 140))) ?></p></div>
        <div class="at-user small">
          <?= avatar_html($c, 'at-avatar') ?>
          <a href="<?= e(page_url('user', ['id' => $c['user_id']])) ?>"><?= e(display_name($c)) ?></a>
        </div>
        <a class="link-btn" href="<?= e(page_url('post', ['id' => $c['post_id']])) ?>#comments"><?= e(mb_substr((string) $c['post_title'], 0, 24)) ?></a>
        <span class="muted"><?= e(time_ago($c['created_at'])) ?> · <?= (int) ($c['status'] ?? 1) === 2 ? '<b>待审核</b>' : ((int) ($c['status'] ?? 1) === 0 ? '已驳回' : '已发布') ?></span>
        <div class="comment-admin-ops">
        <?php if ((int) ($c['status'] ?? 1) === 2): ?>
          <form method="post" class="inline-form">
            <?= csrf_field() ?><input type="hidden" name="act" value="approve"><input type="hidden" name="id" value="<?= (int) $c['id'] ?>"><input type="hidden" name="status" value="pending">
            <button class="btn-mini" type="submit">通过</button>
          </form>
          <form method="post" class="inline-form post-review-reject">
            <?= csrf_field() ?><input type="hidden" name="act" value="reject"><input type="hidden" name="id" value="<?= (int) $c['id'] ?>"><input type="hidden" name="status" value="pending">
            <input type="text" name="reason" placeholder="驳回理由" maxlength="80">
            <button class="btn-mini danger" type="submit">驳回</button>
          </form>
        <?php endif; ?>
        <?php if (!is_superadmin($c) || is_superadmin(current_user())): ?>
        <form method="post" class="inline-form" data-confirm="删除这条评论?">
          <?= csrf_field() ?><input type="hidden" name="act" value="delete"><input type="hidden" name="id" value="<?= (int) $c['id'] ?>"><input type="hidden" name="status" value="<?= e($statusFilter) ?>">
          <button class="link-btn danger" type="submit">删除</button>
        </form>
        <?php else: ?>
          <span class="muted">超管评论 · 不可操作</span>
        <?php endif; ?>
        </div>
      </div>
    <?php endforeach; ?>
    <?php if (!$rows): ?><?php empty_state('没有评论'); ?><?php endif; ?>
  </div>
  <?= pager_html($pager, 'admin', array_filter(['s' => 'comments', 'q' => $q !== '' ? $q : null, 'status' => $statusFilter === 'pending' ? 'pending' : null])) ?>
</section>
主题