木漏茶室源码下载中心
整站 PHP 源码:可浏览文件、复制路径、下载单文件或打包 ZIP。
发布版本 v6.25.231
升级后自动生成独立源码包,下载中心只发送这份冻结包
已排除 config.php / 用户数据 / 上传文件 / 升级备份
COMMUNITY DEPLOYMENTS
已经跑起来的木漏茶室
从源码下载中心下载、完成安装并回传验证的站外站点。每个站点只计 1 次部署下载量;已记录站点会实时读取名称、版本、Logo 与在线状态,本机、内网和证书异常站点无法完成回传。
实时检测
3
个站点已部署
木
木漏茶室
mlcs.xnn.lol · v6.25.231
访问 ↗
2026.11.21
在线
木
木漏茶室PHP初始化安装向导
mlcs.nbnb.mom · v6.25.225
访问 ↗
2026.11.20
在线
木
木漏茶室
csrc.954377.xyz · v6.25.211
访问 ↗
2026.11.20
离线
已展示全部 3 个站点。
admin/extensions.php
8.8 KB · 发布包 v6.25.231
<?php
/**
* 后台 · 扩展管理(内置扩展开关)
*/
require_once APP_ROOT . '/inc/plugin_install.php';
$admin = current_user();
if (!is_superadmin($admin)) {
flash('扩展管理已移至扩展中心,仅超级管理员可见可用', 'err');
redirect(page_url('extensions'));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
check_csrf();
if (input('act') === 'toggle') {
$id = (int) input('id');
$row = DB::one('SELECT * FROM ' . DB::table('extensions') . ' WHERE id = ?', [$id]);
if ($row) {
$enabled = input('enabled') === '1' ? 1 : 0;
DB::run('UPDATE ' . DB::table('extensions') . ' SET status = ? WHERE id = ?', [$enabled, $id]);
flash($enabled ? '扩展已启用' : '扩展已停用');
}
}
if (input('act') === 'delete_site') {
$id = (int) input('id');
$row = DB::one('SELECT * FROM ' . DB::table('extensions') . ' WHERE id = ?', [$id]);
if (!$row || (int) ($row['is_builtin'] ?? 1) === 1) {
flash('内置扩展不能删除,可停用', 'err');
redirect(admin_url('extensions'));
}
$icon = (string) ($row['icon'] ?? '');
if ($icon !== '' && !preg_match('#^https?://#i', $icon)) {
delete_upload($icon);
}
DB::delete('extensions', 'id = ?', [$id]);
flash('网站扩展已删除');
redirect(admin_url('extensions'));
}
if (input('act') === 'edit_name') {
$id = (int) input('id');
$row = DB::one('SELECT * FROM ' . DB::table('extensions') . ' WHERE id = ?', [$id]);
if (!$row) {
flash('扩展不存在', 'err');
redirect(admin_url('extensions'));
}
$name = trim((string) input('name'));
if ($name === '') {
flash('扩展名称不能为空', 'err');
redirect(admin_url('extensions'));
}
if (mb_strlen($name) > 60) {
flash('名称最多 60 字', 'err');
redirect(admin_url('extensions'));
}
$icon = (string) ($row['icon'] ?? '');
$url = trim((string) input('url'));
if ($url !== '' && !preg_match('#^https?://#i', $url)) {
flash('网站地址需以 http:// 或 https:// 开头', 'err');
redirect(admin_url('extensions'));
}
if (input('icon_clear') === '1') {
$icon = '';
} elseif (!empty($_FILES['icon_file']['name'])) {
try {
$stored = upload_store('icon_file', 'extensions', ['image' => true, 'max' => 2 * 1024 * 1024]);
$icon = $stored['path'];
} catch (Exception $e) {
flash('图标上传失败:' . $e->getMessage(), 'err');
redirect(admin_url('extensions'));
}
} else {
$iconUrl = trim((string) input('icon_url'));
if ($iconUrl !== '') {
if (!preg_match('#^https?://#i', $iconUrl)) {
flash('网络图标链接需以 http:// 或 https:// 开头', 'err');
redirect(admin_url('extensions'));
}
$icon = $iconUrl;
}
}
DB::run('UPDATE ' . DB::table('extensions') . ' SET name = ?, icon = ?, url = ? WHERE id = ?',
[$name, $icon, $url, $id]);
flash('扩展名称、图标与网址已保存');
redirect(admin_url('extensions'));
}
if (input('act') === 'sort') {
$sorts = (array) ($_POST['sort'] ?? []);
foreach ($sorts as $eid => $val) {
DB::run('UPDATE ' . DB::table('extensions') . ' SET sort = ? WHERE id = ?', [(int) $val, (int) $eid]);
}
flash('扩展排序已保存');
redirect(admin_url('extensions'));
}
if (input('act') === 'restore') {
DB::run('UPDATE ' . DB::table('extensions') . ' SET status = 1');
flash('所有内置扩展已恢复启用');
}
redirect(admin_url('extensions'));
}
$rows = DB::all('SELECT * FROM ' . DB::table('extensions') . ' WHERE owner_id = 0 ORDER BY sort ASC, id ASC');
$pluginCount = DB::count('plugins', 'status = 1');
?>
<div class="admin-head">
<div><h1>扩展管理</h1><p><?= count($rows) ?> 个内置扩展 · <?= $pluginCount ?> 个插件启用中</p></div>
<div class="admin-quick">
<form method="post" data-confirm="恢复全部内置扩展?">
<?= csrf_field() ?><input type="hidden" name="act" value="restore">
<button class="btn-mini ghost" type="submit">全部恢复</button>
</form>
</div>
</div>
<section class="panel">
<div class="panel-head">
<h2>名称、图标与网址</h2>
<p>修改后会同步更新前台「扩展中心」卡片。填写网站地址后,前台点击会进入带「返回扩展中心」的中转页;留空则使用内置页面。</p>
</div>
<div class="ext-edit-list">
<?php foreach ($rows as $r): ?>
<?php $editIcon = extension_icon_src((string) ($r['icon'] ?? '')); ?>
<form method="post" enctype="multipart/form-data" class="ext-edit-row">
<?= csrf_field() ?>
<input type="hidden" name="act" value="edit_name">
<input type="hidden" name="id" value="<?= (int) $r['id'] ?>">
<div class="ext-edit-slug">
<span class="ext-edit-icon"><?php if ($editIcon !== ''): ?><img src="<?= e($editIcon) ?>" alt=""><?php else: ?>❄<?php endif; ?></span>
<strong><?= e($r['name']) ?></strong><i><?= e($r['slug']) ?></i>
</div>
<div class="ext-edit-fields">
<div class="field ext-field"><label>名称</label><input type="text" name="name" maxlength="60" required value="<?= e($r['name']) ?>"></div>
<div class="field ext-field"><label>上传本地图标</label><input type="file" name="icon_file" accept="image/*"></div>
<div class="field ext-field ext-url">
<label>网站地址</label>
<input type="url" name="url" maxlength="255" value="<?= e($r['url'] ?? '') ?>" placeholder="https://... 留空则使用内置页面">
</div>
<div class="field ext-field ext-url">
<label>网络图标链接</label>
<div class="ext-url-line">
<input type="url" name="icon_url" maxlength="255" value="<?= preg_match('#^https?://#i', (string) ($r['icon'] ?? '')) ? e($r['icon']) : '' ?>" placeholder="https://... 留空则保留当前图标">
<label class="inline-check ext-icon-clear"><input type="checkbox" name="icon_clear" value="1"> 清除图标</label>
</div>
</div>
</div>
<div style="display:flex;flex-direction:column;gap:6px">
<button class="btn-mini ext-save" type="submit">保存</button>
<?php if ((int) ($r['is_builtin'] ?? 1) !== 1): ?>
<button class="btn-mini danger" type="submit" name="act" value="delete_site" formnovalidate onclick="return confirm('删除该网站扩展?');">删除</button>
<?php endif; ?>
</div>
</form>
<?php endforeach; ?>
</div>
</section>
<section class="panel">
<h2 class="section-title">排序(数字越小越靠前)</h2>
<form method="post" class="ext-sort-form">
<?= csrf_field() ?><input type="hidden" name="act" value="sort">
<div class="ext-sort-list">
<?php foreach ($rows as $r): ?>
<label class="ext-sort-row">
<span><?= e($r['name']) ?> <i><?= e($r['slug']) ?></i></span>
<input type="number" name="sort[<?= (int) $r['id'] ?>]" value="<?= (int) $r['sort'] ?>" step="1">
</label>
<?php endforeach; ?>
</div>
<button class="btn-primary" type="submit">保存排序</button>
</form>
</section>
<section class="panel">
<div class="admin-table ext-admin-table">
<div class="at-head"><span>扩展</span><span>标识</span><span>状态</span></div>
<?php foreach ($rows as $r): ?>
<div class="at-row">
<div class="at-main"><strong><?= e($r['name']) ?></strong></div>
<span class="muted"><?= e($r['slug']) ?></span>
<form method="post" class="inline-form">
<?= csrf_field() ?><input type="hidden" name="act" value="toggle"><input type="hidden" name="id" value="<?= (int) $r['id'] ?>">
<label class="toggle-switch" title="点击切换启用 / 停用"><input type="checkbox" name="enabled" value="1" aria-label="启用或停用扩展" <?= (int) $r['status'] === 1 ? 'checked' : '' ?> onchange="this.form.submit()"><span class="toggle-track"><span class="toggle-thumb"></span></span></label>
</form>
</div>
<?php endforeach; ?>
</div>
</section>
<section class="panel">
<h2 class="section-title">说明</h2>
<p class="muted">停用扩展后,前台扩展中心不再显示入口,但已有分享链接仍可直接访问。内置扩展不可删除,可随时恢复。网站型扩展可在上方修改网址或删除。</p>
</section>