Files
ipcheck/app/controller/Index.php
T
2022-07-06 10:49:18 +08:00

25 lines
463 B
PHP

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