PHPackages                             lcoy/cipher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lcoy/cipher

ActiveFlarum-extension

lcoy/cipher
===========

Password-gated \[protected\] BBCode with real-time unlock for Flarum.

v1.0.4(today)01↑2900%MITPHP

Since Aug 8Pushed todayCompare

[ Source](https://github.com/Lcoy2004/Flarum-cipher)[ Packagist](https://packagist.org/packages/lcoy/cipher)[ RSS](/packages/lcoy-cipher/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

lcoy/cipher
===========

[](#lcoycipher)

为 Flarum 提供密码保护的 `[protected]` BBCode 标签，支持多种可见条件与实时解锁体验。

- 密码保护内容，未解锁时仅显示锁定卡片（带流动光效）
- 可选可见条件：点赞、回复、关注作者、关注本帖、帖子赞数、定时可见
- 解锁弹窗内实时显示每个条件的满足状态（✓ 已满足 / ✗ 未满足）
- 实时解锁：时间条件到点自动公开；点赞数达标通过 WebSocket（flarum-pusher）实时刷新
- 可视化编辑弹窗：发帖工具栏 🔒 按钮内提供勾选式条件、快捷时间下拉，无需手写 BBCode
- 作者、管理员与版主无需密码，直接查看原始内容

仓库地址
----

[](#仓库地址)

- Gitee：
- GitHub：
- Packagist：

安装
--

[](#安装)

```
composer require lcoy/cipher
```

启用扩展后，在后台「扩展」页进入 Cipher 设置，可按需配置。

### 前端构建（可选）

[](#前端构建可选)

如果扩展自带的 `js/dist` 不适用，可从源码重新构建前端：

```
cd js
npm install
npm run build
```

基本用法
----

[](#基本用法)

在帖子内容中使用 `[protected]` 标签包裹需要隐藏的内容：

```
[protected password="123456"]只有输入密码才能看到的内容[/protected]

```

- `password`：解锁密码（必填，留空则使用管理员的默认密码）
- `title`：锁定卡片上显示的标题（可选）

未解锁的访客看到的是一张锁定卡片，点击「解锁」输入密码后即可查看内容。

### 使用编辑器按钮

[](#使用编辑器按钮)

发帖/回复的工具栏有 🔒 按钮，打开可视化编辑弹窗：

1. 选中要隐藏的文字，点击 🔒
2. 输入密码（留空则使用管理员默认密码）
3. 勾选需要的可见条件：点赞、回复、关注作者、关注本帖
4. 可选设置「帖子赞数达到 N」与「指定时间后可见」（带 1h / 6h / 12h / 1d / 3d 快捷时间下拉）
5. 点击「确定」即可插入或更新 `[protected]` 标签

再次点击已存在的 🔒 标签可进入编辑模式，原条件会自动回填。

可见条件
----

[](#可见条件)

除密码外，还可以为内容附加额外条件。条件之间为「并且」关系，全部满足才能解锁。

条件示例说明点赞`like="1"`必须给本帖点过赞回复`reply="1"`必须在本讨论中回复过（隐藏/删除的回复不计）关注作者`follow="1"`必须关注帖子作者（依赖 `flarum-tags` 或具备 `user_followers` 表的扩展）关注本帖`followDiscussion="1"`必须关注本讨论（依赖 `flarum-subscriptions`，订阅状态为 `follow`）赞数达标`minlikes="10"`本帖总赞数达到 N 个定时可见`time="2026-08-09 12:00"`到指定时间后自动公开，无需密码相对时间`time="+2d"` / `time="12h"` / `time="30m"` / `time="45s"`相对发帖时间的偏移，保存时归一化为绝对时间> 说明：`follow`（关注作者）和 `followDiscussion`（关注本帖）是两种不同的关注行为。前者跟随作者，后者订阅当前讨论。两者可同时启用。

组合示例：

```
[protected password="123456" title="福利内容" like="1" reply="1" follow="1" followDiscussion="1" minlikes="3" time="2026-08-09 12:00"]内容[/protected]

```

该内容要求：当前时间已到 2026-08-09 12:00、已点赞、已回复、已关注作者、已关注本帖、帖子满 3 个赞，再输入密码才可查看。

### 条件状态实时显示

[](#条件状态实时显示)

锁定卡片与解锁弹窗都会列出每条已配置的条件：

- ✓（绿色）表示当前已满足
- ✗（红色）表示尚未满足

### 实时更新

[](#实时更新)

- **minlikes（赞数）**：启用 `flarum-pusher` 后，其他人点赞导致赞数达标时，正在浏览的访客会实时看到 ✗ 变为 ✓，无需刷新
- **time（定时）**：到点后锁定卡片自动变为公开内容，无需刷新或输入密码

实时更新由后端 `PushPostUpdate` 监听 `PostWasLiked` / `PostWasUnliked` 事件，并通过 Pusher 在 `public` 频道广播 `cipherPostUpdate` 事件；前端订阅该事件后调用 `GET /api/cipher/status` 拉取最新条件状态。`time` 条件则在前端按 `data-cipher-target` 调度一次性定时器，到点自动重渲染。

> 实时通道按需启用：未安装 `flarum-pusher` 时不会触发任何推送，扩展仍可正常工作；同时监听器对失败推送做了静默处理，绝不会因 Pusher 故障而打断原帖请求。

权限说明
----

[](#权限说明)

- 帖子**作者**、**管理员**、拥有 `discussion.moderate` 权限的**版主**：直接看到原始内容，不显示锁定卡片
- **访客**是否允许解锁，由后台设置控制（默认允许）

管理员设置
-----

[](#管理员设置)

后台「Cipher」设置页：

设置说明默认允许访客解锁关闭后，只有登录用户才能解锁受保护内容开启默认密码作者将密码留空时使用的密码`cipher`> 默认密码仅保存在服务端，绝不会下发到前端页面。

安全说明
----

[](#安全说明)

- 密码在保存帖子时即被单向哈希（bcrypt），数据库与前端均不出现明文
- 锁定卡片的渲染结果不会包含密码哈希
- 解锁接口按「帖子 + IP」限流：10 分钟内最多 10 次失败尝试

常见问题
----

[](#常见问题)

**问：忘记密码了怎么办？**作者或管理员可直接查看内容；管理员可在后台修改默认密码供重新尝试。

**问：设置了时间条件，密码还有用吗？**有用。到点前需要密码（且密码正确才解锁）；到点后内容自动公开，不再需要密码。

**问：`like`、`reply`、`follow`、`followDiscussion` 条件在什么时机生效？**解锁接口每次都会重新校验，执行对应操作（点赞 / 回复 / 关注作者 / 关注本帖）后无需重新输入密码逻辑，但需要重新提交解锁；配合 WebSocket 时，条件状态会实时刷新。

**问：为什么我满足所有条件却仍提示未满足？**请确认是在**当前账号**下操作：`like` / `reply` / `follow` / `followDiscussion` 判断的是当前登录用户自己的行为；`minlikes` 判断的是帖子总赞数。访客账号无法满足点赞 / 回复 / 关注类条件。

**问：`follow` 和 `followDiscussion` 有什么区别？**`follow` 关注的是**帖子作者**（依赖 `user_followers` 表，由 `flarum-tags` 等扩展提供）；`followDiscussion` 关注的是**当前讨论**（依赖 `flarum-subscriptions`，订阅状态为 `follow`）。两者独立判定，可同时启用。

**问：`followDiscussion` 启用了但提示未满足？**请到帖子右上角的订阅菜单确认已选择「关注」（follow）状态。「忽略」或默认不订阅都不会算作已关注。

许可证
---

[](#许可证)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e1134dc7905b11fdc31e107629a6b8d8da7dc649e7654bed210d9f988a317c8?d=identicon)[lcoy](/maintainers/lcoy)

---

Top Contributors

[![Lcoy2004](https://avatars.githubusercontent.com/u/62994301?v=4)](https://github.com/Lcoy2004 "Lcoy2004 (21 commits)")

---

Tags

passwordbbcodeflarumprotectedgateunlock

### Embed Badge

![Health badge](/badges/lcoy-cipher/health.svg)

```
[![Health](https://phpackages.com/badges/lcoy-cipher/health.svg)](https://phpackages.com/packages/lcoy-cipher)
```

###  Alternatives

[flarum-lang/russian

Russian language pack for Flarum.

13129.1k](/packages/flarum-lang-russian)[flarum-lang/french

French language pack to localize the Flarum forum software plus its official and third-party extensions.

1941.0k](/packages/flarum-lang-french)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

190198.3k20](/packages/fof-upload)[fof/discussion-language

Specify the language a discussion is written in &amp; sort by language

1035.6k7](/packages/fof-discussion-language)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
