Simple Portal

Customization => Custom Coding => Topic started by: darkon on January 12, 2009, 12:14:12 AM

Title: Block for "online today" Mod?
Post by: darkon on January 12, 2009, 12:14:12 AM
In my board i have the "online today" mod installed, to show what users where online this day. (it can be found here: http://custom.simplemachines.org/mods/index.php?mod=217 )

Has anyone built a block to display the information in the portal?


Title: Re: Block for "online today" Mod?
Post by: darkon on January 16, 2009, 03:46:21 AM
 :'( No one?
Title: Re: Block for "online today" Mod?
Post by: Nabil on January 16, 2009, 10:01:05 AM
look in the www.yourdomain.xx/ssi_examples.php  do you see
the information on who's online today ? , if yes take that function and write it in a php block
Title: Re: Block for "online today" Mod?
Post by: darkon on January 17, 2009, 10:01:04 AM
No it doesn
Title: Re: Block for "online today" Mod?
Post by: [SiNaN] on February 03, 2009, 06:26:17 AM
For SMF 1.x:

global $db_prefix, $user_info, $modSettings, $context;

// Load the users online today.
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);

$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;

$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
WHERE mem.lastLogin >= $midnight
LIMIT 20", __FILE__, __LINE__);

$context['num_hidden_users_online_today'] = 0;
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();

while ($row = mysql_fetch_assoc($result))
{
if (empty($row['showOnline']))
{
$context['num_hidden_users_online_today'] = $context['num_hidden_users_online_today'] + 1;
if (!$user_info['is_admin']) continue;
}

$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];

$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = ' title="' . $lastLogin . '"';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';

$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}

$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);

$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);

krsort($context['users_online_today']);
krsort($context['list_users_online_today']);

$context['num_users_online_today'] = count($context['users_online_today']);

if (!empty($context['users_online_today']))
{
echo '
Users Online Today: ', $context['num_users_online_today'], '
<ul>';

foreach ($context['list_users_online_today'] as $user)
echo '
<li>', $user, '</li>';

echo '
</ul>';
}
else
echo 'No users logged in today.';


For SMF 2.x:

global $sourcedir, $context;

// Get the user online today list.
require_once($sourcedir . '/Subs-MembersOnlineToday.php');
$membersOnlineTodayOptions = array(
'sort' => 'login_time',
'reverse_sort' => true,
'period' => 'current_day',
'canview' => 'everyone',
);
$context += getMembersOnlineTodayStats($membersOnlineTodayOptions);

if (!empty($context['users_online_today']))
{
echo '
Users Online Today: ', $context['num_users_online_today'], '
<ul class="normallist">';

foreach ($context['list_users_online_today'] as $user)
echo '
<li>', $user, '</li>';

echo '
</ul>';
}
else
echo 'No users logged in today.';


You can modify the look as you wish.
Title: Re: Block for "online today" Mod?
Post by: fl4pj4ck on February 27, 2009, 10:07:06 PM
you can always use this one, it shows avatars and names within the specified time period: http://www.tinyportal.net/index.php/topic,27231.0.html
I requested it some time ago, it works with sp as well as with tp
EhPortal 1.39.8 © 2024, WebDev