1. Go to this page and download the library: Download kipkaev55/client-checker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kipkaev55 / client-checker example snippets
use ClientChecker\Client;
$client = new Client(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 YaBrowser/17.3.1.838 Yowser/2.5 Safari/537.36',
'172.68.11.66',
array( // on version 1.0.0 use './GeoLite2-City.mmdb' instead array()
'dbip' => array( //
'type' => 'mysql', //
'host' => '127.0.0.1', //
'db' => 'dbip', //
'user' => 'root', //
'password' => '123456' //
), //
'sypex' => './SxGeoCity.dat', //
// 'geoip' => './GeoLite2-City.mmdb', //
'sorting' => array('sypex', 'dbip', 'geoip') //
) //
);
/*
or
$client = new Client(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 YaBrowser/17.3.1.838 Yowser/2.5 Safari/537.36',
'172.68.11.66',
'./GeoLite2-City.mmdb',
'ru'
); //russian locale (supports [en, de, es, fr, ja, pt-BR, ru, zh-CN])
or
$client = new Client(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 YaBrowser/17.3.1.838 Yowser/2.5 Safari/537.36',
'172.68.11.66',
'./GeoLite2-City.mmdb',
'ru',
'path/to/custom/regexes.php'
); //custom regexes and russian locale
*/
echo ($client->isMobile()) ? 'true' : 'false'; //false
echo "\n";
echo $client->getOs(); //Mac OS X 10.12.4
echo "\n";
echo $client->getBrowser(); //Yandex Browser 17.3.1
echo "\n";
$geo = $client->getIpData();
echo $geo['country']; //RU
echo "\n";
echo $geo['city']; //Moscow
echo "\n";