25 lines
463 B
PHP
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]);
|
|
}
|
|
}
|