1 Star 0 Fork 6

罗钦 / ip-location

forked from 你走后 / ip-location 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ip-location 纯真IP地址库,ipip

纯真IP地址库,composer包(解析QQWry.dat).

记录总数:530422条 更新日期:2022年12月21日

## 安装
$ composer require gai871013/ip-location -vvv

使用方式

在Laravel中使用

1.在 config/app.php 注册 ServiceProvider 和 Facade (Laravel 5.5 + 无需手动注册)

<?php
['providers' => [
    // ...
    Gai871013\IpLocation\ServiceProvider::class,
],
'aliases' => [
    // ...
    'IpLocation' => Gai871013\IpLocation\Facades\IpLocation::class,
],
];

2.使用:

<?php
use Gai871013\IpLocation\Facades\IpLocation;

    // ...
    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 Gai871013\IpLocation\IpLocation;

$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 Gai871013\IpLocation\ipip\db\City($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:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. 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

JetBrains

MIT License Copyright (c) 2020 gai871013 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

纯真IP地址库,composer包(解析QQWry.dat). 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/myd0512/ip-location.git
git@gitee.com:myd0512/ip-location.git
myd0512
ip-location
ip-location
master

搜索帮助