Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.09k stars 372 forks source link

GeoIP returns different or even empty locations depending on the system #124

Open Sebbo94BY opened 5 years ago

Sebbo94BY commented 5 years ago

Laravel version: 5.6 Service: maxmind_database Cache: All Cache Tags: Empty as I use a not supported cache driver in Laravel

I've comitted the below code to Git as it is working fine in my local develop environment:

<?php
use Torann\GeoIP\Facades\GeoIP;

class someClass
{
    public function getLocation($ip_address) {
        $geoip = GeoIP($ip_address);
        if($geoip->ip == "127.0.0.0") {
            return false;
        }

        $location = $geoip->city . ", " . $geoip->state_name . ", " . $geoip->country;

        return $location;
    }
}

In my testing environment, I've verified, that everything works as expected and saw, that it's returning different values then in my local development environment.

When I call the above mentioned function now like this:

$someClass = new someClass();
$someClass->getLocation("84.110.43.7");

...it's returning different values or even some empty fields.

Local development environment:

Petah Tikva, Central District, Israel

Testing environment:

Bat Yam, Tel Aviv, Israel

Another example:

$someClass = new someClass();
$someClass->getLocation("87.186.76.132");

Local development environment:

Schmoelln, Thuringia, Germany

Testing environment:

, , Germany

Why does it return different locations and sometimes even empty fields?