木漏茶室源码下载中心
整站 PHP 源码:可浏览文件、复制路径、下载单文件或打包 ZIP。
发布版本 v6.25.231
升级后自动生成独立源码包,下载中心只发送这份冻结包
已排除 config.php / 用户数据 / 上传文件 / 升级备份
COMMUNITY DEPLOYMENTS
已经跑起来的木漏茶室
从源码下载中心下载、完成安装并回传验证的站外站点。每个站点只计 1 次部署下载量;已记录站点会实时读取名称、版本、Logo 与在线状态,本机、内网和证书异常站点无法完成回传。
实时检测
2
个站点已部署
木
木漏茶室
mlcs.xnn.lol · v6.25.232
访问 ↗
2026.11.21
在线
木
木漏茶室
mlcs.nbnb.mom · v6.25.231
访问 ↗
2026.11.20
在线
已展示全部 2 个站点。
inc/holidays.php
8.4 KB · 发布包 v6.25.231
<?php
/**
* 节日倒计时:公历节日 + 农历节日 + 清明
*
* 只用于首页展示「下一个节日」和当天祝福,不依赖数据库与后台配置。
*/
function site_holiday_lunar_info()
{
static $info = [
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0,
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6,
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0,
];
return $info;
}
function site_holiday_lunar_leap_month($year)
{
$info = site_holiday_lunar_info();
$idx = (int) $year - 1900;
if ($idx < 0 || $idx >= count($info)) {
return 0;
}
return $info[$idx] & 0xf;
}
function site_holiday_lunar_month_days($year, $month, $leap = false)
{
$info = site_holiday_lunar_info();
$idx = (int) $year - 1900;
if ($idx < 0 || $idx >= count($info) || $month < 1 || $month > 12) {
return 0;
}
$days = ($info[$idx] & (0x10000 >> $month)) ? 30 : 29;
if ($leap) {
if (site_holiday_lunar_leap_month($year) !== $month) {
return 0;
}
$days = ($info[$idx] & 0x10000) ? 30 : 29;
}
return $days;
}
function site_holiday_lunar_year_days($year)
{
$total = 0;
for ($m = 1; $m <= 12; $m++) {
$total += site_holiday_lunar_month_days($year, $m);
}
$leap = site_holiday_lunar_leap_month($year);
if ($leap) {
$total += site_holiday_lunar_month_days($year, $leap, true);
}
return $total;
}
/**
* 农历日期转公历 Y-m-d。返回空字符串表示超出内置历表范围。
*/
function site_holiday_lunar_to_solar($year, $month, $day)
{
$info = site_holiday_lunar_info();
$idx = (int) $year - 1900;
if ($idx < 0 || $idx >= count($info) || $month < 1 || $month > 12 || $day < 1 || $day > 30) {
return '';
}
$offset = 0;
for ($y = 1900; $y < $year; $y++) {
$offset += site_holiday_lunar_year_days($y);
}
$leap = site_holiday_lunar_leap_month($year);
for ($m = 1; $m < $month; $m++) {
$offset += site_holiday_lunar_month_days($year, $m);
if ($leap === $m) {
$offset += site_holiday_lunar_month_days($year, $m, true);
}
}
$offset += $day - 1;
$base = new DateTimeImmutable('1900-01-31 00:00:00', new DateTimeZone(date_default_timezone_get()));
return $base->modify('+' . $offset . ' days')->format('Y-m-d');
}
/**
* 清明:21 世纪常用计算公式,仅用于节庆展示。
*/
function site_holiday_qingming_date($year)
{
if ($year < 2000 || $year > 2099) {
return '';
}
$y = $year - 2000;
$day = (int) floor($y * 0.2422 + 4.81) - (int) floor($y / 4);
if ($day < 3 || $day > 6) {
$day = 4;
}
return sprintf('%04d-04-%02d', $year, $day);
}
/**
* 返回当前年份起三年内的节日,按日期升序。
*/
function site_holiday_catalog($baseYear = null)
{
$baseYear = $baseYear ? (int) $baseYear : (int) date('Y');
$fixed = [
['元旦', 1, 1, '元旦快乐', '愿新的一年,茶香常伴,所愿皆成。'],
['劳动节', 5, 1, '劳动节快乐', '致敬每一份认真生活的心。'],
['国庆节', 10, 1, '国庆快乐', '愿山河锦绣,人间皆安。'],
];
$lunar = [
['春节', 1, 1, '新春快乐', '愿岁岁常欢愉,年年皆胜意。'],
['元宵节', 1, 15, '元宵快乐', '愿灯火可亲,人月两圆。'],
['端午节', 5, 5, '端午安康', '愿粽香盈室,顺遂平安。'],
['七夕', 7, 7, '七夕快乐', '愿有情人终成眷属。'],
['中秋节', 8, 15, '中秋快乐', '愿人长久,月常圆。'],
['重阳节', 9, 9, '重阳安康', '愿长辈康健,岁岁登高。'],
['腊八节', 12, 8, '腊八安康', '愿粥暖心头,万事“粥”全。'],
];
$list = [];
for ($year = $baseYear; $year <= $baseYear + 2; $year++) {
foreach ($fixed as $item) {
$date = sprintf('%04d-%02d-%02d', $year, $item[1], $item[2]);
$list[] = [
'key' => 'solar-' . $year . '-' . $item[1] . '-' . $item[2],
'name' => $item[0],
'date' => $date,
'greet' => $item[3],
'blessing' => $item[4],
'lunar' => false,
];
}
foreach ($lunar as $item) {
$date = site_holiday_lunar_to_solar($year, $item[1], $item[2]);
if ($date === '') {
continue;
}
$list[] = [
'key' => 'lunar-' . $year . '-' . $item[1] . '-' . $item[2],
'name' => $item[0],
'date' => $date,
'greet' => $item[3],
'blessing' => $item[4],
'lunar' => true,
];
}
$chuxiLunarYear = $year - 1;
$chuxiDay = site_holiday_lunar_month_days($chuxiLunarYear, 12);
$chuxi = site_holiday_lunar_to_solar($chuxiLunarYear, 12, $chuxiDay);
if ($chuxi !== '') {
$list[] = [
'key' => 'lunar-' . $chuxiLunarYear . '-chuxi',
'name' => '除夕',
'date' => $chuxi,
'greet' => '除夕快乐',
'blessing' => '愿旧岁皆安,新年可期。',
'lunar' => true,
];
}
$qingming = site_holiday_qingming_date($year);
if ($qingming !== '') {
$list[] = [
'key' => 'qingming-' . $year,
'name' => '清明节',
'date' => $qingming,
'greet' => '清明安康',
'blessing' => '愿思念有归处,春日常新。',
'lunar' => false,
];
}
}
usort($list, function ($a, $b) {
if ($a['date'] === $b['date']) {
return strcmp($a['key'], $b['key']);
}
return strcmp($a['date'], $b['date']);
});
return $list;
}
function site_holiday_today($now = null)
{
$today = date('Y-m-d', $now === null ? time() : (int) $now);
foreach (site_holiday_catalog((int) date('Y', $now === null ? time() : (int) $now)) as $item) {
if ($item['date'] === $today) {
return $item;
}
}
return null;
}
function site_holiday_next($now = null)
{
$ts = $now === null ? time() : (int) $now;
$today = date('Y-m-d', $ts);
foreach (site_holiday_catalog((int) date('Y', $ts)) as $item) {
if ($item['date'] > $today) {
return $item;
}
}
return null;
}
/**
* 返回首页倒计时所需状态:当天节日优先,否则返回下一个节日与目标时间。
*/
function site_holiday_status($now = null)
{
$ts = $now === null ? time() : (int) $now;
$todayItem = site_holiday_today($ts);
if ($todayItem) {
return [
'is_today' => true,
'holiday' => $todayItem,
'target' => 0,
'left' => 0,
];
}
$next = site_holiday_next($ts);
if (!$next) {
return null;
}
$target = strtotime($next['date'] . ' 00:00:00');
return [
'is_today' => false,
'holiday' => $next,
'target' => $target,
'left' => max(0, $target - $ts),
];
}