Follow along with the video below to see how to install our site as a web app on your home screen.
Note: this_feature_currently_requires_accessing_site_using_safari
require_once("geoip2.phar");
use GeoIp2\Database\Reader;
// City DB
$reader = new Reader('GeoLite2-City.mmdb');
$record = $reader->city($ip);
//$_SERVER['REMOTE_ADDR']);
// or for Country DB
// $reader = new Reader('/path/to/GeoLite2-Country.mmdb');
// $record = $reader->country($_SERVER['REMOTE_ADDR']);
print($record->country->isoCode . "\n");
//print($record->country->name . "\n");
//print($record->country->names['zh-CN'] . "\n");
//print($record->mostSpecificSubdivision->name . "\n");
print($record->mostSpecificSubdivision->isoCode . "\n");
print($record->city->name . "\n");
Use MaxMind GEO-City
Sort of like this
PHP:require_once("geoip2.phar"); use GeoIp2\Database\Reader; // City DB $reader = new Reader('GeoLite2-City.mmdb'); $record = $reader->city($ip); //$_SERVER['REMOTE_ADDR']); // or for Country DB // $reader = new Reader('/path/to/GeoLite2-Country.mmdb'); // $record = $reader->country($_SERVER['REMOTE_ADDR']); print($record->country->isoCode . "\n"); //print($record->country->name . "\n"); //print($record->country->names['zh-CN'] . "\n"); //print($record->mostSpecificSubdivision->name . "\n"); print($record->mostSpecificSubdivision->isoCode . "\n"); print($record->city->name . "\n");
Or pay a service (tool) that will be slower
That is for a php pageThank you for helping me!
But how do insert it into index.html, so that it is on one line only etc
$.get("https://ipinfo.io", function(response) {
console.log(response.city, response.country);
}, "jsonp");