-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55882a0
commit e7fe904
Showing
7 changed files
with
2,224 additions
and
2 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
CodeIgniter IP2Proxy Library | ||
=============================== | ||
This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges and residential proxies. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats and last seen date. | ||
|
||
## Installation | ||
Upload `controllers` and `libraries` to CodeIgniter `application` folder. | ||
|
||
## Usage | ||
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. | ||
|
||
Sample codes are given in this project, under **controllers** folder. You may run the sample code by using <your_domain>/index.php/ip2proxy_test. | ||
|
||
### BIN Database | ||
Use following codes in your application for get geolocation information. | ||
|
||
// (optional) Define IP2Proxy database path. | ||
define('IP2PROXY_DATABASE', '/path/to/ip2proxy/database'); | ||
|
||
$ipx = new IP2Proxy_lib(); | ||
$countryCode = $ipx->getCountryShort('1.0.241.135'); | ||
|
||
Below are the methods supported for BIN data file lookup. | ||
|
||
$countryShort = $ipx->getCountryShort($ip); | ||
$countryLong = $ipx->getCountryLong($ip); | ||
$region = $ipx->getRegion($ip); | ||
$city = $ipx->getCity($ip); | ||
$isp = $ipx->getISP($ip); | ||
$doamin = $ipx->getDomain($ip); | ||
$usageType = $ipx->getUsageType($ip); | ||
$proxyType = $ipx->getProxyType($ip); | ||
$asn = $ipx->getASN($ip); | ||
$as = $ipx->getAS($ip); | ||
$lastSeen = $ipx->getLastSeen($ip); | ||
$threat = $ipx->getThreat($ip); | ||
$isProxy = $ipx->isProxy($ip); | ||
|
||
### Web Service | ||
Use following codes in your application for get geolocation information. | ||
|
||
// (required) Define IP2Proxy API key. | ||
define('IP2PROXY_API_KEY', 'your_api_key'); | ||
|
||
// (required) Define IP2Proxy Web service package of different granularity of return information. | ||
define('IP2PROXY_PACKAGE', 'PX1'); | ||
|
||
// (optional) Define to use https or http. | ||
define('IP2PROXY_USESSL', false); | ||
|
||
$ipx = new IP2Proxy_lib(); | ||
print_r ($ipx->getWebService('1.0.241.135')); | ||
|
||
## Dependencies | ||
This module requires IP2Proxy BIN data file or IP2Proxy API key to function. You may download the BIN data file at | ||
|
||
* IP2Proxy LITE BIN Data (Free): https://lite.ip2location.com | ||
* IP2Proxy Commercial BIN Data (Comprehensive): https://www.ip2location.com/proxy-database | ||
|
||
You can also sign up for [IP2Proxy Web Service](https://www.ip2location.com/web-service/ip2proxy) to get one free API key. | ||
|
||
## 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. | ||
|
||
## SUPPORT | ||
Email: support@ip2location.com | ||
|
||
Website: https://www.ip2location.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "ip2location/codeigniter-ip2proxy", | ||
"description": "IP2Proxy library for CodeIgniter. This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges and residential proxies using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats and last seen date.", | ||
"keywords": ["ip2proxy-bin-database", "geolocation-information", "codeigniter-ip2proxy", "ip-geolocation", "geolocation", "ip-lookup", "ip-address-database", "ip-database","web service", "proxy"], | ||
"homepage": "https://www.ip2location.com", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "IP2Location", | ||
"email": "support@ip2location.com", | ||
"homepage": "https://www.ip2location.com" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php namespace App\Controllers; | ||
|
||
use App\Libraries\IP2Proxy_lib; | ||
|
||
define('IP2PROXY_DATABASE', 'LOCATION OF YOUR BIN FILE'); | ||
|
||
class IP2Proxy_test extends BaseController { | ||
public function index() { | ||
$ipx = new IP2Proxy_lib(); | ||
|
||
// BIN Database | ||
$countryCode = $ipx->getCountryShort('1.0.241.135'); | ||
|
||
echo '<p>Country code for 1.0.241.135: ' . $countryCode . '</p>'; | ||
|
||
echo ' | ||
<div>You can download the latest BIN database at | ||
<ul> | ||
<li><a href="https://lite.ip2location.com">IP2Proxy LITE BIN Database (Free)</a></li> | ||
<li><a href="https://www.ip2location.com/proxy-database">IP2Proxy BIN Database (Comprehensive)</a></li> | ||
</ul> | ||
</div>'; | ||
|
||
// Web Service | ||
echo '<pre>'; | ||
print_r ($ipx->getWebService('1.0.241.135')); | ||
echo '</pre>'; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php namespace App\Libraries; | ||
|
||
// Web Service Settings | ||
if(!defined('IP2PROXY_API_KEY')) { | ||
define('IP2PROXY_API_KEY', 'demo'); | ||
} | ||
|
||
if(!defined('IP2PROXY_PACKAGE')) { | ||
define('IP2PROXY_PACKAGE', 'PX1'); | ||
} | ||
|
||
if(!defined('IP2PROXY_USESSL')) { | ||
define('IP2PROXY_USESSL', false); | ||
} | ||
|
||
require_once('ip2proxy/class.IP2Proxy.php'); | ||
|
||
class IP2Proxy_lib { | ||
private $database; | ||
|
||
protected static $ip2proxy; | ||
|
||
public function getCountryShort($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$countryShort = self::$ip2proxy->getCountryShort(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $countryShort; | ||
} | ||
|
||
public function getCountryLong($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$countryLong = self::$ip2proxy->getCountryLong(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $countryLong; | ||
} | ||
|
||
public function getRegion($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$region = self::$ip2proxy->getRegion(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $region; | ||
} | ||
|
||
public function getCity($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$city = self::$ip2proxy->getCity(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $city; | ||
} | ||
|
||
public function getISP($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$isp = self::$ip2proxy->getISP(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $isp; | ||
} | ||
|
||
public function getDomain($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$domain = self::$ip2proxy->getDomain(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $domain; | ||
} | ||
|
||
public function getUsageType($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$usageType = self::$ip2proxy->getUsageType(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $usageType; | ||
} | ||
|
||
public function getProxyType($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$proxyType = self::$ip2proxy->getProxyType(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $proxyType; | ||
} | ||
|
||
public function getASN($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$asn = self::$ip2proxy->getASN(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $asn; | ||
} | ||
|
||
public function getAS($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$as = self::$ip2proxy->getAS(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $as; | ||
} | ||
|
||
public function getLastSeen($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$lastSeen = self::$ip2proxy->getLastSeen(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $lastSeen; | ||
} | ||
|
||
public function getThreat($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$threat = self::$ip2proxy->getThreat(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $threat; | ||
} | ||
|
||
public function isProxy($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$isProxy = self::$ip2proxy->isProxy(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $isProxy; | ||
} | ||
|
||
public function getAll($ip=NULL) { | ||
self::$ip2proxy = new \IP2Proxy\Database(); | ||
self::$ip2proxy->open(IP2PROXY_DATABASE, \IP2Proxy\Database::FILE_IO); | ||
$all = self::$ip2proxy->getAll(self::getIP($ip)); | ||
self::$ip2proxy->close(); | ||
return $all; | ||
} | ||
|
||
public function getWebService($ip=NULL) { | ||
$ws = new \IP2Proxy\WebService(IP2PROXY_API_KEY, IP2PROXY_PACKAGE, IP2PROXY_USESSL); | ||
return $ws->lookup(self::getIP($ip)); | ||
} | ||
|
||
protected function getIP($ip=NULL) { | ||
return ($ip) ? $ip : $_SERVER['REMOTE_ADDR']; | ||
} | ||
} | ||
?> |
Oops, something went wrong.