From e668fe566c8d17de27ce5549e08032dbe9e01e4d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 1 Apr 2017 15:25:54 +0200 Subject: [PATCH] Remove Ip localization --- Utils/Converter/Ip.php | 47 ------------------------------------------ 1 file changed, 47 deletions(-) diff --git a/Utils/Converter/Ip.php b/Utils/Converter/Ip.php index a6c09c53c..50ec71b73 100644 --- a/Utils/Converter/Ip.php +++ b/Utils/Converter/Ip.php @@ -30,59 +30,12 @@ namespace phpOMS\Utils\Converter; */ class Ip { - /* public */ const IP_TABLE_PATH = __DIR__ . '/../../Localization/Default/Ip/ipGeoLocation.csv'; /* public */ const IP_TABLE_ITERATIONS = 100; private function __construct() { } - public static function ip2Country(string $ip) : string - { - $fh = fopen(self::IP_TABLE_PATH, 'r'); - - fseek($fh, 0, SEEK_END); - $end = ftell($fh); - fseek($fh, 0); - $start = 0; - $current = $start; - - $ip = self::ip2Float($ip); - $country = ''; - $counter = 0; - - while ($counter < self::IP_TABLE_ITERATIONS) { - $line = fgets($fh, 150); - if ($current !== 0) { - $line = fgets($fh, 150); - } - - $split = explode(',', $line); - - if ($ip >= $split[0] && $ip <= $split[1]) { - $country = $split[2]; - break; - } - - if ($ip > $split[1]) { - $larger = true; - $start = $current; - fseek($fh, (int) (($end - $current) / 2), SEEK_CUR); - } else { - $larger = false; - $end = $current; - fseek($fh, (int) (($start - $current) / 2), SEEK_CUR); - } - - $counter++; - $current = ftell($fh); - } - - fclose($fh); - - return $country; - } - public static function ip2Float(string $ip) : float { $split = explode('.', $ip);