View Full Version : Get Client Info
Darko
October 18th, 2006, 14:31
while testing ($_SERVER['HTTP_USER_AGENT'];) predefined variable, to get some client info, i got some weird result,
on firefox i got:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
on opera i got:
Opera/9.00 (Windows NT 5.1; U; en)
on IE 7:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser; FDM; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
what does mozilla has to do with MS IE 7
----------------------------------------------------------------------------
Another thing, i used get_broswer to get the platform, and it worked fine on the server, but apparently one of my clients host is blocking it. is there anyway to get the os without using get_broswer
krakjoe
October 18th, 2006, 15:14
same for ie6, and has been for a couple of version now, not sure exactly why, but u see there ie identifies as MSIE and always has.
perhaps someone else knows the reason, for as long as I can remember it's been that way
Darko
October 19th, 2006, 10:56
so do you know, of anyway to get the client operating system, without using get_browser
krakjoe
October 19th, 2006, 11:32
theres not a fool proof way, best I can think of is
<?php
if (stripos($_SERVER['HTTP_USER_AGENT'], 'win') !== FALSE) {
echo "Windows environment";
} else {
echo "clever boy";
}
?>
themoose
October 19th, 2006, 12:45
I think IE6/7 is based on the Mozilla framework.. at least that's the only explanation I can think of.
http://www.siteware.ch/webresources/useragents/db.html is a pretty useful resource.
Darko
October 19th, 2006, 13:53
theres not a fool proof way, best I can think of is
<?php
if (stripos($_SERVER['HTTP_USER_AGENT'], 'win') !== FALSE) {
echo "Windows environment";
} else {
echo "clever boy";
}
?>
i made something very similar to that, but it's not very accurate, i need something like the one that they use in webaliser, do you know of any javascript code that can do it
Darko
October 23rd, 2006, 07:27
ok, so i found the script in the manual, and it's somewhat similar to what KRAK_JOE came up with:
$curos=strtolower($_SERVER['HTTP_USER_AGENT']);
if (strstr($curos,"mac")) {
$uos="MacOS";
} else if (strstr($curos,"linux")) {
$uos="Linux";
} else if (strstr($curos,"win")) {
$uos="Windows";
} else if (strstr($curos,"bsd")) {
$uos="BSD";
} else if (strstr($curos,"qnx")) {
$uos="QNX";
} else if (strstr($curos,"sun")) {
$uos="SunOS";
} else if (strstr($curos,"solaris")) {
$uos="Solaris";
} else if (strstr($curos,"irix")) {
$uos="IRIX";
} else if (strstr($curos,"aix")) {
$uos="AIX";
} else if (strstr($curos,"unix")) {
$uos="Unix";
} else if (strstr($curos,"amiga")) {
$uos="Amiga";
} else if (strstr($curos,"os/2")) {
$uos="OS/2";
} else if (strstr($curos,"beos")) {
$uos="BeOS";
} else
{ $uos="Unknown OS";
}
i just thought i put here, so if anybody in the future might needed, it will be on FWS
And if someone is intersted in developing it,, even more, here's a list of what HTTP_USER_AGENT might come back with:
http://www.siteware.ch/webresources/useragents/db.html#other
Regards
Darko
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.