Coder Social home page Coder Social logo

jfcherng / php-ip-location Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 27.05 MB

Get the location information from an IP.

Home Page: https://packagist.org/packages/jfcherng/php-ip-location

License: MIT License

PHP 100.00%
ip location ip-location php-71 psr-1 psr-2 psr-4

php-ip-location's Introduction

php-ip-location

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

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

安裝流程

  1. 使用 Composer 安裝: composer require jfcherng/php-ip-location

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

    1. 取得 IPIP.net 的 IP 離線資料庫 (ipipfree.ipdb)

    2. 純真 IP 資料庫 (qqwry.dat) 的 IPDB 格式版本

    3. 於使用時自行設定兩個資料庫的路徑

使用方式

demo.php

<?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) "教育网"
}
*/

php-ip-location's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-ip-location's Issues

Too few arguments

Too few arguments to function ipip\db\Reader::findMap()
jfcherng\php-ip-location\src\IpLocation.php on line 140 and exactly 2 expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.