2017 © Pedro Peláez
 

library php-ip-location

利用 IP 查詢地理位置。

image

jfcherng/php-ip-location

利用 IP 查詢地理位置。

  • Wednesday, July 18, 2018
  • by jfcherng
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

php-ip-location

GitHub Workflow Status (branch) Packagist Packagist Version Project license GitHub stars Donate to this project using Paypal, (*1)

利用 IPIPcz88 (純真) 兩個資料庫來查詢 IP 的地理位置。, (*2)

安裝流程

  1. 使用 Composer 安裝: composer require jfcherng/php-ip-location, (*3)

  2. 這樣就可以了,但如果你想要自己更新 IP 資料庫,請參考以下步驟:, (*4)

    1. 取得 IPIP.net 的 IP 離線資料庫 (ipipfree.ipdb)
    • 從 https://www.ipip.net/download.html 下載免費版離線資料庫 (需要登入以及手機驗證,可以免費註冊帳號)
    1. 純真 IP 資料庫 (qqwry.dat) 的 IPDB 格式版本
    • 從 https://github.com/metowolf/qqwry.ipdb 下載標準版
    1. 於使用時自行設定兩個資料庫的路徑

使用方式

demo.php, (*5)

<?php

use Jfcherng\IpLocation\IpLocation;

include __DIR__ . '/vendor/autoload.php';

$ipFinder = IpLocation::getInstance();

// 如果不想要使用內建的 IP 資料庫,請進行以下設定
$ipFinder->setup([
    // ipip 資料庫的路徑
    'ipipDb' => __DIR__ . '/src/db/ipipfree.ipdb',
    // cz88 資料庫的路徑
    'cz88Db' => __DIR__ . '/src/db/qqwry.ipdb',
]);

$ip = '202.113.245.255';

$results = $ipFinder->find($ip);

\var_dump($results);
/*
array(5) {
  ["country_name"]=>
  string(6) "中国"
  ["region_name"]=>
  string(6) "天津"
  ["city_name"]=>
  string(6) "天津"
  ["owner_domain"]=>
  string(0) ""
  ["isp_domain"]=>
  string(9) "教育网"
}
*/

The Versions

18/07 2018

dev-master

9999999-dev

利用 IP 查詢地理位置。

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

18/07 2018

1.0.4

1.0.4.0

利用 IP 查詢地理位置。

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

04/07 2018

1.0.3

1.0.3.0

利用 IP 查詢地理位置。

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

04/07 2018

1.0.2

1.0.2.0

利用 IP 查詢地理位置。

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

19/06 2018

1.0.1

1.0.1.0

利用 IP 查詢地理位置。

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng

07/04 2018

1.0.0

1.0.0.0

利用 IP 查詢地理位置。

  Sources   Download

The Requires

  • php ^7.1.3

 

The Development Requires

by Jack Cherng