Reputation: 206
I need exactly all information as in following url
http://thetutlage.com/demo/tut_analytics/
Can any one tell me the solution for this in php ?
Upvotes: 2
Views: 13909
Reputation: 2900
You can not get all the information in one place.
Some information can be found in $_SERVER
including the clients browser.
You can use this information to get more details about the client:
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$browser = get_browser(null, true);
print_r($browser);
The above example will output something similar to:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3
Array
(
[browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$
[browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
[parent] => Firefox 0.9
[platform] => WinXP
[browser] => Firefox
[version] => 0.9
[majorver] => 0
[minorver] => 9
[cssversion] => 2
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] =>
[vbscript] =>
[javascript] => 1
[javaapplets] => 1
...
)
Some informations like the users location are harder to get.
To get the users location you can try to use a geoip lib or use ajax and sniff out the data via javascript.
Both approaches are covered in depth on SO so I`ll just point you to the search and wich you good luck ;)
Upvotes: 0
Reputation: 6335
Getting all information from one source is not possible.
You can use this library for getting information regarding user Operation system and its version and other details
https://github.com/GaretJax/phpbrowscap/.
You can get user device info using :
$browscap = @new Browscap(sys_get_temp_dir());
$device_details = $browscap->getBrowser();
The above will output :
stdClass Object
(
[browser_name] => Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
[browser_name_regex] => ^mozilla/5\.0 \(.*windows nt 6\.2.*wow64.*\) applewebkit/.* \(khtml, like gecko\).*chrome/26\..*safari/.*$
[browser_name_pattern] => Mozilla/5.0 (*Windows NT 6.2*WOW64*) AppleWebKit/* (KHTML, like Gecko)*Chrome/26.*Safari/*
[Parent] => Chrome 26.0
[Platform] => Win8
[Platform_Version] => 6.2
[Win32] =>
[Win64] => 1
[Comment] => Chrome 26.0
[Browser] => Chrome
[Version] => 26.0
[MajorVer] => 26
[MinorVer] => 0
[Beta] => 1
[Frames] => 1
[IFrames] => 1
[Tables] => 1
[Cookies] => 1
[JavaScript] => 1
[JavaApplets] => 1
[CssVersion] => 3
[Alpha] =>
[Win16] =>
[BackgroundSounds] =>
[VBScript] =>
[ActiveXControls] =>
[isMobileDevice] =>
[isSyndicationReader] =>
[Crawler] =>
)
PHP has an inbuilt function get_browser()
which will do the same. You have to browscap ini directive then.
If you want to get the user IP, then you can get it from the $_SERVER variable
$ip_address = $_SERVER["REMOTE_ADDR"];
If you want to know the user city, country etc then you can use the IP you got from the $_SERVER["REMOTE_ADDR"]
to get those . You can use these:
Hope these helps you :)
Upvotes: 0
Reputation: 1433
You can get a lot of info from the $_SERVER global-array.
IP Address: $_SERVER['REMOTE_ADDR']
Browser/OS/versions: $_SERVER['HTTP_USER_AGENT']
To get the City or some other geo information from the IP, Google for "geo IP". Quick note about geo IP: it's not waterproof. It's a managed database with IP addresses and their location. New IP ranges, or moved ("Second hand") IP addresses might not be (or not correct) in the database. Especially IPv6 for example.
Upvotes: 5
Reputation: 1271
You need to use Maxmind geoip database to get City/Country/Region: http://dev.maxmind.com/geoip/downloadable
Upvotes: 1
Reputation: 11830
Look at php functions.
for IP Address
$_SERVER['REMOTE_ADDR'];
similarly you have all other functions to get those values refer
$_SERVER
variable.
Upvotes: 0
Reputation: 7034
The $_SERVER superglobal is your solution -> http://php.net/manual/en/reserved.variables.server.php
Upvotes: 1