function current_user_can_view_private_profile(int $profileUserId): bool
{
$viewer = current_user();
if (!$viewer) {
return false;
}
if ((int)$viewer['id'] === $profileUserId) {
return true;
}
return (int)$viewer['class'] >= 3;
}
function get_public_user_profile(int $userId): ?array
{
if ($userId < 1) {
return null;
}
$mysqli = db();
$stmt = $mysqli->prepare("\n SELECT id, username, email, class, avatar, country, enabled, added, last_login, last_access, ip\n FROM users\n WHERE id = ?\n LIMIT 1\n ");
if (!$stmt) {
error_log('get_public_user_profile prepare failed: ' . $mysqli->error);
return null;
}
$stmt->bind_param('i', $userId);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
return $user ?: null;
}
function get_user_track_comment_count(int $userId): int
{
if ($userId < 1) {
return 0;
}
ensure_track_comments_table();
$mysqli = db();
$stmt = $mysqli->prepare("SELECT COUNT(*) AS total FROM comments WHERE user_id = ?");
if (!$stmt) {
error_log('get_user_track_comment_count prepare failed: ' . $mysqli->error);
return 0;
}
$stmt->bind_param('i', $userId);
$stmt->execute();
$row = $stmt->get_result()->fetch_assoc();
return (int)($row['total'] ?? 0);
}
function profile_initial(string $username): string
{
$username = trim($username);
if ($username === '') {
return '?';
}
if (function_exists('mb_substr')) {
return strtoupper((string)mb_substr($username, 0, 1, 'UTF-8'));
}
return strtoupper(substr($username, 0, 1));
}
function format_profile_datetime(?string $value): string
{
$value = trim((string)$value);
if ($value === '' || $value === '0000-00-00 00:00:00') {
return 'Never';
}
try {
return (new DateTimeImmutable($value))->format('l jS F Y g:i A');
} catch (Throwable $e) {
return $value;
}
}
Browse - theravenAU's Karaoke Kove
♫
89,277
Total Tracks
♚
15,332
Artists
☆
91
New Releases
◷
75
Added This Month
♫ Song Library
12 results