Skip to main content
Topic: Top authors (Read 708 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Top authors

 экрана от 2022-12-03 16-55-23.png

Code: [Select]
echo ‘<header class=»category_header»>Top authors</header>’;
global $scripturl, $modSettings, $settings, $txt;

// Height and width of avatar
$width = ’40px’;
$height = ‘100%’;
// Number of top posters displayed

$topPoster = 10;

$db = database();

// Find the latest poster.
$request = $db->query(», ‘
SELECT mem.id_member, mem.show_online, 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 show_online = 1 AND mem.is_activated = 1
ORDER BY posts DESC
LIMIT {int:limit}’,
array(‘limit’ => $topPoster)
);

$users = array();

while ($row = $db->fetch_assoc($request))
{
$users[] = array(
‘id’ => $row[‘id_member’],
‘name’ => $row[‘real_name’],
‘href’ => $scripturl . ‘?action=profile;u=’ . $row[‘id_member’],
‘link’ => ‘<a href=»‘ . $scripturl . ‘?action=profile;u=’ . $row[‘id_member’] . ‘»>’ . $row[‘real_name’] . ‘</a>’,
‘posts’ => $row[‘posts’],
‘show’ => $row[‘show_online’],
‘avatar’ => array(
‘image’ => empty($row[‘avatar’]) ? ($row[‘id_attach’] > 0 ? ‘src=»‘ . (empty($row[‘attachment_type’]) ? $scripturl . ‘?action=dlattach;attach=’ . $row[‘id_attach’] . ‘;type=avatar’ : $modSettings[‘custom_avatar_url’] . ‘/’ . $row[‘filename’]) . ‘» alt=»» width=»‘.$width.'» height=»‘.$height.'» title=»‘.$row[‘real_name’].'» />’ : ») : (stristr($row[‘avatar’], ‘http://’) ? ‘src=»‘ . $row[‘avatar’] . ‘» alt=»» width=»‘.$width.'» height=»‘.$height.'» title=»‘.$row[‘real_name’].'» />’ : ‘src=»‘ . $modSettings[‘avatar_url’] . ‘/’ . htmlspecialchars($row[‘avatar’]) . ‘» alt=»» width=»‘.$width.'» height=»‘.$height.'» title=»‘.$row[‘real_name’].'» />’),
),
);
}

$db->free_result($request);

// Output our array of users with avatar, posts, and name
echo ‘
<table width=100%><tr>’;

foreach ($users as $user)
{
echo ‘
<td>’,empty($user[‘avatar’][‘image’]) ? ‘<a href=»‘.$user[‘href’].'»><img src=»‘.$settings[‘tp_images_url’].’/TPguest.png» width=»‘.$width.'» height=»‘.$height.'» alt=»» title=»‘.$user[‘name’].'» /></a>’ : ‘<a href=»‘.$user[‘href’].'»><img ‘.$user[‘avatar’][‘image’].'</a>’;
echo ‘
<br><h5 style=»margin: 4px;»>’.$user[‘link’].'</h5><h5 style=»margin: 4px;»>’. $user[‘posts’] .’ ‘.$txt[‘posts’].'</h5></td>’;
}

echo ‘
</tr></table>’;