Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 04:46:50 AM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 51
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 46
Total: 46

Author Topic: Random User Block  (Read 18289 times)

0 Members and 1 Guest are viewing this topic.

Xarcell

  • Guest
Random User Block
« on: November 08, 2005, 02:25:52 PM »
Anyone know a way to create a random user block? Maybe even membergroup based?

-X

Pierse

  • Guest
Re: Random User Block
« Reply #1 on: November 08, 2005, 04:24:51 PM »
This would be great!

Sakuragi

  • Guest
Re: Random User Block
« Reply #2 on: November 12, 2005, 08:07:34 AM »

houston

  • Guest
Re: Random User Block
« Reply #3 on: November 12, 2005, 09:59:48 AM »

snork13

  • Guest

houston

  • Guest
Re: Random User Block
« Reply #5 on: November 12, 2005, 01:30:26 PM »
I tried that Snork13 and all I got was the tiltle bar with nothing below it.

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Random User Block
« Reply #6 on: November 12, 2005, 03:07:35 PM »
Can you post the code you put in?

houston

  • Guest
Re: Random User Block
« Reply #7 on: November 12, 2005, 03:22:47 PM »
Can you post the code you put in?

Here it is.

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

// 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 .= '<td></td><table>';
$link .= '
<td valign="middle" width="40"><img src="' . $scripturl . '?action=dlattach;id=' . $AvatarRes['ID_ATTACH'] . ';type=avatar" height="40"></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="top" nowrap><font size="1" face="Tahoma"><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '[/url]</font></td>
</tr>';
else
$link .= '
<tr>
<td align="left" valign="top" nowrap><font size="1" face="Tahoma"><a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '">' . $tmp['realName'] . '[/url]</font></td>
</tr>';
// Number of total posts
$link .= '<tr>
<td align="left" valign="top"><font size="1" face="Tahoma">Posts:&nbsp;' . $tmp['posts'] . '</font></td>
</tr>';
// Time the member last logged in
$link .= '<tr>
<td align="left" valign="top"><font size="1" face="Tahoma">Last On:&nbsp;' . date("H:i", $tmp['lastLogin']) . '</font></td>
</tr></table></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'] . ')' : '', '

';

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

Sakuragi

  • Guest
Re: Random User Block
« Reply #8 on: November 12, 2005, 04:24:26 PM »
you should put this code on SSI.php just below ssi_whosOnline function
and create a new php bloc with this:
ssi_whosRecent

houston

  • Guest
Re: Random User Block
« Reply #9 on: November 12, 2005, 09:33:35 PM »
you should put this code on SSI.php just below ssi_whosOnline function
and create a new php bloc with this:
ssi_whosRecent

Thanks I will give that a try.