SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Adnan on August 12, 2014, 07:47:13 AM

Title: Customize Whose Online
Post by: Adnan on August 12, 2014, 07:47:13 AM
so i use simple portal at my web (server forum),i want to use whosonline block at footer so i did that it look like,http://i.imgur.com/evIaRgj.png
i wanted to do like this
http://i.imgur.com/Cd7oxJE.png
please help me,its a request ya to all......
Title: Re: Customize Whose Online
Post by: Adnan on August 15, 2014, 01:33:34 AM
any one?
Title: Re: Customize Whose Online
Post by: phantomm on August 15, 2014, 03:52:59 AM
Here is little modified code from this topic: http://simpleportal.net/index.php?topic=9269.0

You can use this and it will (or should ::)) look like you showed on screenshot:
Code: [Select]
/*
Block: Who's Online with Avatar
Author: Blue @ Simple Portal.net
Version: 1.4gold
*/

/* SETUP HERE */
$mode = '3'; // 1 = SimplePortal Block with Avatars | 2 = Facebook like Block | 3 = SMF Forum like Block
// 4 = Online Today -> SimplePortal Block like | 5 = Online Today -> SMF Forum like Block
// 6 = SimplePortal Block with Avatar PLUS Online Today SMF Forum like

$namebellowavatar = true; // If you want to show username bellow avatar (ONLY IN MODE 2)
$scrollbar = true; // Show scrollbar
$scrollheight = '70px'; // Fixed Height before scrollbar appears (ONLY WORKS IF $scrollbar IS TRUE)
$width = '35px'; // Avatar Width
$height = '35px'; // Avatar Height
$default_avatar = 'URL HERE'; //URL To the default avatar

$show_guests = true; // Show guests count
$show_spiders = false; // Show spiders count
$show_hidden = true; // Show hidden count
$show_users = true; // Show users count
$show_visible_today = true; // Show visible users of today (ONLY IN MODE 4 AND 5)
$show_hidden_today = true; // Show hidden users of today (ONLY IN MODE 4 AND 5)
$text['OnlineToday'] = 'Users Online Today'; // Translate it to your language (ONLY IN MODE 6)

$show_guests_users = false; // Show Guests and Users combined (SUM of the two)
$fake_online = 1; //Increase Guest number by multiplying for the value of fake_online

/**********************************************************************************/

// CODE FROM NOW ON! STOP HERE!
global $smcFunc, $scripturl, $sourcedir, $modSettings, $txt, $settings, $context;


$members_result = $smcFunc['db_query']('', '
SELECT l.id_member, m.member_name, m.show_online, m.avatar, g.online_color, g.id_group, g.group_name
FROM {db_prefix}log_online AS l
LEFT JOIN {db_prefix}members AS m ON (m.id_member = l.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN m.id_group = 0 THEN m.id_post_group ELSE m.id_group END)
WHERE l.id_member > 0'
);
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{

      global $memberContext;
      loadMemberData($row_members['id_member']);
      loadMemberContext($row_members['id_member']);


   $members[] = array(
  'id' => $row_members['id_member'],
  'username' => $row_members['member_name'],
  'profile' => '<a style="color: ' . $row_members['online_color'] . ';" title="' . $row_members['group_name'] . '" href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['member_name'] . '</a>',
  'link' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
  'avatar' => $row_members['avatar'] == '' ? $memberContext[$row_members['id_member']]['avatar']['href'] : (stristr($row_members['avatar'], 'http://') ? $row_members['avatar'] : $modSettings['avatar_url'] . '/' . $row_members['avatar']),
  'hidden' => empty($row_members['show_online'])
   );
}
$smcFunc['db_free_result']($members_result);

$stats = ssi_whosOnline('array');

// Output here we go!

if ($mode == '1') {

if ($show_guests_users) {
$number = $stats['num_guests'] + $stats['num_users_online'];
$combined = $number * $fake_online;
echo sp_embed_image('dot'), ' Online: '. $combined  .'<br />';
} else {
if ($show_guests)
echo sp_embed_image('dot'), ' ', $txt['guests'], ': '. $stats['num_guests'] * $fake_online .'<br />';
}

if ($show_hidden)
echo sp_embed_image('dot'), ' ', $txt['hidden'] . ': ' . $stats['num_users_hidden'] .'<br />';

if ($show_spiders && allowedTo('admin_forum'))
echo sp_embed_image('dot'), ' ', $txt['spiders'] . ': ' . $stats['num_spiders'] .'<br />';

echo sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>' : '', ':
<br /><div ' . ($scrollbar ? 'style="overflow: auto; height: ' . $scrollheight . ';">' : '>');

foreach ($members as $member) {
if (!empty($member['avatar'])){
echo '<img style="border: 1px solid silver; padding: 1px; margin-bottom:2px;" src="' . $member['avatar'] . '" width="' . $width . '" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" /> ' . $member['profile'] . '<br />';
} else {
echo '<img style="border: 1px solid silver; padding: 1px; margin-bottom:2px;" src="' . $default_avatar .'" width="' . $width . '" alt="" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" /> ' . $member['profile'] . '<br />';
}
}
echo '</div>';

} elseif ($mode == '2') {

if (!$namebellowavatar)
echo '<div>';

foreach ($members as $member) {

if ($namebellowavatar)
echo '<div style="float: left;">';

echo '<a href="' . $member['link'] . '">';

if (!empty($member['avatar'])){
echo '<img style="border: 1px solid silver; padding: 1px; margin-top:1px;margin-left:1px;margin-bottom:1px;" src="' . $member['avatar'] . '" width="' . $width . '" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" />';
} else {
echo '<img style="border: 1px solid silver; padding: 1px;  margin-top:1px;margin-left:1px;margin-bottom:1px;" src="' . $default_avatar .'" width="' . $width . '" alt="" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" />';
}

echo '</a>' . ($namebellowavatar ? '<br /><span style="text-align: center;">' . $member['profile'] . '</span></div>' : '');
}

if (!$namebellowavatar)
echo '</div>';

echo '<div ' . ($namebellowavatar ? 'style="clear: left;">' : '>') . '<hr />';

if ($show_guests_users) {
$number = $stats['num_guests'] + $stats['num_users_online'];
$combined = $number * $fake_online;
echo sp_embed_image('dot');

if (allowedTo('who_view') && !empty($modSettings['who_enabled']))
echo '<a href="' . $scripturl . '?action=who">';

echo ' Online: ';

if (allowedTo('who_view') && !empty($modSettings['who_enabled']))
echo '</a>';

echo $combined;

} else {
if ($show_guests)
echo sp_embed_image('dot'), ' ', $txt['guests'], ': '. $stats['num_guests'] * $fake_online .'&nbsp;|&nbsp;';

if ($show_users)
echo sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', 'Users', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>:&nbsp;' . $stats['num_users_online'] : '';
}

if ($show_hidden)
echo '<br />' . sp_embed_image('dot'), ' ', $txt['hidden'] . ': ' . $stats['num_users_hidden'];

if ($show_spiders && allowedTo('admin_forum'))
echo '&nbsp;|&nbsp;' . sp_embed_image('dot'), ' ', $txt['spiders'] . ': ' . $stats['num_spiders'];

echo '</div>';

} elseif ($mode == '3') {
echo '<div>';

echo '<a style="font-size:1.1em;" href="' . $scripturl . '?action=who">';

if ($show_guests_users) {
$number = $stats['num_guests'] + $stats['num_users_online'];
$combined = $number * $fake_online;
echo $combined  .' Online';
} else {
if ($show_guests)
echo $stats['num_guests'] * $fake_online . ' ' . $txt['guests'] . ', ';

if ($show_users)
echo $stats['num_users_online'] . ' ' . $txt['users'];
}
if ($show_hidden)
echo ' (' . $stats['num_users_hidden'] . ' ' . $txt['hidden'] . ')';

if ($show_spiders && allowedTo('admin_forum'))
echo ' (' . $stats['num_spiders'] . ' ' . $txt['spiders'] . ')';

echo '</a><br />';

foreach ($members as $member) {
if ($stats['num_users_online'] == '1')
echo '<a href="' . $member['link'] . '">' . $member['profile'] . '</a> ';
else
echo '<a href="' . $member['link'] . '">' . $member['profile'] . '</a>, ';
}

echo '</div>';


} elseif ($mode == '4') {

echo '<div ' . ($scrollbar ? 'style="overflow: auto; height: ' . $scrollheight . ';">' : '>');

$context += getUsersOnlineTodayStats();

echo sp_embed_image('dot'), ' ', $txt['uot_total'], ': ', $context['num_users_online_today'], '<br />';

if ($show_visible_today)
echo sp_embed_image('dot'), ' ', $txt['uot_visible'], ': ', $context['num_users_online_today'] - $context['num_users_hidden_today'] .'<br />';

if ($show_hidden_today)
echo sp_embed_image('dot'), ' ', $txt['uot_hidden'], ': ', $context['num_users_hidden_today'] .'<br />';


echo sp_embed_image('dot') . ' ' . $txt['users'] . ':<br />

<ul class="sp_list"><li class="sp_list_indent">';

echo sp_embed_image('user') . ' ' . implode('</li><li class="sp_list_indent">' . sp_embed_image('user') . ' ' , $context['list_users_online_today']);

echo '</ul></div>';

} elseif ($mode == '5') {

$context += getUsersOnlineTodayStats();

echo '<span style="font-size:1.1em;">' . $context['num_users_online_today'], ' ' , $txt['uot_total'] , ' ' , $txt['users'] . '</span>';

if ($show_visible_today OR $show_hidden_today)
echo ' (';

if ($show_visible_today)
echo $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_users_hidden_today']);

if ($show_visible_today AND $show_hidden_today)
echo ', ';

if ($show_hidden_today)
echo $txt['uot_hidden'], ': ', $context['num_users_hidden_today'];

if ($show_visible_today OR $show_hidden_today)
echo ')';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && $context['viewing_allowed'])
{
echo
'<br />', implode(', ', $context['list_users_online_today']);
}

} else {

if ($show_guests_users) {
$number = $stats['num_guests'] + $stats['num_users_online'];
$combined = $number * $fake_online;
echo sp_embed_image('dot'), ' Online: '. $combined  .'<br />';
} else {
if ($show_guests)
echo sp_embed_image('dot'), ' ', $txt['guests'], ': '. $stats['num_guests'] * $fake_online .'<br />';
}

if ($show_hidden)
echo sp_embed_image('dot'), ' ', $txt['hidden'] . ': ' . $stats['num_users_hidden'] .'<br />';

if ($show_spiders && allowedTo('admin_forum'))
echo sp_embed_image('dot'), ' ', $txt['spiders'] . ': ' . $stats['num_spiders'] .'<br />';

echo sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>' : '', ':
<br /><div ' . ($scrollbar ? 'style="overflow: auto; height: ' . $scrollheight . ';">' : '>');

foreach ($members as $member) {
if (!empty($member['avatar'])){
echo '<img style="border: 1px solid silver; padding: 1px; margin-bottom:2px;" src="' . $member['avatar'] . '" width="' . $width . '" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" /> ' . $member['profile'] . '<br />';
} else {
echo '<img style="border: 1px solid silver; padding: 1px; margin-bottom:2px;" src="' . $default_avatar .'" width="' . $width . '" alt="" height="' . $height . '" align="middle" title="' . $member['username'] . '" alt="' . $member['username'] . '" /> ' . $member['profile'] . '<br />';
}
}
echo '</div><hr />';

// Online Today

$context += getUsersOnlineTodayStats();

echo sp_embed_image('dot'), ' ', $text['OnlineToday'], ': ', $context['num_users_online_today'];

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && $context['viewing_allowed'])
{
echo
'<br />', implode(', ', $context['list_users_online_today']);
}
}
?>
Title: Re: Customize Whose Online
Post by: Adnan on August 18, 2014, 10:32:55 AM
i have to make custom php block?
Title: Re: Customize Whose Online
Post by: andy on August 18, 2014, 11:13:30 AM
Yes, just copy and paste the code and do a few simple 'mode' settings at the top.
SimplePortal 2.3.8 © 2008-2024, SimplePortal