TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 03, 2024, 06:32:28 PM

Login with username, password and session length
Members
  • Total Members: 3,881
  • Latest: fords8
Stats
  • Total Posts: 195,080
  • Total Topics: 21,209
  • Online today: 66
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 60
  • Total: 61
  • @rjen

Random User Block

Started by Xarcell, November 08, 2005, 09:25:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xarcell

Anyone know a way to create a random user block? Maybe even membergroup based?

-X

Pierse





houston

I tried that Snork13 and all I got was the tiltle bar with nothing below it.

IchBin

Can you post the code you put in?

houston

Quote from: IchBinÃ,â,,¢ on November 12, 2005, 10:07:35 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'] . '</a></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'] . '</a></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

you should put this code on SSI.php just below ssi_whosOnline function
and create a new php bloc with this:
ssi_whosRecent

houston

Quote from: Sakuragi on November 12, 2005, 11: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

Thanks I will give that a try.