|
| 1 | +# IP2Proxy CakePHP Plugin |
| 2 | +IP2Proxy CakePHP plugin enables the user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits. It lookup the proxy IP address from IP2Proxy BIN Data file. Developers can use the API to query all IP2Proxy BIN databases for applications written using CakePHP. |
| 3 | + |
| 4 | + |
| 5 | +## INSTALLATION |
| 6 | +For CakePHP 3.x |
| 7 | + |
| 8 | +1. Run the command: `composer require ip2location/ip2proxy-cakephp` to download the plugin into the CakePHP 3 platform. |
| 9 | +2. Download latest IP2Proxy BIN database |
| 10 | + - IP2Proxy free LITE database at http://lite.ip2location.com |
| 11 | + - IP2Proxy commercial database at http://www.ip2location.com/proxy-database |
| 12 | +3. Unzip and copy the BIN file into *cakephp/vendor/ip2location/ip2proxy-cakephp/src/Data* folder. |
| 13 | +4. Rename the BIN file to IP2PROXY.BIN. |
| 14 | + |
| 15 | +**Note:** The plugin has included an old BIN database for your testing and development purpose. |
| 16 | +You may want to download a latest copy of BIN database as the URL stated above. |
| 17 | +The BIN database refers to the binary file ended with .BIN extension, but not the CSV format. |
| 18 | +Please select the right package for download. |
| 19 | + |
| 20 | + |
| 21 | +## USAGE |
| 22 | +In this tutorial, we will show you on how to create a **TestsController** to display the IP information. |
| 23 | + |
| 24 | +1. Create a **TestsController** in CakePHP 3 using the below command line |
| 25 | +``` |
| 26 | +php bin/cake bake controller Tests |
| 27 | +``` |
| 28 | +2. Create an empty **index.ctp** file in *cakephp/src/Template/Tests* folder. |
| 29 | +3. Open the **cakephp/src/Controller/TestsController.php** in any text editor. |
| 30 | +4. Remove the contents in TestsController.php and add the below lines into the controller file. |
| 31 | +``` |
| 32 | +<?php |
| 33 | +namespace App\Controller; |
| 34 | +
|
| 35 | +use App\Controller\AppController; |
| 36 | +use IP2ProxyCakePHP\Controller\IP2ProxyCoresController; |
| 37 | +
|
| 38 | +/** |
| 39 | + * Tests Controller |
| 40 | + */ |
| 41 | +class TestsController extends AppController |
| 42 | +{ |
| 43 | +
|
| 44 | + /** |
| 45 | + * Index method |
| 46 | + * |
| 47 | + * @return \Cake\Http\Response|void |
| 48 | + */ |
| 49 | + public function index() |
| 50 | + { |
| 51 | + $IP2Proxy = new IP2ProxyCoresController(); |
| 52 | + $record = $IP2Proxy->get('1.0.241.135'); |
| 53 | +
|
| 54 | + echo '<p><strong>IP Address: </strong>' . $record['ipAddress'] . '</p>'; |
| 55 | + echo '<p><strong>IP Number: </strong>' . $record['ipNumber'] . '</p>'; |
| 56 | + echo '<p><strong>IP Version: </strong>' . $record['ipVersion'] . '</p>'; |
| 57 | + echo '<p><strong>Country Code: </strong>' . $record['countryCode'] . '</p>'; |
| 58 | + echo '<p><strong>Country: </strong>' . $record['countryName'] . '</p>'; |
| 59 | + echo '<p><strong>State: </strong>' . $record['regionName'] . '</p>'; |
| 60 | + echo '<p><strong>City: </strong>' . $record['cityName'] . '</p>'; |
| 61 | + echo '<p><strong>Proxy Type: </strong>' . $record['proxyType'] . '</p>'; |
| 62 | + echo '<p><strong>Is Proxy: </strong>' . $record['isProxy'] . '</p>'; |
| 63 | + echo '<p><strong>ISP: </strong>' . $record['isp'] . '</p>'; |
| 64 | + } |
| 65 | +
|
| 66 | +} |
| 67 | +``` |
| 68 | +5. Enter the URL <your domain>/Tests and run. You should see the information of **1.0.241.135** IP address. |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +## DEPENDENCIES (IP2PROXY BIN DATA FILE) |
| 73 | +This library requires IP2Proxy BIN data file to function. You may download the BIN data file at |
| 74 | +* IP2Proxy LITE BIN Data (Free): http://lite.ip2location.com |
| 75 | +* IP2Proxy Commercial BIN Data (Comprehensive): http://www.ip2location.com/proxy-database |
| 76 | + |
| 77 | +## SUPPORT |
| 78 | + |
| 79 | + |
| 80 | +Website: http://www.ip2location.com |
0 commit comments