The database of this identification program is a free IP database and an IP offline address database. Supports converting IP into structured country, province, city, county, operator, and regional information
0, the system is offline, and the code already contains the IPV4+IPV6 offline package.
1. The IPV4 database is based on the Innocence IP library. For IP address correction and the latest address, please go directly to the Innocence official website. For details, see the link at the bottom. See the link below for the IPV6 database.
2. Pure IP identification algorithm source network.
3. The structured program comes from my imagination in 2012.
When pure IP data is stored, it is not structured, so it is inevitable that there will be errors when parsed by structured programs. Domestic IP can identify provinces and basically identify cities. Operator and county data depends on luck.
The current version is 3.x (ipv4+ipv6). If you need 2.x, please visit https://github.com/itbdw/ip-database/tree/2.x
Currently, 3.x is seamlessly compatible with version 2.x and can theoretically be upgraded directly.
composer require 'itbdw/ip-database' ^3.0
//According to the actual situation, basically if you use a framework (such as Laravel), you do not need to introduce it manually //require 'vendor/autoload.php';use itbdwIpIpLocation;//0Configuration uses echo json_encode(IpLocation::getLocation($ip), JSON_UNESCAPED_UNICODE) . "n"; //Support custom file path $qqwry_filepath = '/abspath/qqwry.dat';$ipv6wry_path = '/abspath/ipv6wry.db';echo json_encode(IpLocation::getLocation($ip, $qqwry_filepath), JSON_UNESCAPED_UNICODE) . "n";
get success
{ "ip": "163.177.65.160", "country": "China", "province": "Guangdong", "city": "Shenzhen City", "county": "", "isp": "China Unicom" , "area": "Tencent Computer System Unicom Node, Shenzhen City, Guangdong Province, China"}
abnormal
{ "error": "ip invalid"}
cd 进入 ip-database 目录 ,composer install php tests/ip.php {"ip":"172.217.25.14","country":"美国","province":"","city":"","county":"","area":"美国 Google全球边缘网络","isp":""} {"ip":"140.205.172.5","country":"中国","province":"上海","city":"","county":"","area":"中国上海 阿里云","isp":""} {"ip":"123.125.115.110","country":"中国","province":"北京","city":"","county":"","area":"中国北京 北京百度网讯科技有限公司联通节点(BGP)","isp":"联通"} {"ip":"221.196.0.0","country":"中国","province":"天津","city":"河北区","county":"","area":"中国天津河北区 联通","isp":"联通"} {"ip":"60.195.153.98","country":"中国","province":"北京","city":"顺义区","county":"","area":"中国北京顺义区 后沙峪金龙网吧","isp":""} {"ip":"218.193.183.35","country":"中国","province":"上海","city":"","county":"","area":"中国上海 D27-707","isp":""} {"ip":"210.74.2.227","country":"中国","province":"北京","city":"","county":"","area":"中国北京 实验学院机房","isp":""} {"ip":"162.105.217.0","country":"中国","province":"北京","city":"","county":"","area":"中国北京 4区-4f","isp":""} {"ip":"fe80:0000:0001:0000:0440:44ff:1233:5678","country":"局域网","province":"","city":"","county":"","area":"局域网 本地链路单播地址","isp":""} {"ip":"2409:8900:103f:14f:d7e:cd36:11af:be83","country":"中国","province":"北京","city":"","county":"","area":"中国北京 中国移动CMNET网络","isp":"移动"} php tests/ip.php -i 58.196.128.0 {"ip":"58.196.128.0","country":"中国","province":"上海","city":"","county":"","area":"中国上海 上海交通大学","isp":""} php tests/ip.php -i 2409:8a00:6c1d:81c0:51b4:d603:57d1:b5ec {"ip":"2409:8a00:6c1d:81c0:51b4:d603:57d1:b5ec","country":"中国","province":"北京","city":"","county":"","area":"中国北京 中国移动公众宽带","isp":"移动"}
It is recommended that Tencent Cloud accelerate https://mirrors.cloud.tencent.com/help/composer.html
Reason #42
This project is also the result of many days and nights of thinking. If you think it is helpful to you, thank you with a shake of your hand.
1. Innocence IP library (needs to install EXE and decompress to obtain offline package) https://www.cz88.net/help?id=free
2. IPV6 (offline download package is no longer available) https://ip.zxinc.org/ipquery/