1 Star 0 Fork 1

爱玲 / codeigniter-ip2location

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

CodeIgniter IP2Location Library

This module enables users to retrieve below geolocation information from an IP address. It supports both the IPv4 and IPv6 address.

  • Country
  • Region
  • City
  • Latitude & Longitude
  • ZIP Code
  • Time Zone
  • Area Code
  • Net Speed
  • ISP
  • Domain
  • Mobile Information
  • Weather Station Information
  • Elevation
  • Usage Type

Installation

Upload controllers and libraries to CodeIgniter application folder.

IP2Location BIN Database

This module requires IP2Location BIN database to function. An outdated BIN database was provided in this release for your testing, but it's recommended to download the latest BIN database at the below link

For the BIN database update, you can just rename the downloaded BIN database to IP2LOCATION-DB.BIN and replace the copy in application/libraries/ip2location/ (if you didn't change the default IP2LOCATION_DATABASE constant as described in the below section).

IPv4 BIN vs IPv6 BIN

Use the IPv4 BIN file if you just need to query IPv4 addresses.

Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

Usage

Use following codes in your application for get geolocation information.

// Define IP2Location database path (optional). By default, the IP2LOCATION_DATABASE is pointed to *application/libraries/ip2location/IP2LOCATION-DB.BIN* if you choose not to change the original settings.
define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');

// Load the IP2Location library and perform the country code lookup
$this->load->library('ip2location_lib');
$countryCode = $this->ip2location_lib->getCountryCode('8.8.8.8');

Sample Code

Sample codes are given in this project, under controllers folder. You may run the sample code by using <your_domain>/index.php/ip2location_test.

Methods

Below are the methods supported.

$countryCode = $this->ip2location_lib->getCountryCode($ip);
$countryName = $this->ip2location_lib->getCountryName($ip);
$regionName = $this->ip2location_lib->getRegionName($ip);
$cityName = $this->ip2location_lib->getCityName($ip);
$latitude = $this->ip2location_lib->getLatitude($ip);
$longitude = $this->ip2location_lib->getLongitude($ip);
$isp = $this->ip2location_lib->getISP($ip);
$domainName = $this->ip2location_lib->getDomainName($ip);
$zipCode = $this->ip2location_lib->getZIPCode($ip);
$timeZone = $this->ip2location_lib->getTimeZone($ip);
$netSpeed = $this->ip2location_lib->getNetSpeed($ip);
$iddCode = $this->ip2location_lib->getIDDCode($ip);
$areaCode = $this->ip2location_lib->getAreaCode($ip);
$weatherStationCode = $this->ip2location_lib->getWeatherStationCode($ip);
$weatherStationName = $this->ip2location_lib->getWeatherStationName($ip);
$mcc = $this->ip2location_lib->getMCC($ip);
$mnc = $this->ip2location_lib->getMNC($ip);
$mobileCarrierName = $this->ip2location_lib->getMobileCarrierName($ip);
$elevation = $this->ip2location_lib->getElevation($ip);
$usageType = $this->ip2location_lib->getUsageType($ip);
MIT License Copyright (c) 2019 IP2Location.com 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.

简介

IP2Location library for CodeIgniter. Use IP2Location geolocation database to lookup the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type that any IP address or hostname originates from. 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/xiaoshen2017/codeigniter-ip2location.git
git@gitee.com:xiaoshen2017/codeigniter-ip2location.git
xiaoshen2017
codeigniter-ip2location
codeigniter-ip2location
master

搜索帮助