Guest User

Untitled

a guest
Jan 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. $lines = file('GeoIPCountryWhois.csv');
  3. $lastIP = 0;
  4. $lastCountry = '';
  5. $fileC = -1;
  6. $data = array();
  7. foreach ($lines as $line_num => $line)
  8. {
  9.     $info = explode(",", $line, 6);
  10.     $iIP = trim($info[2], '"');
  11.     $iC = trim($info[4], '"');
  12.     if(bcdiv($iIP, 100000000, 0) != $fileC)
  13.     {
  14.         $fileC = bcdiv($iIP, 100000000, 0);
  15.         $data[$fileC][$lastIP] = $lastCountry;
  16.     }
  17.     $data[$fileC][$iIP] = strtolower($iC);
  18.     $lastIP = $iIP;
  19.     $lastCountry = strtolower($iC);
  20.  
  21. }
  22.  
  23. echo "<pre>".print_r($data, 1)."</pre>";
  24. ?>
Add Comment
Please, Sign In to add comment