用户认证

用户认证

站长认证申请审核系统,联动勋章展示

插件 v1.3.2 Twelve 用户 积分兑换 5 金币

xnx_verify 用户认证

功能

  • 站长认证(webmaster),申请 → 审核 → 颁发 / 驳回完整流程

  • 前台申请页:站长填网站名 / 域名 / 简介 / 身份证明;

  • 申请前置条件(AND 关系):注册天数、发帖数、积分、用户组(多选 OR)

  • 申请扣除积分(deduct_credits_type / value),提交时扣除,无论通过 / 驳回不返还

  • 冷却期:驳回后 N 天内不可重新申请(按 reject_time 计算),前台展示剩余天数

  • 有效期:站长可配置有效天数(0=永久),每日 cron 自动撤销过期认证 + 通知 + 回收勋章

  • 后台管理:待审列表分页 + 通过 / 驳回(必填原因)+ 已认证列表(可按类型筛选)+ 撤销 + 手动颁发

  • 联动 xnx_medal 勋章系统:通过 medal_condition_* hook 提供 condition_type='verified_webmaster' / 'verified_developer' 勋章条件

  • 通知:通过 / 驳回 / 撤销 / 过期均通过 notify_create 通知用户

  • 联动 DiscoverService:可注册到发现页

  • 缓存:CacheHelper::registerKeys('xnx_verify', ...) + 静态缓存避免列表页 N+1

  • 多语言(zh-cn / zh-tw / en-us)

文件结构

plugin/xnx_verify/
├── conf.json
├── install.php / uninstall.php        # 建 xnx_verify_apply / xnx_verify_user 表
├── setting.php                        # 后台管理 + 设置
├── icon.png
├── model/
│   └── VerifyService.php              # 核心服务(申请 / 审核 / 查询 / 撤销 / 勋章联动)
├── route/
│   └── verify.php                     # 前台路由:apply / submit / status
├── view/htm/
│   ├── verify_apply.htm               # 申请表单页
│   ├── verify_status.htm              # 我的认证状态页
│   ├── my_verify.htm                  # 个人中心入口
│   └── setting.htm                    # 后台管理页
├── static/js/verify.js
└── hook/
    ├── model_inc_file.php             # 自动加载 VerifyService
    ├── model_route_table_end.php      # 注册 verify 路由
    ├── index_route_case_end.php
    ├── admin_index_route_case_end.php
    ├── my_sidebar_nav_threads_before.htm  # 个人中心侧栏入口
    ├── my_action_before.php
    ├── model_cron_daily_end.php       # 每日 cron 调用 checkExpired()
    ├── medal_condition_check.php       # ↓ 提供给 xnx_medal 的勋章条件
    ├── medal_condition_progress.php
    ├── medal_condition_description.php
    ├── medal_condition_build_value.php
    ├── medal_condition_options.htm
    ├── medal_condition_inputs.htm
    ├── lang_zh_cn_bbs.php
    ├── lang_zh_tw_bbs.php
    └── lang_en_us_bbs.php

配置流程

  1. 后台「插件管理」安装并启用 xnx_verify

  2. 进入「插件设置」→「配置」→ 设置冷却天数、前置条件(注册天数 / 发帖数 / 积分 / 用户组)、申请扣分、有效期

  3. 测试:用户前台访问 /verify-apply → 通过前置检查后填写表单 → 提交后扣除积分(如配置)

  4. 后台「待审列表」→ 通过 / 驳回(必填原因)→ 用户收到通知;通过时自动颁发对应勋章(需 xnx_medal 已配置 condition_type='verified_webmaster' / 'verified_developer' 勋章)

  5. 后台「已认证列表」可撤销认证;手动颁发可绕过申请直接授予指定用户

  6. 按需在「发现页配置」开启插件入口到发现页

扩展说明

VerifyService 通过 hook/model_inc_file.php 自动加载,公开静态方法可被其他插件调用;同时通过 medal_condition_* hook 给 xnx_medal 提供勋章条件。

Service 类与方法签名

VerifyService::getInstance(): VerifyService        // 构造时注册缓存键

// ---- 配置 ----
VerifyService::getSettings(): array               // cooldown_days / require_* / deduct_credits_* / *_expire_days
VerifyService::saveSettings(array $settings): void
VerifyService::getDefaultExpireDays(string $type): int

// ---- 前置检查 ----
VerifyService::checkPrerequisites(int $uid): array  // ['ok'=>bool, 'items'=>[...]]

// ---- 申请 ----
VerifyService::createApply(int $uid, string $type, array $data): array
//   type: 'webmaster' | 'developer',data 为表单数据
//   内部:前置条件检查 → 已有认证检查 → 互斥(待审中不可再申请)→ 冷却期 → 扣分 → 写库
VerifyService::approveApply(int $apply_id, int $audit_uid): array   // 颁发认证 + 撤销其他类型 + 颁发勋章 + 通知
VerifyService::rejectApply(int $apply_id, int $audit_uid, string $reason): array  // reason 必填

// ---- 状态查询 ----
VerifyService::getUserVerifications(int $uid): array   // [type => verify_data],带静态缓存
VerifyService::isVerified(int $uid, string $type): bool   // 常用查询:用户是否拥有某类认证
VerifyService::getUserApplyList(int $uid): array       // 用户所有申请记录(按 id 倒序)
VerifyService::getCooldownRemaining(int $uid, string $type): int  // 0=可申请

// ---- 撤销与手动颁发 ----
VerifyService::revokeVerify(int $uid, string $type, string $reason = ''): array  // reason 非空时发通知
VerifyService::grantManual(int $uid, string $type, string $data_json = '', int $expireDays = 0): array  // 管理员手动颁发

// ---- 有效期 ----
VerifyService::checkExpired(): int    // 每日 cron 调用,撤销过期认证 + 回收勋章 + 通知,返回处理条数

// ---- 勋章联动(被 xnx_medal 调用 / 可被其他插件复用)----
VerifyService::grantMedalForVerify(int $uid, string $type): void   // 颁发 condition_type='verified_'.$type 的所有勋章
VerifyService::revokeMedalForVerify(int $uid, string $type): void  // 回收对应勋章

// ---- 后台查询 ----
VerifyService::getPendingApplies(int $page, int $pagesize): array  // 待审列表
VerifyService::getVerifiedList(int $page, int $pagesize, string $type = ''): array  // 已认证列表
VerifyService::getApply(int $id): array

数据表与触发时机

  • xnx_verify_apply:申请记录(uid+type+status 索引,status 0 待审 / 1 通过 / -1 驳回)

  • xnx_verify_user:用户认证状态(uid+type 联合主键,含 expire_time 0=永久)

  • 互斥规则:approveApplygrantManual 都会调用 revokeOtherTypeVerify() 撤销另一种认证(前者不发通知避免轰炸,后者发通知)

  • hook/model_cron_daily_end.php 每日 0 点触发 checkExpired(),需注意 hook 内 try/catch 包裹且不可 return,否则会绕过 cache_delete('cron_lock_2') 导致 cron 锁不释放

  • 勋章条件 hook(medal_condition_check.php 等 6 个)由 MedalService::checkCondition()default 分支前触发,可用变量 $uid / $condition_type / $condition_value / $result(引用),约定 $result = ['ok'=>bool, 'message'=>string, 'handled'=>true]

  • 缓存键通过 CacheHelper::registerKeys('xnx_verify', ...) 注册:user_verifications / apply_stats,写操作后通过 clearCache() 清理

版本 1.0.5 | 兼容 Xiuno 1.1+


截图 2
v1.3.2 2026-09-04
新增 user_nav_register.php 自注册
v1.3.1 2026-08-22
1.3.0

接入通知中心:新增红点数据源(待审核认证申请实时计数)。

提交申请通知升级为 plugin_notify_fire(new_pending 事件 300s 节流,旧核心回退 AdminNotifyService::audit 兼容)。

审核通过/拒绝后主动失效红点缓存,待办清零清节流键。

1.3.1

管理员通知配置整合到统一通知设置中心:设置页移除旧“管理员通知”区块(开关+邮箱输入),替换为跳转提示卡片。

upgrade.php 幂等迁移旧值到 plugin_notify_config,迁移后删除旧键;新装不再写入旧键。

三语清理 7 个旧键,新增 2 个迁移提示键。
v1.2.8 2026-08-18
优化 认证资料的显示
v1.2.7 2026-08-06
1. 去除开发者相关
2. 增加域名校验
v1.0.5 2026-08-03
作者信息
XiunoX 开发者,独立开发者 & 全栈工程师 DiscuzX 插件/模板、WordPress 主题/插件、XiunoX 框架二次开发、APP 与小程序自研项目。
开发者主页
44
应用
483
安装
2026-08
加入
应用详情
应用分类 插件
版本 v1.3.2
适用版本 1.1
开发者 Twelve
下载量 25
浏览 182
更新时间 2026-09-09
发布时间 2026-08-03
最新回复
查看全部
  • 暂无回复

查看全部评论 / 发表评论
完整评论功能在讨论帖中,点击前往