Skip to content

Commit c3f5b54

Browse files
committed
First release.
0 parents  commit c3f5b54

File tree

5 files changed

+160
-0
lines changed

5 files changed

+160
-0
lines changed

LICENSE.TXT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 IP2Location.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "ip2location/ip2proxy-cakephp",
3+
"description": "Allow users to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",
4+
"keywords": ["cakephp", "ip2proxy", "geolocation"],
5+
"homepage": "https://github.com/ip2location/ip2proxy-cakephp",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "IP2Location",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php": ">=5.4.0",
15+
"cakephp/cakephp": ">=3.0",
16+
"ip2location/ip2proxy-php": "1.*"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"IP2ProxyCakePHP\\": "src"
21+
}
22+
}
23+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace IP2ProxyCakePHP\Controller;
3+
4+
/**
5+
* IP2ProxyCores Controller
6+
*/
7+
class IP2ProxyCoresController
8+
{
9+
10+
/**
11+
* Index method
12+
*
13+
* @return \Cake\Http\Response|void
14+
*/
15+
public function index()
16+
{
17+
//
18+
}
19+
20+
public function get($ip, $query = array())
21+
{
22+
$obj = new \IP2Proxy\Database();
23+
$obj->open(ROOT . DS . 'vendor' . DS . 'ip2location' . DS . 'ip2proxy-cakephp' . DS . 'src' . DS . 'data' . DS . 'IP2PROXY.BIN', \IP2Proxy\Database::FILE_IO);
24+
25+
26+
try {
27+
$records = $obj->getAll($ip);
28+
} catch (Exception $e) {
29+
return null;
30+
}
31+
32+
$obj->close();
33+
return $records;
34+
}
35+
36+
}

src/Data/IP2PROXY.BIN

1 MB
Binary file not shown.

0 commit comments

Comments
 (0)