global $smcFunc, $scripturl, $modSettings, $settings, $txt;
// Style of avatar
$style = 'width:36px; height:36px; border-radius:100%; object-fit:cover; box-shadow:1px 2px 4px rgba(0,0,0,0.4); display:block;';
// Number of top posters displayed
$topPoster = 6;
// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.real_name, mem.posts, mem.avatar, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE mem.is_activated = 1
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);
$users = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// Correctly initialize the avatar variable
$avatar = '<span class="default-avatar" style="' . $style . '" data-adi-id="' . htmlspecialchars($row['id_member']) . '"></span>';
if (!empty($row['avatar'])) {
$avatar = '<img src="' . (stristr($row['avatar'], 'http://') || stristr($row['avatar'], 'https://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar'])) . '" alt="" style="' . $style . '" title="' . htmlspecialchars($row['real_name']) . '" />';
} elseif ($row['id_attach'] > 0) {
$avatar = '<img src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" style="' . $style . '" title="' . htmlspecialchars($row['real_name']) . '" />';
}
$users[$row['id_member']] = array(
'id' => $row['id_member'],
'name' => htmlspecialchars($row['real_name']),
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="https://poetryartonline.com/' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . htmlspecialchars($row['real_name']) . '</a>',
'posts' => $row['posts'],
'avatar' => $avatar
);
}
$smcFunc['db_free_result']($request);
// Output our array of users with avatar, posts, and name
echo '<ul class="recent_topics" style="margin: 0; padding: 0; list-style: none;">';
foreach ($users as $user) {
echo '<li style="display: flex; align-items: center; margin-bottom: 10px;">'
. '<span class="tpavatar" style="margin-right: 10px;">' . $user['avatar'] . '</span>'
. '<div>'
. '<strong>' . $user['link'] . '</strong><br>'
. '<span>' . $user['posts'] . ' ' . htmlspecialchars($txt['posts']) . '</span>'
. '</div>'
. '</li>';
}
echo '</ul>';
Page created in 0.041 seconds with 17 queries.