Solved

Browser and OS detection

Posted on 2006-07-12
7
1,169 Views
Last Modified: 2008-02-01
Hi guys.

I'm required to create a detailed script which will detect the users browser and general pc settings and i would greatly appriciate any advise and code snippets what you may be able to share with me.

I'm developing in PHP.

I'm trying to detect the following in relation to Broswers:
Browser Name (pretty straight forward)
Browser Version (straight forward)
Brower Plugins
Flash Version
Screen Resolution (i have done this already)
If cookies are enabled/disabled
If Javascript is enabled
(Any other important browser setting that i should attempt to detect that you may suggest?)

I'm just using:
[php]
<?php echo $_SERVER['HTTP_USER_AGENT']; ?>
<?php print "IP: ". $_SERVER ['REMOTE_ADDR']; ?>
[/php]
To detect the browser name and the IP address at the moment. Is there a better method of detecting either of these? Would that code be able to detect IP addresses behind a proxy?

Operating System:
What manufacturer
What version
What service pack

Some long shots! Is it possible to detect the Make and Model of the Router been used via PHP? And also if the user is using Anti-Virus or a Firewall on their system?

Any help is greatly appriciated. Thanks.
0
Comment
Question by:blaadom
  • 4
  • 3
7 Comments
 
LVL 8

Accepted Solution

by:
Autogard earned 500 total points
ID: 17095298
>>To detect the browser name and the IP address at the moment. Is there a better method of detecting either of these?
>>Operating System:
>>What manufacturer
>>What version
>>What service pack

The best way I've seen is to use www.php.net/get_browser.  It gives you a pretty comprehensive list of attributes of your visitor.  It requires that you use the "browscap" file (mentioned in that link as well as a link to an updated one).

>>Would that code be able to detect IP addresses behind a proxy?

I don't know of a way of detecting an IP address behind a proxy because the proxy simply hides the IP of the originating user.

>>Some long shots! Is it possible to detect the Make and Model of the Router been used via PHP? And also if the user is using Anti-Virus or a Firewall on their system?

Don't know if it's possible
0
 
LVL 8

Expert Comment

by:Autogard
ID: 17095322
I should note that the "get_browser" and browscap just works from a text file that has browser specifications, so it will show you what OS, version, browser, version, etc... the user is running and it will tell you if those browsers support javascript, frames, etc... but it doesn't tell you (as far as I know) if the user actually has those capabilities enabled or not.

As for your last question -- I sure hope it's not possible to detect some of those things because it would make it real easy to spread viruses, etc...  But there are probably other ways of finding out that stuff.

Just curious, what is the use case that you have that requires you to know so much about a user? :-)
0
 

Author Comment

by:blaadom
ID: 17095360
I'm developing a website which retrives browser settings and the likes.
Something similar to http://www.showmyip.com/gb/
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:Autogard
ID: 17095421
Wow, that's pretty involved.  Cool idea, though.

Yeah, you can get IP and host name using the method you explained above (I would also recommend using gethostbyaddr -- www.php.net/gethostbyaddr).  For some of the more advanced things, the browscap that I showed you should work.  There are other things like showing the country, etc... that would take extra work to do.

This should get you started at least though.
0
 

Author Comment

by:blaadom
ID: 17095733
showing the country and the isp as well as the users broadband exchange invloves getting an account with MaxMind, or similar, something on here http://www.maxmind.com/app/products . They have API's and the like but of course it costs money as you are using their database for some data mining. I might look into doing that if the website becomes proifitable.

It would be a nice touch as you mentioned. Thanks for the advise.
0
 
LVL 8

Expert Comment

by:Autogard
ID: 17095883
Yeah, because of so many variables (e.g. proxies, etc...) it is a really hard thing to be exact on the country and other similar information.  If you were to eventually go with a company like the one you mentioned I would make sure that they can guarantee some kind of accuracy or at least you can find out how they handle proxies, etc...

There are other free alternatives that may or may not be as good, I remember there being some EE questions on this topic.
0
 

Author Comment

by:blaadom
ID: 17096270
yes http://www.hostip.info/index.html is one site which offers a database of known IP addresses for free. http://ip-to-country.webhosting.info/ offer the same service.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question