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

Recent

Welcome to TinyPortal. Please login or sign up.

September 18, 2024, 05:11:39 AM

Login with username, password and session length
Members
  • Total Members: 3,905
  • Latest: acciply
Stats
  • Total Posts: 195,368
  • Total Topics: 21,241
  • Online today: 54
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 54
  • Total: 55
  • @rjen

Custom Who Template Query

Started by Sin69, February 14, 2007, 03:37:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sin69

I guess this is more a mod than a snippet for a block but please excuse me if I've posted this in the wrong area.

From the Custom Who Template  in the Tips & Tricks section posted on SMF...

Using the attached customised who.template.php dropped into my current theme folder, it overrides the default who.template.php (which still remains nicely intact in the default theme folder).

This does a great job in returning a separated list for users, guests and spiders along with a quick IP query and user agent query.

It's so convenient to have all this information at hand with only a quick glance at the who's online page.

What I'd dearly love is to display the results of another query (directly under the user agent info) which returns the "Members from IP (range)" results. (Like the information you see when an IP is clicked)

Useful to see at a glance if any of the IP's have multiple ID's and may marry up some guest IP's in the process.

The query for "Members from IP (range)" is drawn from the Profile.php in the sources directory and so far I haven't found any SSI statements as an alternative.

I'm at a loss on how to complete the query and have asked in that particular tips and tricks thread on SMF, but there's been no interest so far.

Please if anyone can help, it'd be much appreciated.

edit: re-attached modified temlate with code below added

Sin69

#1
Just to let you know where I'm at with this:

I've added $profile to the global statement and added the following below the user agent query...


echo '<br /> User agent: ' . $member['query']['USER_AGENT'];
echo '<br />';


// Find other users that might use the same IP.
$ips = array_unique($ips);
$context['members_in_range'] = array();
if (!empty($ips))
{
$request = db_query("
SELECT ID_MEMBER, realName
FROM {$db_prefix}members
WHERE ID_MEMBER != $memID
AND memberIP IN ('" . implode("', '", $ips) . "')", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
while ($row = mysql_fetch_assoc($request))
$context['members_in_range'][$row['ID_MEMBER']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
mysql_free_result($request);

$request = db_query("
SELECT mem.ID_MEMBER, mem.realName
FROM ({$db_prefix}messages AS m, {$db_prefix}members AS mem)
WHERE mem.ID_MEMBER = m.ID_MEMBER
AND mem.ID_MEMBER != $memID
AND m.posterIP IN ('" . implode("', '", $ips) . "')", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
while ($row = mysql_fetch_assoc($request))
$context['members_in_range'][$row['ID_MEMBER']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
mysql_free_result($request);
}


// List any members that have used the same IP addresses as the current member.
echo '', $txt['members_in_range'], ': ', (count($context['members_in_range']) > 0 ? implode(', ', $context['members_in_range']) : '(' . $txt['none'] . ')'), '<br />';


// The second table lists all the members who have been logged as using this IP address.
echo '', $txt['members_from_ip'], ' ', $context['ip'], '', $txt['ip_address'], '', $txt['display_name'], '';
if (empty($context['ips']))
echo '
', $txt['no_members_from_ip'], '';
else
// Loop through each of the members and display them.
foreach ($context['ips'] as $ip => $memberlist)
echo '<a href="', $scripturl, '?action=trackip;searchip=', $ip, ';">', $ip, '</a>', implode(', ', $memberlist), '';
echo '<br />';


No errors are displayed, but no result either  :'(
All that's displayed is: : ()

Sin69

My guess is that because it's returning a blank array, the query I'm trying to use isn't receiving the ip address from the original function to be able to return a result.

(I also tried adding $user_profile to the globals)

I'm completely lost with this. Anyone?