木漏茶室源码下载中心
整站 PHP 源码:可浏览文件、复制路径、下载单文件或打包 ZIP。
发布版本 v6.25.232
升级后自动生成独立源码包,下载中心只发送这份冻结包
已排除 config.php / 用户数据 / 上传文件 / 升级备份
COMMUNITY DEPLOYMENTS
已经跑起来的木漏茶室
从源码下载中心下载、完成安装并回传验证的站外站点。每个站点只计 1 次部署下载量;已记录站点会实时读取名称、版本、Logo 与在线状态,本机、内网和证书异常站点无法完成回传。
实时检测
2
个站点已部署
木
木漏茶室
mlcs.xnn.lol · v6.25.232
访问 ↗
2026.11.21
在线
木
木漏茶室
mlcs.nbnb.mom · v6.25.232
访问 ↗
2026.11.20
在线
已展示全部 2 个站点。
inc/profile_visits.php
3.8 KB · 发布包 v6.25.232
<?php
/**
* 个人主页访客统计与来访记录。
*/
/** 记录一次登录用户访问他人主页;每次访问累加访客量,来访用户按账号去重。 */
function profile_visit_record($profileUserId, $visitorId)
{
$profileUserId = (int) $profileUserId;
$visitorId = (int) $visitorId;
if ($profileUserId <= 0 || $visitorId <= 0 || $profileUserId === $visitorId) {
return false;
}
try {
$row = DB::one('SELECT id, visits FROM ' . DB::table('profile_visits') . ' WHERE profile_user_id = ? AND visitor_id = ?', [$profileUserId, $visitorId]);
$now = now();
if ($row) {
DB::run('UPDATE ' . DB::table('profile_visits') . ' SET visits = visits + 1, last_at = ? WHERE id = ?', [$now, (int) $row['id']]);
} else {
DB::insert('profile_visits', [
'profile_user_id' => $profileUserId,
'visitor_id' => $visitorId,
'visits' => 1,
'first_at' => $now,
'last_at' => $now,
]);
}
DB::run('UPDATE ' . DB::table('users') . ' SET profile_visitor_count = profile_visitor_count + 1 WHERE id = ?', [$profileUserId]);
return true;
} catch (Exception $e) {
return false;
}
}
function profile_visitor_count_value($uid)
{
return (int) DB::val('SELECT profile_visitor_count FROM ' . DB::table('users') . ' WHERE id = ?', [(int) $uid], 0);
}
/** 最近来访用户,按账号去重;只返回正常状态账号。 */
function profile_visitor_list($uid, $limit = 100)
{
$limit = max(1, min(200, (int) $limit));
return DB::all('SELECT u.*, v.visits, v.first_at, v.last_at
FROM ' . DB::table('profile_visits') . ' v
INNER JOIN ' . DB::table('users') . ' u ON u.id = v.visitor_id
WHERE v.profile_user_id = ? AND u.status = 1
ORDER BY v.last_at DESC, v.id DESC
LIMIT ' . $limit, [(int) $uid]);
}
function profile_visitor_stat_html($user, $isSelf, $count)
{
$count = max(0, (int) $count);
if ($isSelf) {
return '<button type="button" class="pc-visitor-stat" data-visitor-toggle aria-expanded="false" aria-controls="pcVisitorPanel">'
. '<span class="pc-visitor-dot" aria-hidden="true"></span><span class="pc-visitor-label">来访记录</span><b>' . $count . '</b></button>';
}
return '<span class="pc-visitor-stat is-public" title="访客量"><span class="pc-visitor-dot" aria-hidden="true"></span><span class="pc-visitor-label">访客量</span><b>' . $count . '</b></span>';
}
function profile_visitor_panel_html($uid, $total, $isSelf)
{
if (!$isSelf) {
return '';
}
$rows = profile_visitor_list($uid, 100);
$html = '<section class="panel pc-visitors-panel" id="pcVisitorPanel" hidden>'
. '<div class="panel-head row"><h2 class="section-title">来访记录</h2><span class="muted">总访客量 <b>' . max(0, (int) $total) . '</b></span></div>';
if (!$rows) {
$html .= '<div class="pc-visitors-empty">还没有登录用户来访。别的茶客访问你的主页后,会记录在这里。</div>';
} else {
$html .= '<div class="pc-visitor-grid">';
foreach ($rows as $visitor) {
$html .= '<a class="pc-visitor-item" href="' . e(page_url('user', ['id' => (int) $visitor['id']])) . '">'
. '<span class="pc-visitor-avatar">' . avatar_html($visitor, 'pc-visitor-img') . '</span>'
. '<span class="pc-visitor-name">' . e(display_name($visitor)) . verify_badge($visitor) . '</span>'
. '<span class="pc-visitor-meta">来访 ' . (int) ($visitor['visits'] ?? 1) . ' 次</span>'
. '</a>';
}
$html .= '</div>';
}
$html .= '</section>';
return $html;
}