';
// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
echo '
', $txt[140], ':<br />', implode(', ', $context['list_users_online']);
This works only in board index. How can a make it work in index.template.php?
Another choise would be how to pull list of only users from SSI.php?
It seems like it is hard coded into /Sources/BoardIndex.template.php
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}log_online AS lo
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);
$context['users_online'] = array();
$context['list_users_online'] = array();
$context['online_groups'] = array();
$context['num_guests'] = 0;
$context['num_users_hidden'] = 0;
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
{
$context['num_guests']++;
continue;
}
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
$context['users_online'][$row['logTime'] . $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,
'hidden' => empty($row['showOnline']),
);
$context['list_users_online'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
if (!isset($context['online_groups'][$row['ID_GROUP']]))
$context['online_groups'][$row['ID_GROUP']] = array(
'id' => $row['ID_GROUP'],
'name' => $row['groupName'],
'color' => $row['onlineColor']
);
}
else
$context['num_users_hidden']++;
}
mysql_free_result($result);
krsort($context['users_online']);
krsort($context['list_users_online']);
ksort($context['online_groups']);
$context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
// Track most online statistics?
if (!empty($modSettings['trackStats']))
{
// Determine the most users online - both all time and per day.
$total_users = $context['num_guests'] + count($context['users_online']) + $context['num_users_hidden'];
if (!isset($modSettings['mostOnline']) || $total_users >= $modSettings['mostOnline'])
updateSettings(array('mostOnline' => $total_users, 'mostDate' => time()));
$date = strftime('%Y%m%d', forum_time(false));
// One or more stats are not up-to-date?
if (!isset($modSettings['mostOnlineUpdated']) || $modSettings['mostOnlineUpdated'] != $date)
{
$request = db_query("
SELECT mostOn
FROM {$db_prefix}log_activity
WHERE date = $date", __FILE__, __LINE__);
// The log_activity hasn't got an entry for today?
if (mysql_num_rows($request) == 0)
{
db_query("
INSERT IGNORE INTO {$db_prefix}log_activity
(date, mostOn)
VALUES ($date, $total_users)", __FILE__, __LINE__);
updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));
}
// There's an entry in log_activity on today...
else
{
list ($modSettings['mostOnlineToday']) = mysql_fetch_row($request);
if ($total_users > $modSettings['mostOnlineToday'])
trackStats(array('mostOn' => $total_users));
updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => max($total_users, $modSettings['mostOnlineToday'])));
}
mysql_free_result($request);
}
// Highest number of users online today?
elseif ($total_users > $modSettings['mostOnlineToday'])
{
trackStats(array('mostOn' => $total_users));
updateSettings(array('mostOnlineUpdated' => $date, 'mostOnlineToday' => $total_users));
}
}
not sure if that would help you at all :-X
QuoteAnother choise would be how to pull list of only users from SSI.php?
SSI.php has an ssi_whosOnline() function so you could just use:
', ssi_whosOnline() ,'
Can you use SSI functions in your templates?
/me investigates a bit more
yup...
just include SSI.php
That doesn't seem like it would work very well. SSI.php uses sessions, and so do the forums... sounds like they would conflict.
Quote from: Jerry on January 27, 2005, 12:30:52 AM
That doesn't seem like it would work very well. SSI.php uses sessions, and so do the forums... sounds like they would conflict.
But it's been designed so you cna use SSI.php in your templates, so this is not a problem.
-[Unknown]
oh alright, thanks :)
I could use SSI (and have been using it alot in my theme), yes. But like i sayd, i'd like to show only Users, not guests in that list. How do i do that with ssi?
Like this: Users logged in: Jerry, Owdy , ....
Use the array output method!!
-[Unknown]
HOw? Still PHP n00b here ;) I have tryed lots of stuff, but nothing works :(
$who = ssi_whosOnline('array');
print_r($who);
-[Unknown]
';
if ($context['user']['is_logged'])
{
require_once('/www/blaat/public_html/foorumi/SSI.php');
$users = ssi_whosOnline('array');
print_r($users);
}
echo '
??
that should work..
Nope.
require_once('/www/blaat/public_html/foorumi/SSI.php'); <-- is that correct?
yes
have you tried:
require_once('../../SSI.php');
or
require_once('SSI.php');
Thanks, but it isint that. That path works with my other ssi things in that same theme. ;)
thats kinda wierd... must be a problem with what unknown posted
By not working, what do you mean? It displays nothing?
-[Unknown]
Prints:Array ( [users] => Array ( [2034634566628192606Admin] => Array ( [id] => 1 [username] => Admin [name] => ‹Oz› [group] => 1 [href] => http://foorumi.hoitajat.net/index.php?action=profile;u=1 [link] => ‹Oz› [hidden] => [is_last] => )
etc.
Yes, which shows you the information is available. See, you can use $users['users']... and output it with a foreach. Come on, Owdy, I know you know that much PHP.
-[Unknown]
Thanks for beliving me, but i dont. Itryed something like this and it isnt working:';
if ($context['user']['is_logged'])
{
require_once('/www/asiakkaat/public_html/foorumi/SSI.php');
$array = ssi_whosOnline();
foreach ($array as $users)
{
echo '
', $users['users'], '
}
echo '
';
if ($context['user']['is_logged'])
{
require_once('/www/asiakkaat/public_html/foorumi/SSI.php');
$array = ssi_whosOnline('array');
foreach ($array['users'] as $users)
{
echo '
', $users['link'];
}
}
echo '
-[Unknown]
Parse error. This cant be this hard. :(
Typo. See above.
-[Unknown]
PEEEERRRRRRRRFECTTT!!!! :D Thanks! :D
Ok, it missed commas between names. I use this code from SSI.php to show them, but it shows it also after last person. What is wrong in that code?
';
if ($context['user']['is_logged'])
{
require_once('/www/asiakkaat/public_html/foorumi/SSI.php');
$array = ssi_whosOnline('array');
foreach ($array['users'] as $users)
{
echo '
', $users['link'], ', ';
}
}
echo '
And sorry beeing perfectionist about this :D
';
if ($context['user']['is_logged'])
{
require_once('/www/asiakkaat/public_html/foorumi/SSI.php');
$array = ssi_whosOnline('array');
$newarray = array();
foreach ($array['users'] as $user)
$newarray[] = $user['link'];
echo implode(', ', $newarray);
}
echo '
-[Unknown]
Perfect. Thanks again!