UBB.Dev
Posted By: juggaleaux Finished-[6.3] Show Unregistered Hostnames - 04/16/2004 6:13 PM
Mod Name / Version: Show Unregistered Hostnames

Description: Shows the hostname of anonymous users on the "Who's Online" screen under the IP.

For example under 64.68.86.38 will show crawler2.googlebot.com

Working Under: UBB.Threads 6.3

Mod Status: Finished

Any pre-requisites:

Author(s): juggaleaux

Date: 04/16/04

Credits:

Files Altered: online.php
/templates/default/online.tmpl

New Files: none

Database Altered: none

Info/Instructions: a demo is here

In online.php, find this:

if ($user['U_Status'] == "Administrator") {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
}

and change to this:

if ($user['U_Status'] == "Administrator") {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
$hostname = gethostbyaddr($piece['1']);
$anonrow[$x]['hostname'] = $hostname;
}

In online.tmpl find this:

<td class="{$anonrow[$i]['color']}">
{$anonrow[$i]['Username']}
</td>

and change it to this:

<td class="{$anonrow[$i]['color']}">
{$anonrow[$i]['Username']}<BR>
<small>{$anonrow[$i]['hostname']}</small>
</td>

I've only tested this on 6.3, but it should work on some other versions as well.

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
thanx
Works well in 6.4.1, although the default code is a bit different in the online.tmpl file than what it is in 6.3.

Thanks!
It works but I get this at top of screen
6.4.1

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in /home/steelhea/public_html/ubbthreads/online.php on line 266
Posted By: scroungr Re: Finished-[6.3] Show Unregistered Hostnames - 04/20/2004 11:39 PM
add a @ before the gethostbyaddr so php doesn't broadcast it
thanks
Cool, great thx k:
would this work for 6.4.2? nice addon
It should work with a little workarround

I have a question: is there a way to speed gethostbyaddr somehow?
With DNS cach information perhaps?

My whosonline takes for about 50sec with aprox. 50-70 users online
Another idea to improve on this would be to add an option in the preferences in the admin panel.

Who's Online Settings
( ) Show IP addresses only
( ) Show hostnames only
( ) Show IP & hostnames

If someone could pull that off, that could be added to the core install. It doesn't take a whole lot of code, and it's not too obtrusive.
[]PaNTerSan said:
I have a question: is there a way to speed gethostbyaddr somehow?
My whosonline takes for about 50sec with aprox. 50-70 users online [/]
I've copied online.php to resolve.php and also the template files, made changes for @gethostbyaddr. Then I added another $adminlink in ubbt.inc.php - so now admins have Resolve and Who's online possibilites. Both serving their purpose
Posted By: Mirez Re: Finished-[6.3] Show Unregistered Hostnames - 06/11/2004 11:26 PM
We had this running on 6.4. We upgraded recently to 6.5(b1) and I'm glad to say its still fully functional
Posted By: DrChaos Re: Finished-[6.3] Show Unregistered Hostnames - 06/13/2004 11:18 PM
im on a new install of 6.5b1 and the directions worked as stated...
can you make this so mods and admin can see the host name?
Posted By: Twisty Re: Finished-[6.3] Show Unregistered Hostnames - 12/19/2004 12:48 PM
Easy-peasy, just change the first step above to this instead...

In online.php, find this:

if ($user['U_Status'] == "Administrator") {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
}

and change to this:

if (($user['U_Status'] == "Moderator") || ($user['U_Status'] == "Administrator") ) {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
$hostname = gethostbyaddr($piece['1']);
$anonrow[$x]['hostname'] = $hostname;
}
Posted By: StanCA Re: Finished-[6.3] Show Unregistered Hostnames - 12/22/2004 8:40 PM
FWIW this works well in 6.5
Posted By: smoknz28 Re: Finished-[6.3] Show Unregistered Hostnames - 12/23/2004 10:22 AM
Installed with v6.5 with no problem-o!

Thanks for sharing this code.
Posted By: smoknz28 Re: Finished-[6.3] Show Unregistered Hostnames - 05/15/2005 10:20 AM
Also, working under v6.5.1.1 without hitches.

The code to replace is the same.

You can update the hack to show that it works up to v6.5.1.1
Posted By: Poul Re: Finished-[6.3] Show Unregistered Hostnames - 04/20/2006 12:54 AM
[]Twisty said:
Easy-peasy, just change the first step above to this instead...

In online.php, find this:

if ($user['U_Status'] == "Administrator") {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
}

and change to this:

if (($user['U_Status'] == "Moderator") || ($user['U_Status'] == "Administrator") ) {
$piece['0'] = "";
preg_match("/-ANON-(.*)/",$Username,$piece);
$Username = $piece['1'];
$hostname = gethostbyaddr($piece['1']);
$anonrow[$x]['hostname'] = $hostname;
} [/]

If You make some changes this for registered users, it will be great
© UBB.Developers