Fix: ip2region改用包自带内置数据库,避免自定义xdb格式不兼容问题
This commit is contained in:
@@ -71,9 +71,8 @@ class UserController extends Controller
|
||||
$ipToLookup = $targetUser->login_ip ?: $targetUser->last_ip;
|
||||
if ($ipToLookup) {
|
||||
try {
|
||||
$xdbPath = database_path('ip2region/ip2region.xdb');
|
||||
// 第一个参数为缓存策略,第二个为自定义 IPv4 数据库路径
|
||||
$ip2r = new \Ip2Region('file', $xdbPath);
|
||||
// 不传路径,使用 zoujingli/ip2region 包自带的内置数据库
|
||||
$ip2r = new \Ip2Region();
|
||||
$info = $ip2r->getIpInfo($ipToLookup);
|
||||
|
||||
if ($info) {
|
||||
|
||||
Reference in New Issue
Block a user