diff --git a/app/Library/Helper.php b/app/Library/Helper.php index 03693d09..69b50c1a 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -124,15 +124,15 @@ function kg_object_array($object) } /** - * ip to region + * ip地址转区域 * - * @param $ip - * @param string $dbFile + * @param $ip string * @return array + * @throws Exception */ -function kg_ip2region($ip, $dbFile = null) +function kg_ip2region($ip) { - $searcher = new Ip2RegionSearcher($dbFile); + $searcher = new Ip2Region(); $ip2region = $searcher->btreeSearch($ip); diff --git a/composer.json b/composer.json index dd0d16f3..2b0f0bc9 100644 --- a/composer.json +++ b/composer.json @@ -16,12 +16,12 @@ "workerman/gatewayclient": "^3.0", "whichbrowser/parser": "^2.0", "hightman/xunsearch": "^1.4", - "xiaochong0302/ip2region": "^1.0", "robmorgan/phinx": "^0.12", "overtrue/wechat": "^4.2", "endroid/qr-code": "^3.9", "league/commonmark": "^1.5", - "ezyang/htmlpurifier": "^4.14" + "ezyang/htmlpurifier": "^4.14", + "zoujingli/ip2region": "^2.0" }, "require-dev": { "odan/phinx-migrations-generator": "^5.3", diff --git a/composer.lock b/composer.lock index 2fffa2d1..961cfa9d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b5eaf9b151226966d37ce2703e2e1efc", + "content-hash": "a5d21272eaa0df8bfcd5a3cea6d61fad", "packages": [ { "name": "bacon/bacon-qr-code", @@ -5255,55 +5255,6 @@ ], "time": "2022-09-19T04:08:49+00:00" }, - { - "name": "xiaochong0302/ip2region", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/xiaochong0302/ip2region.git", - "reference": "de2fbcb236cce91dfa1be2ff65516a46571b3565" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/xiaochong0302/ip2region/zipball/de2fbcb236cce91dfa1be2ff65516a46571b3565", - "reference": "de2fbcb236cce91dfa1be2ff65516a46571b3565", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Koogua\\Ip2Region\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "xiaochong0302", - "email": "xiaochong0302@gmail.com" - } - ], - "description": "ip2region扩展包", - "keywords": [ - "Ip2Region" - ], - "support": { - "issues": "https://github.com/xiaochong0302/ip2region/issues", - "source": "https://github.com/xiaochong0302/ip2region/tree/v1.0.2" - }, - "time": "2022-04-27T02:45:22+00:00" - }, { "name": "yansongda/pay", "version": "v2.10.5", @@ -5432,6 +5383,58 @@ "source": "https://github.com/yansongda/supports" }, "time": "2020-10-14T08:17:18+00:00" + }, + { + "name": "zoujingli/ip2region", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/zoujingli/ip2region.git", + "reference": "21ed5393a93ea62c277d91ee739b2373d60bf16d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zoujingli/ip2region/zipball/21ed5393a93ea62c277d91ee739b2373d60bf16d", + "reference": "21ed5393a93ea62c277d91ee739b2373d60bf16d", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.4" + }, + "type": "library", + "autoload": { + "classmap": [ + "Ip2Region.php", + "XdbSearcher.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Anyon", + "email": "zoujingli@qq.com", + "homepage": "https://thinkadmin.top" + } + ], + "description": "Ip2Region for PHP", + "homepage": "https://github.com/zoujingli/Ip2Region", + "keywords": [ + "Ip2Region" + ], + "support": { + "issues": "https://github.com/zoujingli/ip2region/issues", + "source": "https://github.com/zoujingli/ip2region/tree/v2.0.4" + }, + "time": "2023-03-28T02:20:00+00:00" } ], "packages-dev": [ @@ -5638,5 +5641,5 @@ "ext-fileinfo": "*" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.3.0" }