From 6bddefe8b5e73a9d08da245a1f2c2ddea61665bd Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Fri, 28 May 2021 16:26:03 +0200 Subject: [PATCH] add plain json output --- src/plain.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/plain.php diff --git a/src/plain.php b/src/plain.php new file mode 100644 index 0000000..a26f423 --- /dev/null +++ b/src/plain.php @@ -0,0 +1,28 @@ +get($ip); + +$res["country"] = (new Reader($countrydb))->get($ip)["country"]["iso_code"]; +$res["asn"] = "AS".$asnr["autonomous_system_number"]." ".$asnr["autonomous_system_organization"]; + +if ($res["country"] == null) { + $res["country"] = "_unknown"; +} + +if ($asnr["autonomous_system_number"] == null) { + $res["asn"] = "No GeoIP entry found, are you new?"; +} + +print(json_encode($res, JSON_PRETTY_PRINT) . "\n");