News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

$context['list_users_online']

Started by Owdy, January 26, 2005, 07:20:29 PM

Previous topic - Next topic

Owdy

';

// 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?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Jerry

#1
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


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Kirby

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() ,'

Jerry

Can you use SSI functions in your templates?

* Jerry investigates a bit more


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Kirby


Jerry

#5
That doesn't seem like it would work very well. SSI.php uses sessions, and so do the forums... sounds like they would conflict.


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

[Unknown]

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]

Jerry



- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Owdy

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 , ....
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

Use the array output method!!

-[Unknown]

Owdy

#10
HOw? Still PHP n00b here ;) I have tryed lots of stuff, but nothing works :(
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

$who = ssi_whosOnline('array');
print_r($who);

-[Unknown]

Owdy

';

if ($context['user']['is_logged'])

{

require_once('/www/blaat/public_html/foorumi/SSI.php');


$users = ssi_whosOnline('array');
print_r($users);
}
echo '
??
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Kirby


Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Kirby

require_once('/www/blaat/public_html/foorumi/SSI.php'); <-- is that correct?

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Kirby

have you tried:
require_once('../../SSI.php');
or
require_once('SSI.php');

Owdy

#18
Thanks, but it isint that. That path works with my other ssi things in that same theme.  ;)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Kirby

thats kinda wierd... must be a problem with what unknown posted

Advertisement: