You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module enables users to retrieve below geolocation information from an IP address. It supports both the IPv4 and IPv6 address.
5
4
6
5
* Country
@@ -19,61 +18,84 @@ This module enables users to retrieve below geolocation information from an IP a
19
18
* Usage Type
20
19
21
20
22
-
Installation
23
-
------------
21
+
## Installation
24
22
Upload `controllers` and `libraries` to CodeIgniter `application` folder.
25
23
26
-
IP2Location BIN Database
27
-
------------------------
28
-
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
29
-
* IP2Location LITE BIN Database (free): https://lite.ip2location.com
30
-
* IP2Location BIN Database (commercial version with high accuracy): https://www.ip2location.com
24
+
## Usage
25
+
This module is able to query the IP address information from either BIN database or web service. This section will explain how to use this extension to query from BIN database and web service.
31
26
32
-
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).
27
+
Sample codes are given in this project, under **controllers** folder. You may run the sample code by using <your_domain>/index.php/ip2location_test.
33
28
34
-
IPv4 BIN vs IPv6 BIN
35
-
------------------------
36
-
Use the IPv4 BIN file if you just need to query IPv4 addresses.
29
+
### BIN Database
30
+
Use following codes in your application for get geolocation information.
31
+
32
+
// (optional) Define IP2Location database path. By default, the IP2LOCATION_DATABASE is pointed to *application/libraries/ip2location/IP2LOCATION-DB.BIN* if you choose not to change the original settings.
Use following codes in your application for get geolocation information.
43
63
44
-
// 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.
// (required) Define IP2Location Web service package of different granularity of return information.
68
+
define('IP2LOCATION_PACKAGE', 'WS1');
50
69
51
-
Sample Code
52
-
-----------
53
-
Sample codes are given in this project, under **controllers** folder. You may run the sample code by using <your_domain>/index.php/ip2location_test.
70
+
// (optional) Define to use https or http.
71
+
define('IP2LOCATION_USESSL', false);
72
+
73
+
// (optional) Define extra information in addition to the above-selected package. Refer to https://www.ip2location.com/web-service/ip2location for the list of available addons.
74
+
define('IP2LOCATION_ADDONS', []);
75
+
76
+
// (optional) Define Translation information. Refer to https://www.ip2location.com/web-service/ip2location for available languages.
77
+
define('IP2LOCATION_LANGUAGE', 'zh-cn');
78
+
79
+
$ipl = new IP2Location_lib();
80
+
$countryCode = $ipl->getWebService('8.8.8.8');
81
+
82
+
## Dependencies
83
+
This module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at
84
+
85
+
* IP2Location LITE BIN Data (Free): https://lite.ip2location.com
86
+
* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com
87
+
88
+
An outdated BIN database was provided in this release for your testing. You are recommended to visit the above links to download the latest BIN database.
89
+
90
+
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 Usage section).
91
+
92
+
You can also sign up for [IP2Location Web Service](https://www.ip2location.com/web-service/ip2location) to get one free API key.
93
+
94
+
## IPv4 BIN vs IPv6 BIN
95
+
* Use the IPv4 BIN file if you just need to query IPv4 addresses.
96
+
* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
0 commit comments