Solved

Browser and OS detection

Posted on 2006-07-12
7
1,165 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now