MyBB Community Forums

Full Version: Show Useragents on Online.php page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
If you want to show Useragent on who's online page, then here is how;

Open ./inc/functions_online.php page and find;
function build_wol_row($user)
{
	global $mybb, $lang, $templates, $theme, $session;

and Change it to;
function build_wol_row($user)
{
	global $mybb, $db, $lang, $templates, $theme, $session;

Now within the same file, find;
	$online_time = my_date($mybb->settings['timeformat'], $user['time']);
And add the following code Above that code;
$query = $db->simple_select("sessions", "useragent", "uid='{$user['uid']}'");
$user['useragent'] = $db->fetch_field($query, "useragent");

Save the file.

Now Go to: ACP > Templates > Your theme's templates > Online Templates > online_row > and find;
{$online_name}
And add the following code just after that;
<span style="float: right; font-size: 9px;">Useragent: {$user['useragent']}</span>

Save template.

It should result into this;
[Image: attachment.php?aid=416]
Very nice. Smile
awesome....thank you Smile
Thanks for the feedbacks.

First post edited. Now you can view Useragents of guests and bots too Wink
Hi, Yaldaram. Thank you for your great tutorial. But, bots useragents shows false.

Like this:

Google
Mozilla/5.0 (Windows NT 5.1; U; en) Opera 8.01
IP: 66.249.72.80

Does not have to be like this?:
googlebot/2.1 (+http://www.googlebot.com/bot.html)

Sorry for my english and greetings from Cyprus.
(2011-04-27, 07:17 PM)Serkan Wrote: [ -> ]Hi, Yaldaram. Thank you for your great tutorial. But, bots useragents shows false.

Like this:

Google
Mozilla/5.0 (Windows NT 5.1; U; en) Opera 8.01
IP: 66.249.72.80

Does not have to be like this?:
googlebot/2.1 (+http://www.googlebot.com/bot.html)

Sorry for my english and greetings from Cyprus.

its dependent on what useragent string the bot is providing to the server that gets displayed.
Can you make it so only administrators can see that?
Change above with this;
$query = $db->simple_select("sessions", "useragent", "uid='{$user['uid']}'");
$useragent = $db->fetch_field($query, "useragent");
if ($mybb->user['usergroup'] == 4)
{
$user['useragents'] = '<span style="float: right; font-size: 9px;">Useragent: '.$user['useragent'].'</span>';
}
Save the file.

Now Go to: ACP > Templates > Your theme's templates > Online Templates > online_row > and find;
{$online_name}
And add the following code just after that;
{$user['useragents']}

Save template.
Sorry this problem is not about bots useragent. All guests show the same. Can you help me Yaldaram?
for performance reasons, I would put the query inside the usergroup check as well. no point in running a query that you wont be using

if ($mybb->user['usergroup'] == 4)
{
$query = $db->simple_select("sessions", "useragent", "uid='{$user['uid']}'");
$useragent = $db->fetch_field($query, "useragent");
$user['useragents'] = '<span style="float: right; font-size: 9px;">Useragent: '.$user['useragent'].'</span>';
}

(2011-04-28, 01:53 PM)Serkan Wrote: [ -> ]Sorry this problem is not about bots useragent. All guests show the same. Can you help me Yaldaram?

its because he is using the UID for the query, it should be using the session ID. try this:

if ($mybb->user['usergroup'] == 4)
{
$query = $db->simple_select("sessions", "useragent", "sid='{$user['sid']}'");
$useragent = $db->fetch_field($query, "useragent");
$user['useragents'] = '<span style="float: right; font-size: 9px;">Useragent: '.$user['useragent'].'</span>';
} 
Pages: 1 2 3