News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Online User's avatars rotation

Started by Fizzy, July 10, 2004, 03:39:46 AM

Previous topic - Next topic

Senkusha

Quote from: babylonking on August 12, 2004, 08:27:52 PM
QuoteSo do you want this instead of the 'top/bottom ssi function?' or is this another ssi function?

Just like the one in your web site left menu " 5 Recent Members "

QuoteWhat is it doing, and not doing?

only the hosted avatars is showing the uploaded avatars is not showing.

http://www.babylonking.net/include44.php



Okay, the simply add a LIMIT 5 to the end of the SELECT statement for the five most recent members. (My site lists ALL members since midnight).

I just realized that the uploaded avatars isn't working.  I'll see if I can find a solution, since that function is being called from anoother function.

Did that make any sense?
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

babylonking

Quote from: Senkusha on August 12, 2004, 09:09:36 PM
Quote from: babylonking on August 12, 2004, 08:27:52 PM
QuoteSo do you want this instead of the 'top/bottom ssi function?' or is this another ssi function?

Just like the one in your web site left menu " 5 Recent Members "

QuoteWhat is it doing, and not doing?

only the hosted avatars is showing the uploaded avatars is not showing.

http://www.babylonking.net/include44.php



Okay, the simply add a LIMIT 5 to the end of the SELECT statement for the five most recent members. (My site lists ALL members since midnight).

I just realized that the uploaded avatars isn't working.  I'll see if I can find a solution, since that function is being called from anoother function.

Did that make any sense?

Just take your time  Senkusha no rushing  ;)

Senkusha

Na, I should have something by the end of the day.  Remember, I'm using this same technology!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Vinoth

Thanx a lot, also some other members too need this feature.
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

Elisa

I have tried to install the mod, but it does not work! after that I have copied the code in the rows what I must make? Help!!!

Senkusha

Quote from: babylonking on August 12, 2004, 06:13:32 PM
Thanks Senkusha .........Two more thing please  :D

I want to Load the users online for the past 5 hours & the members name i want them to display  top/bottom like the sample below.

faridgorges
Posts: 0

Bazneta
Posts: 0

tobeya
Posts: 0


Do you still want the avatars to display?

Quote
Avatar
membername
Posts: 0

Avatar
membername
Posts: 0

btw, I got the uploaded avatars working!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

babylonking

QuoteDo you still want the avatars to display?

sure just like the one in your web site left menu.  :)

Quotebtw, I got the uploaded avatars working!

cool ........... can't wait to added  ;)

Senkusha

#47
Okay, here is the code.  As is, it will display a listing down the side of your board like this:

Quote
Avatar
member
Posts:  ##
Last On:  HH:MM

It will list only the five most recent members that have been since midnight.

I would recommend adding this code just after the ssi_WhosOnline () function (since this is a modified copy of that code).  You may call this code by placing this code in your main page:

If you want to change the number of hours the query looks, change the following line:

$midnight = ((date("U") - (date("H") * 3600)) - (date("i") * 60));

If you want to change the number of users listed change this line:

LIMIT 5", __FILE__, __LINE__);


If you want to change how this list is displayed (horizontal / vertical), then you'll need to change this line:

echo '<table align="left" border="0">';
foreach ($return['users'] as $user)
echo '<tr><td align="left" valign="bottom">' . $user['link'] . '</td></tr>' , !$user['is_last'] ? '' : '';
echo '</table>';

to this (note if you change the number to more than 5 members, you could have problems.):

echo '<table align="left" border="0"><tr><td valign="bottom">';
foreach ($return['users'] as $user)
echo $user['link'] , !$user['is_last'] ? '' : '';
echo '</td></tr></table>';


Quote
ssi_WhosRecent()

Find the section

// Just like whosOnline except it also logs the online presence.


right above it add:

// Shows a list of recent users:  YY Guests, ZZ Users and then a list...
function ssi_whosRecent($output_method = 'echo')
{
global $scripturl, $db_prefix, $txt, $modSettings;

$midnight = ((date("U") - (date("H") * 3600)) - (date("i") * 60));
// Load the users online for the past 24 hours.
$result = db_query("
SELECT
mem.ID_MEMBER, mem.realName, mem.memberName, mem.ID_GROUP, mem.showOnline, mem.avatar, mem.lastLogin, mem.posts,
mg.onlineColor
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))
WHERE mem.lastLogin >= '$midnight'
ORDER BY mem.realName
LIMIT 5", __FILE__, __LINE__);

$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;

while ($tmp = mysql_fetch_assoc($result))
{
if (!isset($tmp['realName']))
{
$return['guests']++;
continue;
}
elseif (empty($tmp['showOnline']))
{
$return['hidden']++;
continue;
}

$link = '<table border="0" align="left">';

// The user Avatar...
if ($tmp['avatar'] == '')
{
$AvatarReq = db_query ("SELECT * FROM {$db_prefix}attachments WHERE ID_MEMBER = '$tmp[ID_MEMBER]'", __FILE__, __LINE__);
$AvatarRes = mysql_fetch_assoc($AvatarReq);
if (mysql_num_rows ($AvatarReq) == 1)
$link .= '<img src="' . $scripturl . '?action=dlattach;id=' . $AvatarRes['ID_ATTACH'] . ';type=avatar" height="40">';
$link .= '
<tr>
<td valign="bottom">&nbsp;</td>
</tr>';
}
elseif (strtoupper(substr($tmp['avatar'],0,7)) == 'HTTP://')
$link .= '
<tr>
<td align="center" valign="bottom"><img src="' . $tmp['avatar'] . '" height="40"></td>
</tr>';
else
$link .= '
<tr>
<td align="center" valign="bottom"><img src="' . $modSettings['avatar_url'] . '/' . $tmp['avatar'] . '" height="40"></td>
</tr>';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link .= '
<tr>
<td align="left" valign="bottom" nowrap><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '</a></td>
</tr>';
else
$link .= '
<tr>
<td align="left" valign="bottom" nowrap><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '">' . $tmp['realName'] . '</a></td>
</tr>';
// Number of total posts
$link .= '<tr>
<td align="left" valign="bottom">Posts:&nbsp;&nbsp;' . $tmp['posts'] . '</td>
</tr>';
// Time the member last logged in
$link .= '<tr>
<td align="left" valign="bottom">Last On:&nbsp;&nbsp;' . date("H:i", $tmp['lastLogin']) . '</td>
</tr></table>';


$return['users'][] = array(
'id' => $tmp['ID_MEMBER'],
'username' => $tmp['memberName'],
'name' => $tmp['realName'],
'group' => $tmp['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'],
'link' => $link,
'is_last' => false
);
}
mysql_free_result($result);

$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];

if (!empty($return['users']))
$return['users'][count($return['users']) - 1]['is_last'] = true;

if ($output_method != 'echo')
return $return;

echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'], $return['hidden'] > 0 ? ' (' . $return['hidden'] . ' ' . $txt['hidden'] . ')' : '', '<br />
';

echo '<table align="left" border="0">';
foreach ($return['users'] as $user)
echo '<tr><td align="left" valign="bottom">' . $user['link'] . '</td></tr>' , !$user['is_last'] ? '' : '';
echo '</table>';
}


That should do it.
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

babylonking

Nice Senkusha it's working  :D


Thanks alot  :)

Elisa

I do not understand, excuse!  I modify alone the SSI.php file?  And the file of the template ones not?

babylonking

#50
How i make the "members name, posts & last on text" to appear beside each members avatars just like the one in your web site. :)

Sorry for bugging you Senkusha  ::)

Mysterio

Senkusha, I tried installing the 'Avatar Online' mod, but it brought back some errors:

QuoteNotice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 271
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 272
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 273
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 274
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 275
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 279

And here is what's on lines 271-275:

         
Quote'id' => $tmp['ID_MEMBER'],
         'username' => $tmp['memberName'],
         'name' => $tmp['realName'],
         'group' => $tmp['ID_GROUP'],

And 279:

Quoteif ($tmp['onlineColor'] != '')

How do I fix that?

Thanks.

Senkusha

#52
Quote from: babylonking on August 13, 2004, 12:58:49 PM
How i make the "members name, posts & last on text" to appear beside each members avatars just like the one in your web site. :)

Sorry for bugging you Senkusha  ::)

Try this code instead:


// Shows a list of recent users:  YY Guests, ZZ Users and then a list...
function ssi_whosRecent($output_method = 'echo')
{
global $scripturl, $db_prefix, $txt, $modSettings;

$midnight = ((date("U") - (date("H") * 3600)) - (date("i") * 60));
// Load the users online for the past 24 hours.
$result = db_query("
SELECT
mem.ID_MEMBER, mem.realName, mem.memberName, mem.ID_GROUP, mem.showOnline, mem.avatar, mem.lastLogin, mem.posts,
mg.onlineColor
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))
WHERE mem.lastLogin >= '$midnight'
ORDER BY mem.realName
LIMIT 5", __FILE__, __LINE__);

$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;

while ($tmp = mysql_fetch_assoc($result))
{
if (!isset($tmp['realName']))
{
$return['guests']++;
continue;
}
elseif (empty($tmp['showOnline']))
{
$return['hidden']++;
continue;
}

$link = '<tr><td><fieldset><table><tr>';

// The user Avatar...
if ($tmp['avatar'] == '')
{
$AvatarReq = mysql_query ("SELECT * FROM smf_attachments WHERE ID_MEMBER = '$tmp[ID_MEMBER]'") or die(mysql_error());
$AvatarRes = mysql_fetch_assoc($AvatarReq);
if (mysql_num_rows ($AvatarReq) == 1)
$link .= '<td><img src="' . $scripturl . '?action=dlattach;id=' . $AvatarRes['ID_ATTACH'] . ';type=avatar" height="40"></td><td><table>';
$link .= '
<td valign="middle" width="40">&nbsp;</td><td><table>';
}
elseif (strtoupper(substr($tmp['avatar'],0,7)) == 'HTTP://')
$link .= '
<td align="center" valign="middle"><img src="' . $tmp['avatar'] . '" height="40"></td><td><table>';
else
$link .= '
<td align="center" valign="middle"><img src="' . $modSettings['avatar_url'] . '/' . $tmp['avatar'] . '" height="40"></td><td><table>';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link .= '
<tr>
<td align="left" valign="bottom" nowrap><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '</a></td>
</tr>';
else
$link .= '
<tr>
<td align="left" valign="bottom" nowrap><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '">' . $tmp['realName'] . '</a></td>
</tr>';
// Number of total posts
$link .= '<tr>
<td align="left" valign="bottom">Posts:&nbsp;&nbsp;' . $tmp['posts'] . '</td>
</tr>';
// Time the member last logged in
$link .= '<tr>
<td align="left" valign="bottom">Last On:&nbsp;&nbsp;' . date("H:i", $tmp['lastLogin']) . '</td>
</tr></table></td></tr></table></fieldset></td></tr>';


$return['users'][] = array(
'id' => $tmp['ID_MEMBER'],
'username' => $tmp['memberName'],
'name' => $tmp['realName'],
'group' => $tmp['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'],
'link' => $link,
'is_last' => false
);
}
mysql_free_result($result);

$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];

if (!empty($return['users']))
$return['users'][count($return['users']) - 1]['is_last'] = true;

if ($output_method != 'echo')
return $return;

echo '
', $return['guests'], ' ', $return['guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', $return['num_users'], ' ', $return['num_users'] == 1 ? $txt['user'] : $txt['users'], $return['hidden'] > 0 ? ' (' . $return['hidden'] . ' ' . $txt['hidden'] . ')' : '', '<br />
';

echo '<table align="left" border="0">';
foreach ($return['users'] as $user)
echo $user['link'], !$user['is_last'] ? '' : '';
echo '</table>';
}
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Senkusha

Quote from: Mysterio on August 13, 2004, 12:59:14 PM
Senkusha, I tried installing the 'Avatar Online' mod, but it brought back some errors:

QuoteNotice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 271
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 272
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 273
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 274
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 275
Notice: Undefined variable: tmp in /****/****/****/****/Sources/BoardIndex.php on line 279

And here is what's on lines 271-275:

         
Quote'id' => $tmp['ID_MEMBER'],
         'username' => $tmp['memberName'],
         'name' => $tmp['realName'],
         'group' => $tmp['ID_GROUP'],

And 279:

Quoteif ($tmp['onlineColor'] != '')

How do I fix that?

Thanks.

This mod uses SSI.  Refer to the ssi_examples.php for configuration help.  You should only need to add ssi_WhosRecent () to your main webpage.
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Mysterio

I'm not talking about adding that to my website, but adding that to my forum.

Elisa

I do not succeed!  You can say me exactly as you have made?

Senkusha

Quote from: Mysterio on August 13, 2004, 03:43:33 PM
I'm not talking about adding that to my website, but adding that to my forum.

Where about do you want to add this to your forum?  you can use this function as is.  The only thing you need to do is build a 'shell' around your forum.  Let me know if this is acceptable or if you need further help.
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Senkusha

Quote from: Elisa on August 13, 2004, 03:52:21 PM
I do not succeed!  You can say me exactly as you have made?

Explain to me what is happening, or you could link to your website so I can see what is happening.

Thanks!
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Mysterio

Quote from: Senkusha on August 13, 2004, 04:05:43 PM
Where about do you want to add this to your forum? you can use this function as is. The only thing you need to do is build a 'shell' around your forum. Let me know if this is acceptable or if you need further help.

At the bottom of the forum. Like where everyone else wants it. You know, where it'll say the 5 most recent members or whatever, then displays the avatar, etc.

Tell me if you need more specific information and I'll do my best to explain it in detail.

Thanks.

Senkusha

So then you want this code here:

Quote from: Senkusha on August 11, 2004, 12:55:09 PM
Quote from: babylonking on August 11, 2004, 11:52:06 AM
Quote from: Senkusha on August 11, 2004, 11:49:13 AM
Sure!  Just to be specific, do you want the five most recent online members or just the five most recent members?

the most recent online should be fine  :)

Here is the code to add the avatars to the listing. Note this code is for all Online members:

Open BoardIndex.php and find:

// 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 = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_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']))
{
$context['num_users_hidden']++;
continue;
}


Replace it with the following code:

// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline, mem.avatar,
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 = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_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']))
{
$context['num_users_hidden']++;
continue;
}
// The user Avatar...
if ($row['avatar'] == '')
$link = '&nbsp;<br>';
elseif (strtoupper(substr($row['avatar'],0,7)) == 'HTTP://')
$link = '<img src="' . $row['avatar'] . '" height="40"><br>';
else
$link = '<img src="' . $modSettings['avatar_url'] . '/' . $row['avatar'] . '" height="40"><br>';

// 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>';



And delete the following (repeated lines at the bottom now):

// 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>';


Now if you want to limit this query to only five members, change this:

$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline, mem.avatar,
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 = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))", __FILE__, __LINE__);


to this:

$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline, mem.avatar,
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 = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP)) LIMIT 5", __FILE__, __LINE__);


That should do the trick for you.  Make sure you make a backup copy of the BoardIndex.php file!  I have tested this on my board, but since I only had myself active at the time, I can not gauntee that it works.

Let me know if you have any problems.
--Senkusha
The Anime Brigade
Anime-style Role Playing Games and Discussion.
(SMF v. 2.1.4, PHP v. 8.0)

Advertisement: