-
Notifications
You must be signed in to change notification settings - Fork 21
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
5aab97d
commit 97ef394
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
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,56 @@ | ||
### IP2Proxy PHP Module | ||
|
||
This is the PHP module to lookup IP2Proxy databases from https://www.ip2location.com/proxy-database | ||
|
||
**IP2Proxy Database** contains IP addresses which are used as VPN anonymizer, open proxies, web proxies and Tor exits. The database includes records for all public IPv4 addresses. | ||
|
||
|
||
|
||
#### Usage | ||
|
||
Open and read IP2Proxy binary database. There are 3 modes: | ||
|
||
1. **\IP2Proxy\Database::FILE_IO** - File I/O reading. Slower look, but low resource consuming. | ||
2. **\IP2Proxy\Database::MEMORY_CACHE** - Caches database into memory for faster lookup. Required high memory. | ||
3. **\IP2Proxy\Database::SHARED_MEMORY** - Stores whole IP2Proxy database into system memory. Lookup is possible across all applications within the system. Extremely resources consuming. Do not use this mode if your system do not have enough memory. | ||
|
||
``` | ||
require 'class.IP2Proxy.php'; | ||
$db = new \IP2Proxy\Database('./samples/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); | ||
``` | ||
|
||
To start lookup result from database, use the following codes: | ||
|
||
``` | ||
$records = $db->lookup('1.0.241.135', \IP2Proxy\Database::ALL); | ||
``` | ||
|
||
Results are returned in array. | ||
|
||
``` | ||
echo '<p><strong>IP Address: </strong>' . $records['ipAddress'] . '</p>'; | ||
echo '<p><strong>IP Number: </strong>' . $records['ipNumber'] . '</p>'; | ||
echo '<p><strong>IP Version: </strong>' . $records['ipVersion'] . '</p>'; | ||
echo '<p><strong>Country Code: </strong>' . $records['countryCode'] . '</p>'; | ||
echo '<p><strong>Country: </strong>' . $records['countryName'] . '</p>'; | ||
echo '<p><strong>State: </strong>' . $records['regionName'] . '</p>'; | ||
echo '<p><strong>City: </strong>' . $records['cityName'] . '</p>'; | ||
/* | ||
Type of proxy: VPN, TOR, DCH, PUB, WEB | ||
*/ | ||
echo '<p><strong>Proxy Type: </strong>' . $records['proxyType'] . '</p>'; | ||
/* | ||
Returns -1 on errors | ||
Returns 0 is not proxy | ||
Return 1 if proxy | ||
Return 2 if it's data center IP | ||
*/ | ||
echo '<p><strong>Is Proxy: </strong>' . $records['isProxy'] . '</p>'; | ||
echo '<p><strong>ISP: </strong>' . $records['isp'] . '</p>'; | ||
``` | ||
|
||
|
||
|
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
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,22 @@ | ||
{ | ||
"name": "ip2location/ip2proxy-php", | ||
"type": "library", | ||
"description": "A PHP module to lookup for Proxy/VPN IP address from IP2Proxy database.", | ||
"keywords": ["geolocation", "detect vpn", "ip to vpn"], | ||
"homepage": "http://www.ip2location.com/", | ||
"license": "GPL", | ||
"authors": [ | ||
{ | ||
"name": "IP2Location", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"class.IP2Proxy.php" | ||
] | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
require 'class.IP2Proxy.php'; | ||
|
||
$db = new \IP2Proxy\Database('./samples/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); | ||
$records = $db->lookup('1.0.241.135', \IP2Proxy\Database::ALL); | ||
|
||
echo '<p><strong>IP Address: </strong>' . $records['ipAddress'] . '</p>'; | ||
echo '<p><strong>IP Number: </strong>' . $records['ipNumber'] . '</p>'; | ||
echo '<p><strong>IP Version: </strong>' . $records['ipVersion'] . '</p>'; | ||
echo '<p><strong>Country Code: </strong>' . $records['countryCode'] . '</p>'; | ||
echo '<p><strong>Country: </strong>' . $records['countryName'] . '</p>'; | ||
echo '<p><strong>State: </strong>' . $records['regionName'] . '</p>'; | ||
echo '<p><strong>City: </strong>' . $records['cityName'] . '</p>'; | ||
echo '<p><strong>Proxy Type: </strong>' . $records['proxyType'] . '</p>'; | ||
echo '<p><strong>Is Proxy: </strong>' . $records['isProxy'] . '</p>'; | ||
echo '<p><strong>ISP: </strong>' . $records['isp'] . '</p>'; |
Binary file not shown.