木漏茶室源码下载中心
整站 PHP 源码:可浏览文件、复制路径、下载单文件或打包 ZIP。
发布版本 v6.25.230
升级后自动生成独立源码包,下载中心只发送这份冻结包
已排除 config.php / 用户数据 / 上传文件 / 升级备份
COMMUNITY DEPLOYMENTS
已经跑起来的木漏茶室
从源码下载中心下载、完成安装并回传验证的站外站点。每个站点只计 1 次部署下载量;已记录站点会实时读取名称、版本、Logo 与在线状态,本机、内网和证书异常站点无法完成回传。
实时检测
3
个站点已部署
木
木漏茶室
mlcs.xnn.lol · v6.25.230
访问 ↗
2026.11.21
在线
木
木漏茶室
mlcs.nbnb.mom · v6.25.225
访问 ↗
2026.11.20
在线
木
木漏茶室
csrc.954377.xyz · v6.25.211
访问 ↗
2026.11.20
离线
已展示全部 3 个站点。
admin/carousel.php
7.9 KB · 发布包 v6.25.230
<?php
/**
* 后台 · 首页轮播
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
check_csrf();
$act = input('act');
$id = (int) input('id');
if ($act === 'interval') {
$sec = (int) input('interval', 5);
$sec = max(1, min(60, $sec));
set_setting('carousel_interval', (string) $sec);
flash('轮播时长已设为 ' . $sec . ' 秒');
redirect(admin_url('carousel'));
}
if ($act === 'save') {
$title = mb_substr(trim((string) ($_POST['title'] ?? '')), 0, 60);
$link = trim((string) ($_POST['link'] ?? ''));
$url = trim((string) ($_POST['image_url'] ?? ''));
$sort = (int) input('sort', 0);
$image = '';
try {
if (!empty($_FILES['image']['name'])) {
$stored = upload_store('image', 'carousel', ['image' => true, 'max' => 1000 * 1024 * 1024]);
$image = $stored['path'];
} elseif ($url !== '') {
if (!preg_match('#^https?://#i', $url)) {
throw new Exception('网络图片需以 http:// 或 https:// 开头');
}
$image = $url;
}
if ($id > 0) {
$data = ['title' => $title, 'link' => $link, 'sort' => $sort];
if ($image !== '') {
$data['image'] = $image;
}
DB::update('carousel', $data, 'id = ?', [$id]);
flash('轮播已更新');
} else {
if ($image === '') {
throw new Exception('请上传图片或填写网络图片链接');
}
DB::insert('carousel', [
'title' => $title,
'image' => $image,
'link' => $link,
'sort' => $sort,
'status' => 1,
'created_at' => now(),
]);
flash('轮播已添加');
}
} catch (Exception $e) {
flash('保存失败:' . $e->getMessage(), 'err');
}
redirect(admin_url('carousel'));
}
if ($act === 'delete') {
$row = DB::one('SELECT * FROM ' . DB::table('carousel') . ' WHERE id = ?', [$id]);
if ($row) {
if (strpos($row['image'], 'uploads/') === 0) {
delete_upload($row['image']);
}
DB::delete('carousel', 'id = ?', [$id]);
flash('轮播已删除');
}
redirect(admin_url('carousel'));
}
if ($act === 'toggle') {
$row = DB::one('SELECT * FROM ' . DB::table('carousel') . ' WHERE id = ?', [$id]);
if ($row) {
DB::run('UPDATE ' . DB::table('carousel') . ' SET status = ? WHERE id = ?', [(int) $row['status'] === 1 ? 0 : 1, $id]);
}
redirect(admin_url('carousel'));
}
}
$slides = DB::all('SELECT * FROM ' . DB::table('carousel') . ' ORDER BY sort ASC, id ASC');
$editing = (int) input('edit') > 0 ? DB::one('SELECT * FROM ' . DB::table('carousel') . ' WHERE id = ?', [(int) input('edit')]) : null;
?>
<div class="admin-head">
<div><h1>首页轮播</h1><p>共 <?= count($slides) ?> 张 · 支持本地上传与网络链接</p></div>
</div>
<section class="panel carousel-duration">
<form method="post">
<?= csrf_field() ?>
<input type="hidden" name="act" value="interval">
<label>轮播自动切换时长</label>
<input type="number" name="interval" min="1" max="60" step="1"
value="<?= (int) setting('carousel_interval', 5) ?>">
<span>秒</span>
<button class="btn-primary" type="submit">保存时长</button>
<small>首页有多张轮播图时,每隔这么多秒自动切换一次。</small>
</form>
</section>
<section class="admin-two">
<div class="panel">
<div class="carousel-admin">
<?php foreach ($slides as $s): ?>
<figure class="carousel-admin-cell">
<img src="<?= e(upload_url($s['image'])) ?>" alt="">
<figcaption>
<strong><?= e($s['title'] ?: '无标题') ?></strong>
<span><?= (int) $s['status'] === 1 ? '显示中' : '已隐藏' ?> · 排序 <?= (int) $s['sort'] ?></span>
<div class="at-ops">
<a class="link-btn" href="<?= e(admin_url('carousel', ['edit' => $s['id']])) ?>">编辑</a>
<form method="post" class="inline-form"><?= csrf_field() ?><input type="hidden" name="act" value="toggle"><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><button class="link-btn" type="submit"><?= (int) $s['status'] === 1 ? '隐藏' : '显示' ?></button></form>
<form method="post" class="inline-form" data-confirm="删除这张轮播图?"><?= csrf_field() ?><input type="hidden" name="act" value="delete"><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><button class="link-btn danger" type="submit">删除</button></form>
</div>
</figcaption>
</figure>
<?php endforeach; ?>
<?php if (!$slides): ?><?php empty_state('还没有轮播图', '在右侧添加第一张'); ?><?php endif; ?>
</div>
</div>
<div class="panel">
<h2 class="section-title"><?= $editing ? '编辑轮播' : '新增轮播' ?></h2>
<form method="post" enctype="multipart/form-data" class="form-card">
<?= csrf_field() ?>
<input type="hidden" name="act" value="save">
<input type="hidden" name="id" value="<?= $editing ? (int) $editing['id'] : 0 ?>">
<label>标题(展示在图片下方,可留空)</label>
<input type="text" name="title" maxlength="60" value="<?= e($editing['title'] ?? '') ?>">
<label>本地图片(建议 16:9,最大 1000MB,原图保存不压缩)</label>
<label class="upload-drop" data-carousel-drop>
<input type="file" name="image" accept="image/*" data-carousel-file>
<span class="upload-drop-plus" aria-hidden="true">+</span>
<strong class="upload-drop-title" data-default="拖拽图片到此处,或点击选择文件">拖拽图片到此处,或点击选择文件</strong>
<small class="upload-drop-hint">建议 16:9,最大 1000MB,原图保存不压缩</small>
</label>
<label>或网络图片链接</label>
<input type="url" name="image_url" placeholder="https://">
<label>点击跳转链接(可留空)</label>
<input type="url" name="link" value="<?= e($editing['link'] ?? '') ?>" placeholder="https://">
<label>排序</label>
<input type="number" name="sort" value="<?= (int) ($editing['sort'] ?? 0) ?>">
<button class="btn-primary" type="submit">保存</button>
<?php if ($editing): ?><a class="btn-ghost" href="<?= e(admin_url('carousel')) ?>">取消</a><?php endif; ?>
</form>
</div>
</section>
<script>
(function () {
document.querySelectorAll('[data-carousel-drop]').forEach(function (zone) {
var input = zone.querySelector('[data-carousel-file]');
var title = zone.querySelector('.upload-drop-title');
if (!input || !title) return;
var def = title.getAttribute('data-default') || title.textContent;
function showName() {
var file = input.files && input.files[0];
title.textContent = file ? file.name : def;
}
['dragenter', 'dragover'].forEach(function (evt) {
zone.addEventListener(evt, function (e) {
e.preventDefault();
e.stopPropagation();
zone.classList.add('is-drop');
});
});
['dragleave', 'dragend'].forEach(function (evt) {
zone.addEventListener(evt, function (e) {
e.preventDefault();
zone.classList.remove('is-drop');
});
});
zone.addEventListener('drop', function (e) {
e.preventDefault();
e.stopPropagation();
zone.classList.remove('is-drop');
var files = e.dataTransfer && e.dataTransfer.files;
if (!files || !files.length) return;
try {
input.files = files;
} catch (err) {
return;
}
showName();
});
input.addEventListener('change', showName);
});
})();
</script>