mirror of
https://github.com/Karaka-Management/Build.git
synced 2026-01-20 07:38:41 +00:00
Algorithm for generating the ip/country table
This commit is contained in:
parent
df6f6202bb
commit
cfe15807af
19
ipGeoLocationBuilder.php
Normal file
19
ipGeoLocationBuilder.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$fh = fopen('GeoIPCountryWhois.csv', 'r');
|
||||
$fo = fopen('output.csv', 'w');
|
||||
|
||||
function ip2int(string $ip) : float {
|
||||
$split = explode('.', $ip);
|
||||
return $split[0] * (256 ** 3) + $split[1] * (256 ** 2) + $split[2] * (256 ** 1) + $split[3];
|
||||
}
|
||||
|
||||
while (($data = fgetcsv($fh, 150, ",")) !== FALSE) {
|
||||
fputcsv($fo, [ip2int($data[0]), ip2int($data[1]), $data[4]]);
|
||||
}
|
||||
|
||||
fclose($fo);
|
||||
fclose($fh);
|
||||
Loading…
Reference in New Issue
Block a user