ip-location 纯真IP地址库,ipip
纯真IP地址库,composer包(解析QQWry.dat).
记录总数:547722条 更新日期:2024年01月24日
安装
$ composer require gai871013/ip-location -vvv
使用方式
在Laravel中使用
1.在 config/app.php
注册 ServiceProvider 和 Facade (Laravel 5.5 + 无需手动注册)
<?php ['providers' => [ // ... Gai871013IpLocationServiceProvider::class, ], 'aliases' => [ // ... 'IpLocation' => Gai871013IpLocationFacadesIpLocation::class, ], ];
2.使用:
<?php use Gai871013IpLocationFacadesIpLocation; // ... dump(app('IpLocation')->getLocation('www.wc87.com')); dd(IpLocation::getLocation('8.8.4.4')); array( "ip" => "101.200.45.167", "beginip" => "101.200.0.0", "endip" => "101.201.255.255", "country" => "北京市", "area" => "阿里云BGP数据中心", ); array( "ip" => "8.8.4.4", "beginip" => "8.8.4.4", "endip" => "8.8.4.4", "country" => "美国", "area" => "加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器", ); // ...
基本使用
<?php use Gai871013IpLocationIpLocation; $ipLocation = new IpLocation(); // url $url = 'https://www.baidu.com'; $ip = '127.0.0.1'; // 使用域名国家&运营商 $result = $ipLocation->getLocation($url); dump($result); array( "ip" => "61.135.169.125", "beginip" => "61.135.169.0", "endip" => "61.135.169.255", "country" => "北京市", "area" => "北京百度网讯科技有限公司联通节点", ); // 使用IP地址国家&运营商 $result = $ipLocation->getLocation($ip); dump($result); array( "ip" => "127.0.0.1", "beginip" => "127.0.0.1", "endip" => "127.0.0.1", "country" => "本机地址", "area" => "", ) ?>
<?php # ipip $path = 'path-to-ipdb.ipdb' || null; $city = new Gai871013IpLocationipipdbCity($path); var_dump($city->find('118.28.1.1')); var_dump($city->find('8.8.8.8')); var_dump($city->find('127.0.0.1'));
Contributing
You can contribute in one of three ways:
File bug reports using the issue tracker. Answer questions or fix bugs on the issue tracker. Contribute new features or update the wiki.The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT
Sponsors
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。