Files
ipcheck/app/controller/Index.php
T
2022-07-06 11:21:58 +08:00

25 lines
462 B
PHP

<?php
namespace app\controller;
use itbdw\Ip\IpLocation;
use support\Request;
class Index
{
public function index(Request $request, $checkIp = null)
{
$ip = $request->getRealIp();
if ($checkIp) {
$ip = gethostbyname($checkIp);
}
$filepath = '/usr/src/myapp/lib/qqwry.dat';
$location = IpLocation::getLocation($ip, $filepath);
return json(['ip' => $ip, 'location' => $location]);
}
}