JFIF$        dd7 

Viewing File: /home/vanquishholdings/public_html/src/vendor/akaunting/laravel-firewall/src/Middleware/Geo.php

<?php

namespace Akaunting\Firewall\Middleware;

use Akaunting\Firewall\Abstracts\Middleware;
use Illuminate\Support\Str;

class Geo extends Middleware
{
    public function check($patterns)
    {
        $places = ['continents', 'regions', 'countries', 'cities'];

        if ($this->isEmpty($places)) {
            return false;
        }

        if (! $location = $this->getLocation()) {
            return false;
        }

        foreach ($places as $place) {
            if (! $this->isFiltered($location, $place)) {
                continue;
            }

            return true;
        }

        return false;
    }

    protected function isEmpty($places)
    {
        foreach ($places as $place) {
            if (! $list = config('firewall.middleware.' . $this->middleware . '.' . $place)) {
                continue;
            }

            if (empty($list['allow']) && empty($list['block'])) {
                continue;
            }

            return false;
        }

        return true;
    }

    protected function isFiltered($location, $place)
    {
        if (! $list = config('firewall.middleware.' . $this->middleware . '.' . $place)) {
            return false;
        }

        $s_place = Str::singular($place);

        if (! empty($list['allow']) && ! in_array((string) $location->$s_place, (array) $list['allow'])) {
            return true;
        }

        if (in_array((string) $location->$s_place, (array) $list['block'])) {
            return true;
        }

        return false;
    }

    protected function getLocation()
    {
        $location = new \stdClass();
        $location->continent = $location->country = $location->region = $location->city = null;

        $service = config('firewall.middleware.' . $this->middleware . '.service');

        return $this->$service($location);
    }

    protected function ipapi($location)
    {
        $response = $this->getResponse('http://ip-api.com/json/' . $this->ip() . '?fields=continent,country,regionName,city');

        if (!is_object($response) || empty($response->country) || empty($response->city)) {
            return false;
        }

        $location->continent = $response->continent;
        $location->country = $response->country;
        $location->region = $response->regionName;
        $location->city = $response->city;

        return $location;
    }

    protected function extremeiplookup($location)
    {
        $response = $this->getResponse('https://extreme-ip-lookup.com/json/' . $this->ip());

        if (!is_object($response) || empty($response->country) || empty($response->city)) {
            return false;
        }

        $location->continent = $response->continent;
        $location->country = $response->country;
        $location->region = $response->region;
        $location->city = $response->city;

        return $location;
    }

    protected function ipstack($location)
    {
        $response = $this->getResponse('https://api.ipstack.com/' . $this->ip() . '?access_key=' . env('IPSTACK_KEY'));

        if (!is_object($response) || empty($response->country_name) || empty($response->region_name)) {
            return false;
        }

        $location->continent = $response->continent_name;
        $location->country = $response->country_name;
        $location->region = $response->region_name;
        $location->city = $response->city;

        return $location;
    }

    protected function ipdata($location)
    {
        $response = $this->getResponse('https://api.ipdata.co/' . $this->ip() . '?api-key=' . env('IPSTACK_KEY'));

        if (! is_object($response) || empty($response->country_name) || empty($response->region_name)) {
            return false;
        }

        $location->continent = $response->continent_name;
        $location->country = $response->country_name;
        $location->region = $response->region_name;
        $location->city = $response->city;

        return $location;
    }

    protected function ipinfo($location)
    {
        $response = $this->getResponse('https://ipinfo.io/' . $this->ip() . '/geo?token=' . env('IPINFO_KEY'));

        if (! is_object($response) || empty($response->country) || empty($response->city)) {
            return false;
        }

        $location->country = $response->country;
        $location->region = $response->region;
        $location->city = $response->city;

        return $location;
    }

    public function ipregistry($location)
    {
        $url = 'https://api.ipregistry.co/' . $this->ip() . '?key=' . env('IPREGISTRY_KEY');

        $response = $this->getResponse($url);

        if (! is_object($response) || empty($response->location)) {
            return false;
        }

        $location->continent = $response->location->continent->name;
        $location->country = $response->location->country->name;
        $location->country_code = $response->location->country->code;
        $location->region = $response->location->region->name;
        $location->city = $response->location->city;
        $location->timezone = $response->time_zone->id;
        $location->currency_code = $response->currency->code;

        $location->is_eu = $response->location->in_eu;

        if (! empty($response->location->language->code)) {
            $location->language_code = $response->location->language->code . '-' . $response->location->country->code;
        }

        return $location;
    }

    public function ip2locationio($location)
    {
        $url = 'https://api.ip2location.io/?ip=' . $this->ip() . '&key=' . env('IP2LOCATIONIO_KEY');

        $response = $this->getResponse($url);

        if (! is_object($response) || empty($response->location)) {
            return false;
        }

        $location->country = $response->country_name;
        $location->country_code = $response->country_code;
        $location->region = $response->region_name;
        $location->city = $response->city_name;
        $location->latitude = $response->latitude;
        $location->longitude = $response->longitude;
        $location->zipcode = $response->zip_code;
        $location->timezone = $response->time_zone;
        $location->asn = $response->asn;
        $location->as = $response->as;

        return $location;
    }

    protected function getResponse($url)
    {
        try {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 3);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
            $content = curl_exec($ch);
            curl_close($ch);

            $response = json_decode($content);
        } catch (\ErrorException $e) {
            $response = null;
        }

        return $response;
    }
}
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg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