|
| 1 | +### IP2Proxy PHP Module |
| 2 | + |
| 3 | +This is the PHP module to lookup IP2Proxy databases from https://www.ip2location.com/proxy-database |
| 4 | + |
| 5 | +**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. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +#### Usage |
| 10 | + |
| 11 | +Open and read IP2Proxy binary database. There are 3 modes: |
| 12 | + |
| 13 | +1. **\IP2Proxy\Database::FILE_IO** - File I/O reading. Slower look, but low resource consuming. |
| 14 | +2. **\IP2Proxy\Database::MEMORY_CACHE** - Caches database into memory for faster lookup. Required high memory. |
| 15 | +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. |
| 16 | + |
| 17 | +``` |
| 18 | +require 'class.IP2Proxy.php'; |
| 19 | +
|
| 20 | +$db = new \IP2Proxy\Database('./samples/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); |
| 21 | +``` |
| 22 | + |
| 23 | +To start lookup result from database, use the following codes: |
| 24 | + |
| 25 | +``` |
| 26 | +$records = $db->lookup('1.0.241.135', \IP2Proxy\Database::ALL); |
| 27 | +``` |
| 28 | + |
| 29 | +Results are returned in array. |
| 30 | + |
| 31 | +``` |
| 32 | +echo '<p><strong>IP Address: </strong>' . $records['ipAddress'] . '</p>'; |
| 33 | +echo '<p><strong>IP Number: </strong>' . $records['ipNumber'] . '</p>'; |
| 34 | +echo '<p><strong>IP Version: </strong>' . $records['ipVersion'] . '</p>'; |
| 35 | +echo '<p><strong>Country Code: </strong>' . $records['countryCode'] . '</p>'; |
| 36 | +echo '<p><strong>Country: </strong>' . $records['countryName'] . '</p>'; |
| 37 | +echo '<p><strong>State: </strong>' . $records['regionName'] . '</p>'; |
| 38 | +echo '<p><strong>City: </strong>' . $records['cityName'] . '</p>'; |
| 39 | +
|
| 40 | +/* |
| 41 | + Type of proxy: VPN, TOR, DCH, PUB, WEB |
| 42 | +*/ |
| 43 | +echo '<p><strong>Proxy Type: </strong>' . $records['proxyType'] . '</p>'; |
| 44 | +
|
| 45 | +/* |
| 46 | + Returns -1 on errors |
| 47 | + Returns 0 is not proxy |
| 48 | + Return 1 if proxy |
| 49 | + Return 2 if it's data center IP |
| 50 | +*/ |
| 51 | +echo '<p><strong>Is Proxy: </strong>' . $records['isProxy'] . '</p>'; |
| 52 | +echo '<p><strong>ISP: </strong>' . $records['isp'] . '</p>'; |
| 53 | +``` |
| 54 | + |
| 55 | + |
| 56 | + |
0 commit comments