This commit is contained in:
Suvodip
2024-07-11 12:45:10 +05:30
parent d368213568
commit 040c4b87c1
33 changed files with 1042 additions and 867 deletions

View File

@@ -0,0 +1,21 @@
<?php
require '.hta_lib/vendors/maxmind-db-reader/vendor/autoload.php';
use GeoIp2\Database\Reader;
if (isset($_GET['ip'])) {
try {
$reader = new Reader('.hta_lib/data/GeoLite2-City.mmdb');
$records = $reader->city($_GET['ip']);
$city = $records->city->name;
echo json_encode(['city' => $city]);
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
}
} else {
echo json_encode(['error' => 'Invalid parameters']);
}
?>