PimpMyLog icon indicating copy to clipboard operation
PimpMyLog copied to clipboard

GeoIP Flags

Open potsky opened this issue 11 years ago • 3 comments

Assigned to Suggestions #50. As reported in Tender:

Could You make Icon Flag (near IP or seperate column) by country from IP (geoip)?.
Important flags in attachment.

geoip like maxmind...
http://geoip3.maxmind.com/[a/b/f]?l=[LICENSE KEY]&i=[IP ADRESS]

Sample:
<?php
$licencja[1] = array('nr' => '1', 'typ' => 'e', 'klucz' => '[LICENSE KEY]', 'stan' => '0');
.
.
.
$licencja[10] = array('nr' => '10', 'typ' => 'a', 'klucz' => '[LICENSE KEY]', 'stan' => '1');

if ($licencja[$i]['typ'] == 'a') {
$geoip_kolumny = array(
'country_code',
'error'
);
}

# b - city
if ($licencja[$i]['typ'] == 'b') {
$geoip_kolumny = array(
'country_code',
'region_code',
'city_name',
'latitude',
'longitude',
'error'
);
}

# f - city/isp/org
if ($licencja[$i]['typ'] == 'f') {
$geoip_kolumny = array(
'country_code',
'region_code',
'city_name',
'postal_code',
'latitude',
'longitude',
'metro_code',
'area_code',
'isp_name',
'organization_name',
'error'
);
}

# e - omni
if ($licencja[$i]['typ'] == 'e') {
$geoip_kolumny = array(
'country_code',
'country_name',
'region_code',
'region_name',
'city_name',
'latitude',
'longitude',
'metro_code',
'area_code',
'time_zone',
'continent_code',
'postal_code',
'isp_name',
'organization_name',
'domain',
'as_number',
'netspeed',
'user_type',
'accuracy_radius',
'country_confidence',
'city_confidence',
'region_confidence',
'postal_confidence',
'error'
);
}

$maxmind_url = ('http://geoip3.maxmind.com/' . $licencja[$i]['typ'] . '?l=' . $licencja[$i]['klucz'] . '&i=' . $ban_ipv4);

                $curl = curl_init();
                curl_setopt_array($curl, array(
                    CURLOPT_URL => $maxmind_url,
                    CURLOPT_USERAGENT => 'MaxMind PHP Sample',
                    CURLOPT_TIMEOUT => 5,
                    CURLOPT_CONNECTTIMEOUT => 5,
                    CURLOPT_RETURNTRANSFER => true
                    )
                  );

                $resp = curl_exec($curl);

                if (curl_errno($curl)) {
                  echo ('Wystąpił błąd w funkcji pobierającej CURL().' . curl_errno($curl));
                  flush(); ob_flush();
                }
                $geoip_wartosci = str_getcsv(filtruj(str_replace("'", "\'", $resp)));
                $geoip_wartosci = array_pad($geoip_wartosci, sizeof($geoip_kolumny), '');
                $geoip = array_combine($geoip_kolumny, $geoip_wartosci);

?>

potsky avatar Oct 13 '14 10:10 potsky

it`s a great feature +1

syrakozz avatar Dec 25 '14 22:12 syrakozz

I agree. +1

Ishi-k2 avatar Dec 26 '14 18:12 Ishi-k2

Understood :-)

potsky avatar Dec 26 '14 19:12 potsky