Coder Social home page Coder Social logo

ip2location / ip2proxy-laravel Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 3.0 20 KB

IP2Proxy Laravel extension enables the user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.

License: MIT License

PHP 100.00%
ip2proxy-laravel web-proxy tor-exits vpn-anonymizer laravel laravel-framework laravel-package laravel-extension ip2proxy ip2proxy-database proxy-database

ip2proxy-laravel's Introduction

IP2Proxy Laravel Extension

Latest Stable Version Total Downloads

IP2Proxy Laravel extension enables the user to query an IP address if it was being used as VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges, residential proxies, consumer privacy networks, and enterprise private networks.

Note: This extension works in Laravel 6, Laravel 7, Laravel 8 and Laravel 9.

INSTALLATION

Run the command: composer require ip2location/ip2proxy-laravel to download the package into the Laravel platform.

USAGE

IP2Proxy Laravel extension is able to query the IP address proxy 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.

BIN DATABASE

  1. Download IP2Proxy BIN database
  2. To use IP2Proxy databases, create a folder named as ip2proxy in the database directory.
  3. Unzip and copy the BIN file into database/ip2proxy/ folder.
  4. Rename the BIN file to IP2PROXY.BIN.
  5. Create a TestController in Laravel using the below command line
php artisan make:controller TestController
  1. Open the app/Http/Controllers/TestController.php in any text editor.
  2. To use IP2Proxy databases, add the below lines into the controller file
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use IP2ProxyLaravel;            //use IP2ProxyLaravel class

class TestController extends Controller
{
    //Create a lookup function for display
    public function lookup(){
        //Try query the geolocation information of 1.2.3.4 IP address
        $records = IP2ProxyLaravel::get('1.2.3.4', 'bin');

        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>';
        echo '<p><strong>Domain: </strong>' . $records['domain'] . '</p>';
        echo '<p><strong>Usage Type: </strong>' . $records['usageType'] . '</p>';
        echo '<p><strong>ASN: </strong>' . $records['asn'] . '</p>';
        echo '<p><strong>AS: </strong>' . $records['as'] . '</p>';
        echo '<p><strong>Last Seen: </strong>' . $records['lastSeen'] . '</p>';
        echo '<p><strong>Threat: </strong>' . $records['threat'] . '</p>';
        echo '<p><strong>Provider: </strong>' . $records['provider'] . '</p>';
    }
}
  1. Add the following line into the routes/web.php file.
Route::get('test', 'TestController@lookup');
  1. Enter the URL /public/test and run. You should see the information of 1.2.3.4 IP address.

WEB SERVICE

  1. To use IP2Location.io or IP2Proxy Web Service, create a new file called "site_vars.php" in config directory.
  2. In the site_vars.php, save the following contents for IP2Location.io:
<?php
return [
    'IP2LocationioAPIKey' => 'your_api_key', // Required. Your IP2Location.io API key.
    'IP2LocationioLanguage' => 'en', // Optional. Refer to https://www.ip2location.io/ip2location-documentation for available languages.
];

Or save the following contents for IP2Proxy:

<?php
return [
    'IP2ProxyAPIKey' => 'your_api_key', // Required. Your IP2Proxy API key.
    'IP2ProxyPackage' => 'PX1', // Required. Choose the package you would like to use.
    'IP2ProxyUsessl' => false, // Optional. Use https or http.
];
  1. Create a TestController in Laravel using the below command line
php artisan make:controller TestController
  1. Open the app/Http/Controllers/TestController.php in any text editor.
  2. To use IP2Proxy Web Service, add the below lines into the controller file.
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use IP2ProxyLaravel;            //use IP2ProxyLaravel class

class TestController extends Controller
{
    //Create a lookup function for display
    public function lookup(){
        //Try query the geolocation information of 1.2.3.4 IP address
        $records = IP2ProxyLaravel::get('1.2.3.4', 'ws');

        echo '<pre>';
        print_r($records);
        echo '</pre>';
    }
}
  1. Add the following line into the routes/web.php file.
Route::get('test', 'TestController@lookup');
  1. Enter the URL /public/test and run. You should see the information of 1.2.3.4 IP address.

DEPENDENCIES (IP2PROXY BIN DATA FILE)

This library requires IP2Proxy BIN data file to function. You may download the BIN data file at

SUPPORT

Email: [email protected]

Website: https://www.ip2location.com

ip2proxy-laravel's People

Contributors

ip2location avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ip2proxy-laravel's Issues

Error Class "IP2ProxyLaravel" not found

PHP 8.1.11
Laravel 9.36.4
Class "IP2ProxyLaravel" not found

code ///
use IP2ProxyLaravel;

public function index()
{
$ip = $_SERVER['REMOTE_ADDR'];
$records = IP2ProxyLaravel::get($ip, 'bin');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.