Detect ip location, operating system and browser using PHP Detector Library
Jon Moffet
I've decided to share my PHP Detector library to the public which I've coded somewhere around 2006. The library does wonders in detecting IP address geo-location, operating system and the type of browser used based on its user-agent information.
The ip address->geo-location information is provided for free from ShowIP fakap webservice.
The library is handy for for creating web application which serve content depending on users location and type of operating system/browser that he use or for creating web application that collect web surfers statistical data.
Here's how to use Detector library :
The live demo of Detector library in action can be viewed here : Detector Library demo.
Requirements
- Requires PHP 4.4.0 or 5.0.x
- Requires php cURL extension installed, please refer here for workaround if your server doesn't have PHP cURL extension installed
License
Detector library is licensed under Creative Commons Attribution-ShareAlike 3.0, and can be modified and used in commercial application as long as you share the modified source code with the public.
Tags: php, php library, library, user-agent, browsers, detector, snippets
Posted in Uncategorized |








June 7th, 2007 at 10:17 pm
I’m not following how to get the city, state, and zip. After running your sample code, here is what I am receiving:
, ,, (74.135.147.136) using : Mozilla Firefox 1.5.0.12 on Mac OS Object>os_version
June 8th, 2007 at 7:11 pm
that’s funny. btw you computer must be connected to the internet when you run the application.
also may i know your php version?
June 12th, 2007 at 4:28 am
Yes, we are connected to the internet here at the office. The PHP is version 4.4.4
June 17th, 2007 at 4:02 am
August 9th, 2007 at 6:30 am
New BraunfelsTX, US,New Braunfels, (xxx.xxx.xxx.xxx) using : Mozilla Firefox 2.0.0.6 on Windows XP
Worked great! Thanks SO MUCH for putting this out there.
September 8th, 2007 at 1:54 pm
wow…nice one!
October 25th, 2007 at 3:52 am
Been using this for my web counter for the last month or so; brilliant script thanks. Doesn’t appear to be working today though - your “Detector Library Demo” link isn’t working either. Any idea what the problem is?
Thanks,
Phil Kynaston
October 25th, 2007 at 3:48 pm
random server maintenance i guess. It’s running fine now :)
November 13th, 2007 at 8:32 pm
How to change Windows NT 6.0 to Windows Vista ?
December 5th, 2007 at 1:32 pm
what this mean? can we change into ours?
$apiserver=”http://showip.fakap.net/txt/”;
October 7th, 2008 at 7:47 pm